-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
208 lines (189 loc) · 6.01 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>FM4cast</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="js/apikey.js" charset="utf-8"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicon-16x16.png">
<link rel="manifest" href="/assets/site.webmanifest">
<link rel="mask-icon" href="/assets/safari-pinned-tab.svg" color="#ffe501">
<link rel="shortcut icon" href="/assets/favicon.ico">
<meta name="msapplication-TileColor" content="#ffe501">
<meta name="msapplication-config" content="/assets/browserconfig.xml">
<meta name="theme-color" content="#ffe501">
<meta property="og:image" content="https://fm4cast.deebas.com/assets/og-image.jpg">
<meta property="og:image:height" content="355">
<meta property="og:image:width" content="679">
<meta property="og:title" content="FM4cast">
<meta property="og:description" content="Play Radio FM4 on your Cast device">
<meta property="og:type" content="website">
<meta property="og:url" content="https://fm4cast.deebas.com">
<meta itemprop="name" content="FM4cast" />
<meta itemprop="description" content="Play Radio FM4 on your Cast device" />
<meta itemprop="image" content="https://fm4cast.deebas.com/assets/og-image.jpg" />
<style media="screen">
google-cast-launcher {
--disconnected-color: #c1c1c1;
--connected-color: #ffe501;
}
.cast-button {
max-width: 100pt;
margin: 0 auto 40pt;
}
body {
background-color: #242424;
color: #c1c1c1;
margin: 0;
font-family: Verdana;
}
.main {
}
.yellow {
position:relative;
background-color: #ffe501;
height: 100pt;
}
.black {
position:relative;
padding-top: 80pt;
}
.text {
font-size: 60pt;
font-weight: bold;
transform: scale(1.4,1);
letter-spacing: -7pt;
right: 0px;
margin-right: 35pt;
position: absolute;
}
.fm4.text {
color: #242424;
bottom: 0px;
}
.cast.text {
color: #ffe501;
top: 0px;
}
.cast-info {
width: 75%;
margin: -30pt auto 50pt;
text-align: justify;
font-size: 10pt;
}
.contribute {
position: fixed;
bottom: 0;
right: 0;
font-size: 8pt;
padding: 8pt;
text-align: right;
background-color: #242424;
}
.contribute a {
color: inherit;
}
.debugLog {
padding-bottom: 50pt;
}
.debugLog > div > * {
margin-left: 2pt;
}
.debugLog > div > div {
display: inline-block;
}
.debugLog > div > span {
font-weight: bold;
}
.debugLog {
font-size: 8pt;
}
</style>
</head>
<body>
<div class="main">
<div class="yellow"><div class="fm4 text">FM4</div></div>
<div class="black">
<div class="cast text">cast</div>
<div class="cast-button">
<google-cast-launcher></google-cast-launcher>
</div>
<div class="cast-info">
<p>FM4cast funktioniert im <b>Chrome</b> unter Window, Linux, MacOS, Android und iOS.</p>
<p>Du musst dich im selben Netz wie das Cast-fähige Gerät befinden.</p>
</div>
<div class="debugLog"></div>
<div class="contribute">
Anregungen, Fehlerberichte oder Weiterentwicklungen kannst du hier abliefern: <a target="_blank" href="https://github.com/sehaas/fm4cast">github.com/sehaas/fm4cast</a>
</div>
</div>
</div>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js');
}
window['fm4castDebug'] = !/debug/.test(window.location.search) ?
() => {} : (callback, message) => {
var logDiv = document.createElement('div');
logDiv.innerHTML = '<span>' + new Date().toISOString() + '</span>' +
'<div>' + callback + '</div>' +
'<div>' + message + '</div>';
document.getElementsByClassName('debugLog')[0].prepend(logDiv);
fetch('/debug/' + encodeURIComponent(callback) +
'/' + encodeURIComponent(message));
};
window['__onGCastApiAvailable'] = function(isAvailable) {
fm4castDebug('GCastApiAvailable', isAvailable);
if (isAvailable) {
initializeCastApi();
}
};
initializeCastApi = function() {
var context = cast.framework.CastContext.getInstance();
context.setOptions({
receiverApplicationId: fm4cast.castAppId,
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
resumeSavedSession: true
});
context.addEventListener(
cast.framework.CastContextEventType.CAST_STATE_CHANGED,
function(event) {
fm4castDebug(event.type, event.castState);
switch(event.castState) {
case 'NO_DEVICES_AVAILABLE':
document.getElementsByClassName('cast-info')[0].style.display = 'block';
break;
case 'NOT_CONNECTED':
document.getElementsByClassName('cast-info')[0].style.display = 'none';
break;
case 'CONNECTING':
break;
case 'CONNECTED':
break;
}
}
)
var player = new cast.framework.RemotePlayer();
var playerController = new cast.framework.RemotePlayerController(player);
playerController.addEventListener(
cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED, function(event) {
fm4castDebug(event.field, event.value);
if (player.isConnected) {
initializeFM4LiveStream();
}
});
};
initializeFM4LiveStream = function() {
var castSession = cast.framework.CastContext.getInstance().getCurrentSession();
var mediaInfo = new chrome.cast.media.MediaInfo('https://orf-live.ors-shoutcast.at/fm4-q1a','audio/mpeg');
var request = new chrome.cast.media.LoadRequest(mediaInfo);
castSession.loadMedia(request).then(
function() { fm4castDebug('session.loadMedia', 'success'); },
function(errorCode) { fm4castDebug('session.loadMedia', errorCode); });
}
</script>
<script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
</body>
</html>