VideoJS的播放功能

时间:2019-03-04 17:57:15

标签: video.js hls

我对播放器有问题,重点是当我尝试调用player.play();时。什么都没发生。 Chrome 72

	var player = videojs('content_video');
	
	player.src({
			src: "https://vdn.terrafox.com/sf/bb-baycam/playlist.m3u8",
			type: "application/x-mpegURL"
	})
	player.ready(() => {
	   player.play()
	})	
	 <link href="http://vjs.zencdn.net/5.19/video-js.css" rel="stylesheet">
	 <script src="http://vjs.zencdn.net/5.19/video.js"></script>
	 <script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.8.0/videojs-contrib-hls.min.js" ></script>  
   
    <video id="content_video" class="video-js vjs-default-skin" controls preload="auto" autoplay playsinline width="640" height="360">
    </video>

1 个答案:

答案 0 :(得分:0)

您正在使用的链接(即https://vdn.terrafox.com/sf/bb-baycam/playlist.m3u8)不存在。因此播放功能不起作用。如果您为ex使用正确的网址。 https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8,它将起作用。

	var player = videojs('content_video');
	
	player.src({
			src: "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8",
			type: "application/x-mpegURL"
	})
	player.ready(() => {
	   player.play()
	})	
	 <link href="http://vjs.zencdn.net/5.19/video-js.css" rel="stylesheet">
	 <script src="http://vjs.zencdn.net/5.19/video.js"></script>
	 <script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.8.0/videojs-contrib-hls.min.js" ></script>  
   
    <video id="content_video" class="video-js vjs-default-skin" controls preload="auto" autoplay playsinline width="640" height="360">
    </video>