-
Notifications
You must be signed in to change notification settings - Fork 0
/
receiver.html
63 lines (57 loc) · 2.52 KB
/
receiver.html
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<title>HyperCast Receiver Demo</title>
<meta charset="UTF-8">
<!-- Cast API must be included before anything else, and it can't be bundled -->
<script src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js"></script>
<script type="module">
import { h, text, app } from "https://unpkg.com/hyperapp";
import { ReceiverSub } from "./src/receiver.js";
app({
init: { video_url: null },
view: (state) => h("main", {}, [
state.video_url ?
h("h1", {}, text("Video:" + state.video_url)) : h("h1", {}, text("No video")),
]),
subscriptions: (state) => [
ReceiverSub({
loadMessageInterceptor: function (loadRequestData) {
// Our demo app sends a full URL in loadRequestData.media.contentId,
// but some people might just send the ID and we need to set
// media.contentUrl for ourselves.
console.log("Got a LOAD request:", loadRequestData);
/*
loadRequestData.media.contentId = item.stream.dash;
loadRequestData.media.contentType = 'application/dash+xml';
loadRequestData.media.metadata = metadata;
*/
//loadRequestData.media.contentUrl = loadRequestData.media.contentId;
//loadRequestData.media.contentId = null;
/*
let metadata = new cast.framework.messages.GenericMediaMetadata();
metadata.title = "My Title";
metadata.subtitle = "My Description";
loadRequestData.media.metadata = metadata;
loadRequestData.media.contentType = 'video/mp4';
*/
return loadRequestData;
},
onMessageLoad: function (state, data) {
return { ...state, video_url: data.media.contentUrl };
},
})
],
node: document.getElementById("app"),
})
</script>
</head>
<body>
<!--
for some reason the casting API doesn't like it when this element is
dynamically generated by hyperapp :(
-->
<cast-media-player></cast-media-player>
<main id="app"></main>
</body>
</html>