移动端如何播放M3U8格式的视频

时间:2024-02-18 22:52:55
<!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>
      <a href="www.zhuanl8.cn">赚来吧课堂</a>
<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> function ajaxvideo(hid){ //hid是 地址如 http://sp.sdsthk.com/%e8%a1%a5%e5%85%85%e5%a4%a7%e7%ba%b2.m3u8 var myPlayer = videojs(\'example-video\'); myPlayer.src({\'src\':hid,\'type\':\'application/x-mpegURL\'}); }

 www.zhuanl8.cn 惊喜不断