Friendiqa/source-linux/js/yplayer.html

48 lines
1.6 KiB
HTML
Raw Normal View History

2019-01-09 22:03:16 +01:00
<html>
<head>
<title>-1</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
</head>
<body bgcolor="black" marginwidth="0" marginheight="0">
<div id="player"></div>
<script>
function getVideoId() {
return window.location.href.slice(window.location.href.indexOf('?') + 1);
}
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
2019-12-10 21:12:32 +01:00
console.log("Videoid: "+getVideoId());
2019-01-09 22:03:16 +01:00
player = new YT.Player('player', {
2019-12-10 21:12:32 +01:00
playerVars: { 'html5': 1, 'iv_load_policy': 3, 'autoplay': 1 },
2019-01-09 22:03:16 +01:00
frameborder: '0',
height: '100%',
width: '100%',
videoId: getVideoId(),
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
document.title = 0;
2019-12-10 21:12:32 +01:00
event.target.playVideo();
2019-01-09 22:03:16 +01:00
}
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING) {
document.title = 1;
} else if (event.data == YT.PlayerState.ENDED || event.data == YT.PlayerState.PAUSED) {
document.title = 2;
}
}
</script>
</body>
2019-12-10 21:12:32 +01:00
</html>