-
Notifications
You must be signed in to change notification settings - Fork 5
/
receiver.htm
35 lines (35 loc) · 1.19 KB
/
receiver.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<html>
<head>
<title>WebTorrent Google Cast</title>
<script type='text/javascript' src='https://www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js'></script>
<script type='text/javascript' src='https://cdn.jsdelivr.net/webtorrent/latest/webtorrent.min.js'></script>
<style type='text/css'>
video {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<video autoplay id='media'></video>
<script type='text/javascript'>
window.onload = function() {
// cast.receiver.logger.setLevelValue(cast.receiver.LoggerLevel.DEBUG);
window.mediaElement = document.getElementById('media');
window.mediaManager = new cast.receiver.MediaManager(window.mediaElement);
window.mediaManager.onLoad = function(event) {
if (event.data['media'] && event.data['media']['contentId']) {
var torrentId = event.data['media']['contentId'];
var client = new WebTorrent();
client.add(torrentId, function(torrent) {
var file = torrent.files[0];
file.renderTo('video');
});
}
}
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
window.castReceiverManager.start();
}
</script>
</body>
</html>