苹果CMS Dplayer播放器自动下一集

DPlayer 是一款可爱的 HTML5 弹幕视频播放器,可帮助人们轻松构建视频和弹幕。在苹果cms的配置中,默认的播放器不会自动播放,也不会自动播放下一集视频,需要手工修改Dplayer的代码。目前Dplayer播放器在网络上比较流行,且性能与功能方面比较出众,下面看一看如何配置Dplayer播放器。

苹果CMS设置Dplayer播放器自动播放下一集

在苹果cms的配置中,默认的播放器不会自动播放,也不会自动播放下一集视频,需要手工修改Dplayer的代码。目前Dplayer播放器在网络上比较流行,且性能与功能方面比较出众,下面看一看如何配置Dplayer播放器。

Dplayer播放器是谁?

DPlayer 是一款可爱的 HTML5 弹幕视频播放器,可帮助人们轻松构建视频和弹幕。

DPlayer网站地址:https://dplayer.js.org/

Github项目地址:https://github.com/DIYgod/DPlayer

整合dplayer播放器增加记忆,P2P播放和自动下一集的Dplayer播放器代码

替换下面的dplayer播放器代码,替换目录苹果cms系统static/player/dplayer.html 全部内容替换即可。

<!DOCTYPE html>
<html>
<head>
    <title>dplayer 1.27.0 播放器p2p加速+记忆播放</title>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8"/>
    <meta http-equiv="content-language" content="zh-CN"/>
    <meta http-equiv="X-UA-Compatible" content="chrome=1"/>
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="expires" content="0"/>
    <meta name="referrer" content="never"/>
    <meta name="renderer" content="webkit"/>
    <meta name="msapplication-tap-highlight" content="no"/>
    <meta name="HandheldFriendly" content="true"/>
    <meta name="x5-page-mode" content="app"/>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport">
    <style type="text/css">
        body,html{width:100%;height:100%;background:#000;padding:0;margin:0;overflow-x:hidden;overflow-y:hidden}
        *{margin:0;border:0;padding:0;text-decoration:none}
        #stats{position:fixed;top:5px;left:8px;font-size:12px;color:#fdfdfd;text-shadow:1px 1px 1px #000, 1px 1px 1px #000}
        #playerCnt{width:100%;height:100%;}
    </style>
    <link rel="stylesheet" href="/static/player/dplayer/DPlayer.min.css">
    <script type="text/javascript" src="/static/player/dplayer/flv.min.js"></script>
    <script type="text/javascript" src="/static/player/dplayer/hls.min.js"></script>
    <script type="text/javascript" src="/static/player/dplayer/dash.all.min.js"></script>
    <script type="text/javascript" src="/static/player/dplayer/webtorrent.min.js"></script>
    <script type="text/javascript" src="/static/player/dplayer/DPlayer.min.js"></script>
</head>
<body style="background:#000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" oncontextmenu=window.event.returnValue=false>
<div id="playerCnt"></div>
<div id="stats"></div>
<script language="Javascript">
    document.oncontextmenu=new Function("event.returnValue=false");
    document.onselectstart=new Function("event.returnValue=false");
</script>
<script src="https://cdn.jsdelivr.net/npm/cdnbye@latest"></script>
<script>
    var type='normal';
    var live=false;
    if(parent.MacPlayer.PlayUrl.indexOf('.m3u8')>-1){
        type='hls';
        live=true;
    }
    else if(parent.MacPlayer.PlayUrl.indexOf('magnet:')>-1){
        type='webtorrent';
    }
    else if(parent.MacPlayer.PlayUrl.indexOf('.flv')>-1){
        type='flv';
    }
    else if(parent.MacPlayer.PlayUrl.indexOf('.mpd')>-1){
        type='dash';
    }
    var webdata = {
        set:function(key,val){
            window.sessionStorage.setItem(key,val);
        },
        get:function(key){
            return window.sessionStorage.getItem(key);
        },
        del:function(key){
            window.sessionStorage.removeItem(key);
        },
        clear:function(key){
            window.sessionStorage.clear();
        }
    };
    var _peerId = '', _peerNum = 0, _totalP2PDownloaded = 0, _totalP2PUploaded = 0;
    var dp = new DPlayer({
        container: document.getElementById('playerCnt'),
        autoplay: true, //自动播放视频,不支持移动浏览器
        volume: 1.0, //声音
        preload: 'auto',//预加载的方式可以是'none''metadata''auto',默认值:'auto'
        hotkey: true, //绑定热键,包括左右键和空格,默认值:true
        screenshot: true, //截屏
        theme: '#28FF28',//主题颜色
        video: {
            url: parent.MacPlayer.PlayUrl,//播放地址
            type: 'customHls', //播放协议
            pic: 'https://yingyinjia.top/HB/loading.png', // 视频封面
            customType: {
                'customHls': function (video, player) {
                    const hls = new Hls({
                        debug: false,
                        // Other hlsjsConfig options provided by hls.js
                        p2pConfig: {
                            logLevel: false,
                            live: false,        // 如果是直播设为true
                            // Other p2pConfig options provided by CDNBye
                            getStats: function (totalP2PDownloaded, totalP2PUploaded, totalHTTPDownloaded) {
                                console.warn(`totalP2PDownloaded ${totalP2PDownloaded} totalHTTPDownloaded ${totalHTTPDownloaded}`);
                                _totalP2PDownloaded = totalP2PDownloaded;
                                _totalP2PUploaded = totalP2PUploaded;
                                updateStats();
                            },
                            getPeerId: function (peerId) {
                                _peerId = peerId;
                            },
                            getPeersInfo: function (peers) {
                                _peerNum = peers.length;
                                updateStats();
                            },
                        }
                    });
                    hls.loadSource(video.src);
                    hls.attachMedia(video);
                }
            }
        },
contextmenu: [ //弹幕设置
]
    });
    dp.seek(webdata.get('pay'+parent.MacPlayer.PlayUrl));
    setInterval(function(){
        webdata.set('pay'+parent.MacPlayer.PlayUrl,dp.video.currentTime);
    },1000);
   dp.on('stats', function (stats) {
        _totalP2PDownloaded = stats.totalP2PDownloaded;
        _totalP2PUploaded = stats.totalP2PUploaded;
        updateStats();
    });
    dp.on('peerId', function (peerId) {
        _peerId = peerId;
    });
    dp.on('peers', function (peers) {
        _peerNum = peers.length;
        updateStats();
    });
    dp.on('ended', function (){
        if(parent.MacPlayer.PlayLinkNext!=''){
            top.location.href = parent.MacPlayer.PlayLinkNext;
        }
    });
    function updateStats() {
        var text = 'P2P已开启 共享' + (_totalP2PUploaded/1024).toFixed(2) + 'MB' + ' 已加速' + (_totalP2PDownloaded/1024).toFixed(2)
            + 'MB' + ' 此片有 ' + _peerNum + ' 位影迷正在观看';
        //document.getElementById('stats').innerText = text
    }
</script>
</body>
</html>

 

5/5 - (1 vote)

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注