mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Starting add of custom receiver app
This commit is contained in:
@@ -13,6 +13,9 @@ RewriteCond %{HTTP_HOST} ^remote.zoff.no
|
||||
RewriteCond %{REQUEST_URI} !/static
|
||||
RewriteRule ^(.*)$ php/controller.php [L,NC,QSA]
|
||||
|
||||
RewriteCond %{HTTP_HOST} ^cast.zoff.no
|
||||
RewriteRule ^(.*)$ receiver/ [L,NC,QSA]
|
||||
|
||||
RewriteCond %{HTTP_HOST} ^bot.zoff.no
|
||||
RewriteCond %{REQUEST_URI} !/static
|
||||
RewriteRule ^(.*)$ php/bot.php [L,NC,QSA]
|
||||
|
||||
14
receiver/index.html
Normal file
14
receiver/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js">
|
||||
</script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
||||
<script src="receiver.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="player"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
75
receiver/receiver.js
Normal file
75
receiver/receiver.js
Normal file
@@ -0,0 +1,75 @@
|
||||
var receiver = new cast.receiver.Receiver("E6856E24", ["no.zoff.customcast"],"",5);
|
||||
var ytChannelHandler = new cast.receiver.ChannelHandler(cfg.msgNamespace);
|
||||
var nextVideo;
|
||||
ytChannelHandler.addChannelFactory(receiver.createChannelFactory(cfg.msgNamespace));
|
||||
ytChannelHandler.addEventListener(
|
||||
cast.receiver.Channel.EventType.MESSAGE,
|
||||
onMessage.bind(this)
|
||||
);
|
||||
|
||||
receiver.start();
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
var tag = document.createElement('script');
|
||||
tag.src = "https://www.youtube.com/iframe_api";
|
||||
var firstScriptTag = document.getElementsByTagName('script')[0];
|
||||
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
||||
});
|
||||
|
||||
ytMessages={
|
||||
"getNextVideo": function(event) {
|
||||
nextVideo=event.message.videoId;
|
||||
},
|
||||
"loadVideo": function(event) {
|
||||
player.loadVideoById(event.message.videoId);
|
||||
},
|
||||
"stopCasting": function() {
|
||||
endcast();
|
||||
},
|
||||
"playVideo": function() {
|
||||
player.playVideo();
|
||||
},
|
||||
"pauseVideo": function() {
|
||||
player.pauseVideo();
|
||||
},
|
||||
"stopVideo": function() {
|
||||
player.stopVideo();
|
||||
},
|
||||
"seekTo": function(event) {
|
||||
player.seekTo(event.message.seekTo)
|
||||
},
|
||||
"getStatus": function() {
|
||||
channel.send({'event':'statusCheck','message':player.getPlayerState()});
|
||||
}
|
||||
};
|
||||
|
||||
function onYouTubeIframeAPIReady() {
|
||||
player = new YT.Player('player', {
|
||||
height: 562,
|
||||
width: 1000,
|
||||
playerVars: { 'autoplay': 0, 'controls': 0 },
|
||||
events: {
|
||||
'onReady': onPlayerReady,
|
||||
'onStateChange': onPlayerStateChange
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onPlayerReady() {
|
||||
channel.send({'event':'iframeApiReady','message':'ready'});
|
||||
}
|
||||
|
||||
function onPlayerStateChange(event) {
|
||||
channel.send({'event':'stateChange','message':event.data});
|
||||
/*if (event.data==YT.PlayerState.ENDED) {
|
||||
endcast();
|
||||
}*/
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
ytMessages[event.message.type](event);
|
||||
}
|
||||
|
||||
function endcast() {
|
||||
setTimeout(window.close, 2000);
|
||||
}
|
||||
Reference in New Issue
Block a user