Skip to content

Instantly share code, notes, and snippets.

@justasrutkauskas
Created April 13, 2017 20:48
Show Gist options
  • Save justasrutkauskas/7135678970cd84b049ffd2ba2ce5a2b7 to your computer and use it in GitHub Desktop.
Save justasrutkauskas/7135678970cd84b049ffd2ba2ce5a2b7 to your computer and use it in GitHub Desktop.
<!--
Copyright 2015 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
This shows a very simple receiver to help you get code up and running. You can
think of this as your first step. It is not compatible with our UX guidelines.
It is useful for learning the basic concepts of the system.
-->
<!DOCTYPE html>
<html>
<head>
<!--
While this receiver doesn't have any text, it's important to know that
Chromecast defaults to a black background with black text. Changing that will
help your efforts.
We find that having everything fit in the HTML boxes tends to look nicer on TV
so, we also set overflow: hidden, which clips all flowing outside of boxes or
adding of scrollbars, which aren't useful on TV.
-->
<style type="text/css">
@import url(http://fonts.googleapis.com/css?family=Droid+Serif:400,700);
body {
font-family: "Droid Serif", serif;
color: #444;
line-height: 150%;
border: 0px;
margin: 0px;
width: 100%;
height: 100%;
overflow: hidden !important;
}
video {
width: 100%;
height: 100%;
margin: auto auto;
overflow: hidden !important;
}
</style>
<!--
Include the Receiver Library - Very important use our URL, don't attempt to
host this yourself.
-->
<script type="text/javascript"
src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js">
</script>
<title>CastHelloVideoPlayer</title>
</head>
<body>
<video id='video' />
<script type="text/javascript">
// Turn on debugging so that you can see what is going on. Please turn this off
// on your production receivers.
cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG);
console.log('Starting receiver application');
window.mediaElement = document.getElementById('video');
// Create the media manager. This will handle all media messages by default.
window.mediaManager = new cast.receiver.MediaManager(window.mediaElement);
// Start the receiver manager
console.log('Starting receiver manager');
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
castReceiverManager.onSenderDisconnected = function (event) {
console.log("Sender disconnected");
if (window.castReceiverManager.getSenders().length == 0 &&
event.reason == cast.receiver.system.DisconnectReason.REQUESTED_BY_SENDER) {
window.close();
}
};
// The default inactivity is normally 10 seconds, since we are encouraging you
// to debug this receiver, we are setting it to 10 minutes. As setting a break
// point might inadvertently trigger a timeout. The purpose of the timer is to
// speed the recognition of disconnection of a sender. As the TCP/IP standard
// mechanisms can be quite slow.
castReceiverManager.start({maxInactivity: 600});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment