mirror of https://github.com/IoTcat/player.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
6.1 KiB
162 lines
6.1 KiB
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<title>ACG.WATCH Player</title> |
|
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/dplayer@1.25.0/dist/DPlayer.min.css"> |
|
<script type="text/javascript">block_aplayer = true;</script> |
|
<script src="https://cdn.yimian.xyz/ushio-js/ushio-head.min.js"></script> |
|
</head> |
|
<body> |
|
|
|
<div id="dplayer"></div> |
|
<br/> |
|
<p> |
|
名称: <span id="video_name">未知</span> |
|
</p> |
|
<br/> |
|
<button onClick="next_video()">下一集</button> |
|
<button onClick="window.location.href='../'">返回首页</button> |
|
<br/> |
|
<br/> |
|
|
|
<script src="https://cdn.yimian.xyz/ushio-js/ushio-footer.min.js"></script> |
|
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script> |
|
<script src="https://cdn.jsdelivr.net/npm/flv.js@1.5.0/dist/flv.min.js"></script> |
|
<script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script> |
|
<script src="https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js"></script> |
|
<script src="https://cdn.jsdelivr.net/npm/dplayer@1.25.0/dist/DPlayer.min.js"></script> |
|
<script type="text/javascript"> |
|
var options = { |
|
container: document.getElementById('dplayer'), |
|
theme: '#'+('00000'+ (Math.random()*0x1000000<<0).toString(16)).substr(-6), |
|
logo: 'https://cdn.yimian.xyz/img/logo/logo_white.png', |
|
lang: 'zh-cn', |
|
autoplay: true, |
|
video: { |
|
pic: 'https://api.yimian.xyz/img/?size=1920x1080', |
|
quality: [], |
|
defaultQuality: 0, |
|
playFrom: 0 |
|
}, |
|
danmaku: { |
|
id: $.md5(page.params.url+'').substr(0, 16), |
|
api: 'https://danmaku.yimian.xyz/', |
|
maximum: 1000, |
|
addition: [], |
|
user: 'iotcat', |
|
bottom: '15%', |
|
unlimited: true, |
|
} |
|
}; |
|
/* if no GET video url */ |
|
if(Object.keys(page.params).length === 0 || !page.params.hasOwnProperty("url")){ |
|
if(!cookie.get('last_watch')){ |
|
page.params.url = "https://api.yimian.xyz/video/?path=404.mp4"; |
|
}else{ |
|
page.params.url = cookie.get('last_watch'); |
|
history.pushState({},page.title,"https://acg.watch/player?url="+cookie.get('last_watch')); |
|
} |
|
}else{ |
|
cookie.set('last_watch', page.params.url); |
|
} |
|
var dp = {}; |
|
var isWaiting = false; |
|
$.post("https://acg.watch/api/getQuality.php?url="+page.params.url, function(res){ |
|
|
|
options.video.quality = JSON.parse(res); |
|
dp = new DPlayer(options); |
|
/* recover history playing */ |
|
if(options.video.quality[0].url && options.video.quality[0].url != 'https://api.yimian.xyz/video?path=404.mp4'){ |
|
if(cookie.get($.md5(options.video.quality[0].url)) != null){ |
|
dp.seek(cookie.get($.md5(options.video.quality[0].url))); |
|
options.video.playFrom = cookie.get($.md5(options.video.quality[0].url)); |
|
dp.notice("已恢复到上次播放位置", 4000); |
|
} |
|
} |
|
/* record seek point */ |
|
setInterval(function(){ |
|
if(!dp.video.paused && dp.video.currentTime > 10){ |
|
cookie.set($.md5(options.video.quality[0].url), dp.video.currentTime); |
|
} |
|
}, 1000); |
|
/* print info */ |
|
getInfo(); |
|
/* next video */ |
|
dp.on('ended', next_video); |
|
/* if waiting change source */ |
|
dp.on('waiting', waitEvent); |
|
dp.on('playing', function(){ |
|
isWaiting = false; |
|
}); |
|
}); |
|
|
|
var next_video = function() { |
|
cookie.set($.md5(options.video.quality[0].url), "0"); |
|
$.post("https://acg.watch/api/getNext.php?url="+options.video.quality[0].url, function(res){ |
|
res = JSON.parse(res); |
|
dp.notice("正在跳转至下一集", 4000); |
|
setTimeout(function(){ |
|
cookie.set('last_watch', res.url); |
|
history.pushState({},page.title,"https://acg.watch/player?url="+res.url); |
|
page.params.url = res.url; |
|
$.post("https://acg.watch/api/getQuality.php?url="+res.url, function(res2){ |
|
console.log(JSON.parse(res2)); |
|
options.video.quality = JSON.parse(res2); |
|
options.video.defaultQuality = 0; |
|
options.video.playFrom = 0; |
|
dp.switchVideo( |
|
{ |
|
url: res.url, |
|
quality: JSON.parse(res2), |
|
defaultQuality: 0 |
|
}, |
|
{ |
|
id: $.md5(res.url+'').substr(0, 16), |
|
api: 'https://danmaku.yimian.xyz/', |
|
maximum: 1000, |
|
addition: [], |
|
user: 'iotcat', |
|
bottom: '15%', |
|
unlimited: true, |
|
} |
|
); |
|
/* print info */ |
|
getInfo(); |
|
|
|
//setTimeout(function(){dp.switchQuality(0);}, 1000); |
|
}); |
|
}, 2000); |
|
}); |
|
} |
|
var getInfo = function(){ |
|
$.post('https://acg.watch/api/getInfo.php?url='+options.video.quality[0].url, function(res){ |
|
res = JSON.parse(res); |
|
printInfo(res); |
|
}); |
|
} |
|
var printInfo = function(res){ |
|
$('#video_name').html(res.name); |
|
} |
|
var autoSwitchQuality = function(){ |
|
if(isWaiting && options.video.quality.length > 1){ |
|
waitEvent(15000); |
|
dp.notice("监测到卡顿,切换片源"); |
|
options.video.defaultQuality = (options.video.defaultQuality >= options.video.quality.length - 1) ? 0 : options.video.defaultQuality+1; |
|
console.log('Switch quality to ' + options.video.defaultQuality); |
|
dp.switchQuality(options.video.defaultQuality); |
|
} |
|
} |
|
var waitEvent = function(t = 6000){ |
|
isWaiting = true; |
|
setTimeout(function(){ |
|
if(dp.video.currentTime > options.video.playFrom + 10){ |
|
autoSwitchQuality(); |
|
}else{ |
|
setTimeout(autoSwitchQuality, 9000); |
|
} |
|
}, t); |
|
}; |
|
</script> |
|
</body> |
|
</html>
|
|
|