mirror of
https://github.com/bdnugget/url-cast-receiver.git
synced 2026-11-07 09:17:30 +00:00
58 lines
1.9 KiB
HTML
58 lines
1.9 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>URL Cast Receiver</title>
|
|
|
|
<style type='text/css'>
|
|
html, body {width: 100%; height: 100%; padding: 0; margin: 0;}
|
|
body {overflow:hidden; background: #FFF;}
|
|
#iframe {width: 100%; height: 100%;}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<iframe src='' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' seamless='seamless' id='iframe'></iframe>
|
|
|
|
<script type='text/javascript' src='//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js'></script>
|
|
|
|
<script type='text/javascript'>
|
|
window.onload = function() {
|
|
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
|
|
|
|
castReceiverManager.onReady = function(event) {
|
|
window.castReceiverManager.setApplicationState('URL Cast ready...');
|
|
};
|
|
|
|
// messages on a custom namespace
|
|
var ns = 'urn:x-cast:com.url.cast';
|
|
window.messageBus = window.castReceiverManager.getCastMessageBus(ns);
|
|
|
|
window.messageBus.onMessage = function(e) {
|
|
var msg = JSON.parse(e.data);
|
|
|
|
window.messageBus.send(e.senderId, 'ok');
|
|
|
|
if (msg.type === 'iframe') updateFrame(msg.url);
|
|
if (msg.type === 'loc') updateLocation(msg.url);
|
|
};
|
|
|
|
// initialize CastReceiverManager
|
|
window.castReceiverManager.start({statusText: 'URL Cast starting...'});
|
|
};
|
|
|
|
// Update the iframe src
|
|
// warning: watch out for X-Frame-Options -> DENY
|
|
function updateFrame(url) {
|
|
window.castReceiverManager.setApplicationState('Now Playing: ' + url);
|
|
document.getElementById('iframe').src = url;
|
|
}
|
|
|
|
// Set the window location to the URL
|
|
// warning: this reciever dies essentially, because you navigated away
|
|
function updateLocation(url) {
|
|
window.castReceiverManager.setApplicationState('Now Playing: ' + url);
|
|
window.location.href = url;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |