阅读:3299回复:0
videojs 播放.M3U8格式视频
1.原生video标签网页端只支持MP4、OGG、WebM的视频格式
2.直播的视频格式一般为.m3u8,如果不行对video进行格外处理,可以采用video.js插件 3.video.js须配合第三方的videojs库videojs-contrib-hls.js来播放.m3u8视频 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>videoJs</title> <link rel="stylesheet" type="text/css" href="css/video-js.css"> <script src="js/video.min.js"></script> <script src="https://unpkg.com/videojs-contrib-hls/dist/videojs-contrib-hls.js"></script> </head> <body> <section id="videoPlayer"> <video id="example-video" width="600" height="300" class="video-js vjs-default-skin vjs-big-play-centered" poster=""> <source src="http://rm03.wscdn.hls.xiaoka.tv/live/fczjp0Dc_J60VGMN/playlist.m3u8" type="application/x-mpegURL" id="target"> </video> </section> <script type="text/javascript"> var player = videojs('example-video', { "poster": "", "controls": "true" }, function() { this.on('play', function() { console.log('正在播放'); }); //暂停--播放完毕后也会暂停 this.on('pause', function() { console.log("暂停中") }); // 结束 this.on('ended', function() { console.log('结束'); }) }); </script> </body> </html> |
|