gpt4 book ai didi

javascript - HLS 视频在 chrome 上不可见 |视频.js

转载 作者:行者123 更新时间:2023-11-30 21:13:10 25 4
gpt4 key购买 nike

我正在尝试使用 video.js 在我的 wordpress 网站上播放 HLS 视频。 我能听到音频,但看不到视频。知道为什么会这样。

我尝试了其他链接(例如 this ),视频是可见的。但是,就我而言,我的视频都不可见。请注意,数据位于 S3 上,具有公共(public)访问权限。

我的代码如下:

<link href="http://vjs.zencdn.net/6.2.5/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js"></script>

<video id=example-video width=960 height=400 class="video-js vjs-default-skin" controls>
<source
src="https://s3.amazonaws.com/sffs-upload-steve/v1/hls/sffs-2014-short-012/sffs-2014-short-012.m3u8"
type="application/x-mpegURL">
</video>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link href="https://unpkg.com/video.js/dist/video-js.css" rel="stylesheet">
<script src="https://unpkg.com/video.js/dist/video.js"></script>
<script src="https://unpkg.com/videojs-flash/dist/videojs-flash.js"></script>
<script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script>


<script>
(function(window, videojs) {
var player = window.player = videojs('example-video');
var loadUrl = document.getElementById('load-url');
var url = document.getElementById('url');
loadUrl.addEventListener('submit', function(event) {
event.preventDefault();
player.src({
src: url.value,
type: 'application/x-mpegURL'
});
return false;
});
}(window, window.videojs));
</script>

请帮忙。

最佳答案

我不确定上面代码的真正问题是什么,因为我没有足够的 web 相关知识。然而,我发现this堆栈溢出的解决方案和事情开始工作:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Video</title>

<link href="http://vjs.zencdn.net/4.12/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.12/video.js"></script>
<script src="https://github.com/videojs/videojs-contrib-media-sources/releases/download/v0.1.0/videojs-media-sources.js"></script>
<script src="https://github.com/videojs/videojs-contrib-hls/releases/download/v0.11.2/videojs.hls.min.js"></script>

</head>
<body>
<h1>Video</h1>

<video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="268"
data-setup='{}'>
<source src="http://iphone-streaming.ustream.tv/uhls/3064708/streams/live/iphone/playlist.m3u8" type='application/x-mpegURL'>
</video>

<script>
var player = videojs('my_video_1');
</script>

</body>
</html>

<!-- Replace current .m3u8 and check..current file has access issue-->

更新此解决方案有时也不起作用。可能是 HLS 视频的带宽问题。我的 S3 存储桶在美国,因为用户在那里。但是,我正在从巴基斯坦访问它。所以问题仍然存在。可能是什么问题?如何解决?

关于javascript - HLS 视频在 chrome 上不可见 |视频.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45924975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com