苹果CMSV10整合dplayer播放器教程,使用方法:将文件上传到自己的网站(比如文件名叫dplayer.php,上传到要目录),在苹果cms后台播放器设置中开启解析,解析域名设置为/dplayer.php/?url=

播放器功能:支持格式:m3u8、mp4,播放记忆,P2P加速(去除在视频中P2P信息),自动播放下一集(仅电脑端),去掉弹幕(需要的自行去掉注释),手机增加引导点击播放图片

很多人都要去右键菜单,这次更新代码已经去掉了,另外修复了安卓手机原生浏览器播放与暂时的问题

代码: 

                        dplayer增加记忆 P2P播放                                                                                 
                                                                                                                             
                        var isWap = navigator.userAgent.match(/iPad|iPhone|iPod|Baidu/i) != null; //百度浏览器和苹果移动端不使用P2P功能
                        if(!isWap){
                                if(url.indexOf(".m3u8") > 0){         
                                        var _peerId = '', _peerNum = 0, _totalP2PDownloaded = 0, _totalP2PUploaded = 0;       
                                        var type = 'customHls';
                                }
                                else {
                                        var type = 'normal'; //MP4格式P2P兼容性不好,不调用P2P。
                                }
                                var dp = new DPlayer({
                                        container: document.getElementById('dplayer'),
                                        autoplay: true,
                                        hotkey: true,  // 移动端全屏时向右划动快进,向左划动快退。
                                        logo: '',
                                        video: {
                                                url:url,
                                                pic: '',  //图片地址。
                                                type: type,
                                                customType: {
                                                        'customHls': function (video, player) {
                                                                const hls = new Hls({
                                                                        debug: false,
                                                                        p2pConfig: {
                                                                                logLevel: true,
                                                                                live: false,        // 如果是直播设为true
                                                                        }
                                                                });
                                                                hls.loadSource(video.src);
                                                                hls.attachMedia(video);
                                                                hls.p2pEngine.on('stats', function (stats) {
                                                                        _totalP2PDownloaded = stats.totalP2PDownloaded;
                                                                        _totalP2PUploaded = stats.totalP2PUploaded;
                                                                        //updateStats();
                                                                }).on('peerId', function (peerId) {
                                                                        _peerId = peerId;
                                                                }).on('peers', function (peers) {
                                                                        _peerNum = peers.length;
                                                                        //updateStats();
                                                                });
                           
                                                        }
                                                }
                                        },                       
                                        /*danmaku: {
                                                id: 'E3368B56CDBB4IU',   //弹幕代码,可定义其他的ID,请修改;
                                                api: 'https://dplayer.moerats.com/',
                                                bottom: '25%',
                                                unlimited: false,
                                        }, */            
                                        contextmenu: [
                                        ],
                                        highlight: [
                                                {
                                                        text: '提示:点击下方状态栏可以发送字幕',
                                                        time: 360,
                                                },
                                                {
                                                        text: '警告:请不要相信视频中任何广告与字幕',
                                                        time: 1200,
                                                },
                                        ]
                                });
                                  
                                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();
                                        }
                                };
                                dp.seek(webdata.get('vod' url));
                                setInterval(function(){
                                        webdata.set('vod' url,dp.video.currentTime);
                                },1000);
                                dp.on('ended',function() {
                                        dp.notice("视频播放已结束");                   //可以替换成下一集调用等代码
                                        if(parent.MacPlayer.PlayLinkNext!=''){
                                        top.location.href = parent.MacPlayer.PlayLinkNext;}
                                });       
                        }
                        else{
                                document.getElementById('dplayer').innerHTML='';
                        }
                        function updateStats() {
                                var text = '七星P2P正在为您加速'   (_totalP2PDownloaded/1024).toFixed(2)
                                          'MB 已分享'   (_totalP2PUploaded/1024).toFixed(2)   'MB'   ' 连接节点'   _peerNum   '个';
                                document.getElementById('stats').innerText = text ;
                        }
                " _ue_custom_node_="true">