backported old youtube html5 player, partially works. Thanks @selfisekai!

merge-requests/5/head
Dominika 2020-08-09 05:41:05 +02:00
parent 90990f5928
commit a020493973
2 changed files with 47 additions and 3 deletions

10
webroot/yt/player.shs Executable file

File diff suppressed because one or more lines are too long

View File

@ -32,8 +32,12 @@ if [[ ${get_data[v]} ]]; then
<input name='q' type='text'>
<input type='submit' value='Search'>
</form>
<div><br><video id='player' src='$url' controls></video>
<h2>$title</h2>
<div><br>"
source webroot/yt/player.shs
#<video id='player' src='$url' controls></video>
echo "<h2>$title</h2>
<div>
<div>
Uploaded by <b><a href='channel.shs?id=$channel_id'>$uploader</a></b> on <b>$(date -d "$(echo $video | jq -r '.upload_date' | sed -E 's/..../&-/;s/....-../&-/')" "+%d %B %Y")</b>
@ -80,7 +84,7 @@ if [[ ${get_data[v]} ]]; then
echo "<script type='text/javascript'>
window.addEventListener('DOMContentLoaded', (event) => {
var video = document.getElementById('player');
video.play();
// video.play();
video.addEventListener('ended',function(){
window.location = 'watch.shs?v=$next&playlist=${get_data[playlist]}';
});
@ -91,6 +95,36 @@ if [[ ${get_data[v]} ]]; then
echo "<a href='watch.shs?v=${video_id[$i]}&playlist=${get_data[playlist]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
done
fi
echo "<script type='text/javascript'>
window.addEventListener('DOMContentLoaded', (event) => {
var video = document.getElementById('player');
function toggleVideo() {
if (video.paused) {
const classList = document.querySelector('.ytp-button-play').classList;
classList.remove('ytp-button-play');
classList.add('ytp-button-pause');
return video.play();
} else {
const classList = document.querySelector('.ytp-button-pause').classList;
classList.remove('ytp-button-pause');
classList.add('ytp-button-play');
return video.pause();
}
}
function updateTime() {
v = document.querySelector('.html5-main-video');
document.querySelector('.ytp-time-current').innerHTML = Math.round(v.currentTime/60)+':'+Math.round(v.currentTime%60).toString().padStart(2, '0');
document.querySelector('.ytp-time-duration').innerHTML = Math.round(v.duration/60)+':'+Math.round(v.duration%60).toString().padStart(2, '0');
document.querySelector('.ytp-play-progress').style.transform='scaleX('+v.currentTime/v.duration+')';
document.querySelector('.html5-scrubber-button').style.left=v.currentTime/v.duration*100+'%';
}
toggleVideo();
// document.querySelector('.ytp-button-play').addEventListener('click', () => toggleVideo());
document.querySelector('.ytp-button-pause').addEventListener('click', () => toggleVideo());
document.querySelector('.html5-main-video').addEventListener('timeupdate', () => updateTime());
});
</script>"
else
source templates/head.sh
echo "pls add ?v param i'm still WiP"