苹果CMSV10播放器增加记忆+P2P播放+自动下一集+支持弹幕等功能

使用方法:

1、把代码复制;

2、新建一下文件比如dp.php;

3、把代码放到文件里面保存;

4、上传dp.php到你的苹果CMS网站;

5、在苹果CMS后台设置播放器解析接口为 :  http://你的域名/dp.php?url=

 

代码如下:


<html>
<head>
<title>dplayer增加记忆+P2P播放</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11" />
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer@latest/dist/DPlayer.min.css" /> 
<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:10px;font-size:10px;color:#fdfdfd;z-index:20719029;text-shadow:1px 1px 1px #000, 1px 1px 1px #000}
#dplayer{position:inherit}
</style>
</head>
<body style="background:#000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" oncontextmenu=window.event.returnValue=false>
<div id="dplayer"></div>
<div id="stats"></div>
<script src="https://cdn.jsdelivr.net/npm/cdnbye@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/dplayer@latest"></script>
<script>
var url = '<?php echo($_REQUEST['url']);?>';
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: true,
}, 
contextmenu: [
{
text: '极速影视',
link: 'http://qxkkk.cn',
},
],
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='<video src="'+url+'" controls="controls" preload="preload" poster="" width="100%" height="100%" autoplay="autoplay"></video>';
}
function updateStats() {
var text = '七星P2P正在为您加速' + (_totalP2PDownloaded/1024).toFixed(2)
+ 'MB 已分享' + (_totalP2PUploaded/1024).toFixed(2) + 'MB' + ' 连接节点' + _peerNum + '个';
document.getElementById('stats').innerText = text ;
}
</script>
<div style="display:none"><script type="text/javascript">var cnzz_s_tag = document.createElement("script");cnzz_s_tag.type = "text/javascript";cnzz_s_tag.async = true;cnzz_s_tag.charset = "utf-8";cnzz_s_tag.src = "//s9.cnzz.com/z_stat.php?id=1278589179&web_id=1278589179&async=1";var root_s = document.getElementsByTagName("script")[0];root_s.parentNode.insertBefore(cnzz_s_tag, root_s);</script></div>
</body>
</html>
点赞

发表评论