zoukankan      html  css  js  c++  java
  • 代码(m3u8视频源播放器代码)

     以下是代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>m3u8</title>
        <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://cdn.bootcss.com/hls.js/8.0.0-beta.3/hls.min.js"></script>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            #player{
                width: 100vw;
                height: auto;
            }
        </style>
    </head>
    <body>
        <div class="input-div">
            <form method="post" id="str-post">
                <input type="text" value="https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8" name="url" placeholder="请输入m3u8播放地址" autocomplete="off">
                <button type="submit">播放</button>
            </form>
        </div>
        <video id="player" controls=""></video>
        <script>
            function playM3u8(url){
                if(Hls.isSupported()) {
                    var video = document.getElementById('player');
                    video.volume = 1.0;
                    var hls = new Hls();
                    var m3u8Url = decodeURIComponent(url)
                    hls.loadSource(m3u8Url);
                    hls.attachMedia(video);
                    hls.on(Hls.Events.MANIFEST_PARSED,function() {
                        video.play();
                    });
                }
            }
            $("#str-post").submit(function () {
                $("html,body").animate({
                    scrollTop: $(".input-div").offset().top - 20
                }, 200);
                playM3u8($("#str-post").serializeArray()[0].value);
                return false;
            })
        </script>
    </body>
    </html>
  • 相关阅读:
    「总结」容斥。二.反演原理 3.约数容斥
    「总结」容斥。二.反演原理 2.组合容斥
    「总结」容斥。二.反演原理 1.子集容斥
    「总结」容斥。一.容斥原理
    「考试」num (破800纪念)
    「刷题」 网络
    「考试」 Or
    「考试」weight
    「刷题」GERALD07加强版
    「刷题」Triple
  • 原文地址:https://www.cnblogs.com/wuhairui/p/12775677.html
Copyright © 2011-2022 走看看