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.
329 lines
11 KiB
329 lines
11 KiB
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta charset="UTF-8"> |
|
<title>ACG.WATCH Player</title> |
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/awsm.css@3.0.4/dist/awsm_theme_pearl-lusta.min.css"> |
|
<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> |
|
<header> |
|
<h1>ACG.WATCH</h1> |
|
<p>Watch ACG video <abbr title="At ACG.WATCH">ONLINE</abbr></p> |
|
<nav> |
|
<ul> |
|
<li><a href="../">Homepage</a></li> |
|
<li><a href="../">Playlist</a></li> |
|
<li><a href="https://iotcat.me/">About Me</a></li> |
|
</ul> |
|
</nav> |
|
</header> |
|
<main> |
|
<article> |
|
<section> |
|
<div id="dplayer"></div> |
|
<aside> |
|
<p> |
|
<strong>D.L.</strong> |
|
<a href="javascript:window.open(page.params.url);">You can download this video from here..</a> |
|
</p> |
|
</aside> |
|
</section> |
|
<section> |
|
<p>Name: <span id="video_name">Unkonwn..</span></p> |
|
</section> |
|
<section> |
|
<button onClick="next_video()">Next</button> |
|
<button onClick="window.location.href='../'">Homepage</button> |
|
</section> |
|
<section> |
|
<details> |
|
<summary>Show Video Params</summary> |
|
<p>Instant video params ^_^</p> |
|
<table> |
|
<thead> |
|
<tr> |
|
<th>Params</th> |
|
<th>Value</th> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<tr> |
|
<td>Video_Vid</td> |
|
<td id="video_vid"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_Class</td> |
|
<td id="video_class"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_Series</td> |
|
<td id="video_series"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_No</td> |
|
<td id="video_no"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_Name</td> |
|
<td id="video_name2"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_Link</td> |
|
<td id="video_link"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_description</td> |
|
<td id="video_description"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_DanmakuId</td> |
|
<td id="video_danmaku"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_QualityOptions</td> |
|
<td id="video_quality"></td> |
|
</tr> |
|
<tr> |
|
<td>Video_PlayFrom</td> |
|
<td id="video_playFrom"></td> |
|
</tr> |
|
<tr> |
|
<td>Player_Width</td> |
|
<td id="player_width"></td> |
|
</tr> |
|
<tr> |
|
<td>Player_Height</td> |
|
<td id="player_height"></td> |
|
</tr> |
|
<tr> |
|
<td>Player_CurrentTime</td> |
|
<td id="player_currentTime"></td> |
|
</tr> |
|
<tr> |
|
<td>Player_Duration</td> |
|
<td id="player_duration"></td> |
|
</tr> |
|
<tr> |
|
<td>Player_Volume</td> |
|
<td id="player_volume"></td> |
|
</tr> |
|
<tr> |
|
<td>Player_Paused</td> |
|
<td id="player_paused"></td> |
|
</tr> |
|
<tr> |
|
<td>Danmaku_Num</td> |
|
<td id="danmaku_danIndex"></td> |
|
</tr> |
|
<tr> |
|
<td>Danmaku_Opacity</td> |
|
<td id="danmaku_opacity"></td> |
|
</tr> |
|
<tr> |
|
<td>Danmaku_NumBottom</td> |
|
<td id="danmaku_numBottom"></td> |
|
</tr> |
|
<tr> |
|
<td>Danmaku_NumRight</td> |
|
<td id="danmaku_numRight"></td> |
|
</tr> |
|
<tr> |
|
<td>Danmaku_NumTop</td> |
|
<td id="danmaku_numTop"></td> |
|
</tr> |
|
</tbody> |
|
</table> |
|
</details> |
|
</section> |
|
</article> |
|
</main> |
|
<footer> |
|
<p style="text-align: center;"> Powered By Ushio | Made with love by <a href="https://iotcat.me">iotcat</a> </p> |
|
<br> |
|
</footer> |
|
|
|
<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, 8), |
|
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; |
|
$.get("https://acg.watch/api/getVideoByUrl?url="+page.params.url, function(res){ |
|
//res = JSON.parse(res); |
|
options.video.quality = [ |
|
{ |
|
name: '推荐', |
|
url: res.url |
|
} |
|
]; |
|
options.danmaku.id = res.danmakuID; |
|
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(res); |
|
/* 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"); |
|
$.get("https://acg.watch/api/getNextByUrl?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; |
|
|
|
//res2 = JSON.parse(res2); |
|
options.video.quality = [ |
|
{ |
|
name: "推荐", |
|
url: res.url |
|
} |
|
]; |
|
options.danmaku.id = res.danmakuID; |
|
options.video.defaultQuality = 0; |
|
options.video.playFrom = 0; |
|
dp.switchVideo( |
|
{ |
|
url: res.url, |
|
quality: [ |
|
{ |
|
name: "推荐", |
|
url: res.url |
|
} |
|
], |
|
defaultQuality: 0 |
|
}, |
|
{ |
|
id: res.danmakuID, |
|
api: 'https://danmaku.yimian.xyz/', |
|
maximum: 1000, |
|
addition: [], |
|
user: 'iotcat', |
|
bottom: '15%', |
|
unlimited: true, |
|
} |
|
); |
|
/* print info */ |
|
getInfo(res); |
|
|
|
//setTimeout(function(){dp.switchQuality(0);}, 1000); |
|
|
|
}, 2000); |
|
}); |
|
} |
|
var getInfo = function(res){ |
|
printInfo(res); |
|
} |
|
var printInfo = function(res){ |
|
$('#video_name').html(res.name); |
|
$('#video_name2').html(res.name); |
|
$('#video_class').html(res.class); |
|
$('#video_series').html(res.seriesID); |
|
$('#video_no').html(res.no); |
|
$('#video_vid').html(res.vid); |
|
$('#video_link').html(res.url); |
|
$('#video_description').html(res.description); |
|
$('#video_quality').html(options.video.quality.length); |
|
$('#video_playFrom').html(options.video.playFrom); |
|
|
|
} |
|
var autoSwitchQuality = function(){ |
|
if(isWaiting && options.video.quality.length > 1){ |
|
waitEvent(15000); |
|
if(options.video.defaultQuality >= options.video.quality.length - 1){ |
|
return; |
|
} |
|
dp.notice("监测到卡顿,切换片源"); |
|
options.video.defaultQuality = (options.video.defaultQuality >= options.video.quality.length - 1) ? options.video.defaultQuality : 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); |
|
}; |
|
/* print player and danmaku info */ |
|
setInterval(function(){ |
|
$('#danmaku_numRight').html(Object.keys(dp.danmaku.danTunnel.right).length); |
|
$('#danmaku_numBottom').html(Object.keys(dp.danmaku.danTunnel.bottom).length); |
|
$('#danmaku_numTop').html(Object.keys(dp.danmaku.danTunnel.top).length); |
|
$('#danmaku_opacity').html(dp.danmaku._opacity); |
|
$('#danmaku_danIndex').html(dp.danmaku.danIndex); |
|
$('#video_danmaku').html(options.danmaku.id); |
|
$('#player_width').html(dp.video.videoWidth); |
|
$('#player_height').html(dp.video.videoHeight); |
|
$('#player_volume').html(dp.video.volume); |
|
$('#player_paused').html((dp.video.paused)?"true":"false"); |
|
$('#player_currentTime').html(dp.video.currentTime); |
|
$('#player_duration').html(dp.video.duration); |
|
}, 1000); |
|
</script> |
|
</body> |
|
</html>
|
|
|