-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint-cast-sdk-version.html
47 lines (41 loc) · 1.46 KB
/
print-cast-sdk-version.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
<html>
<head>
<title>Print Cast SDK Version</title>
<link rel="stylesheet" type="text/css" href="common.css">
<script src="https://www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js"></script>
<script src="start-session.js"></script>
</head>
<body>
<div id="output"></div>
</body>
<script>
async function main() {
output.textContent = `Cast SDK version ${cast.framework.VERSION}`;
if (window.speechSynthesis) {
const onEnd = async () => {
await new Promise((resolve) => setTimeout(resolve, 2000));
// Repeat the version number only, and slowly.
const shortUtterance = new SpeechSynthesisUtterance(
`version ${cast.framework.VERSION}`);
shortUtterance.rate = 0.5;
shortUtterance.onend = onEnd;
speechSynthesis.speak(shortUtterance);
};
const fullUtterance = new SpeechSynthesisUtterance(output.textContent);
fullUtterance.onend = onEnd;
fullUtterance.onerror = () => {
// On Cast, it's fine to synthesize speech on page load.
// On Chrome, you need user interaction. To debug, allow clicking the
// document to start this process.
console.log('Failure! Click document to play sound.');
document.addEventListener('click', main, {once: true});
};
speechSynthesis.speak(fullUtterance);
console.log(`Speaking: ${output.textContent}`);
} else {
console.log('Speach API unavailable');
}
}
main();
</script>
</html>