剑轩

使用dplayer进行视频播放

电脑版发表于:2020/8/22 14:22

贴个小demo:

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>测试视频播放</title>
    <script src="~/lib/DPlayer/DPlayer.js"></script>
</head>
<body>
        <div id="player1" class="dplayer" style="width:600px;height:400px">

        </div>

    <script>

        var dp1 = new DPlayer({
            element: document.getElementById('dplayer1'),
            preload: 'none',
            screenshot: true,
            video: {
                url: 'https://api.dogecloud.com/player/get.mp4?vcode=5ac682e6f8231991&userId=17&ext=.mp4',
                pic: 'https://i.loli.net/2019/06/06/5cf8c5d9c57b510947.png',
                thumbnails: 'https://i.loli.net/2019/06/06/5cf8c5d9cec8510758.jpg'
            },
            subtitle: {
                url: 'https://s-sh-17-dplayercdn.oss.dogecdn.com/hikarunara.vtt'
            }
        });

    </script>
</body>
</html>

视频的宽高就由那个小div来觉定,它会自适应的,效果如下。还是很不错的一个播放效果



想要有播放集数的效果,就是弄一个左右布局写一点东西即可,左右布局可以参考:
https://www.tnblog.net/aojiancc2/article/details/4887



关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢