-
Notifications
You must be signed in to change notification settings - Fork 0
/
video-test-sound-off-touch.html
59 lines (42 loc) · 1.33 KB
/
video-test-sound-off-touch.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
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
</head>
<body>
</body>
<script>
var log = function(msg) {
var div = document.createElement("div");
div.innerHTML = msg;
document.body.appendChild(div);
}
log("test #2 : start Android autoplay with sound off with touch");
log("<br><br>");
log("<font color='red'>please touch any spot on this page</font> to start a test");
var video = document.createElement("video");
video.src = "http://acdn.adnxs.com/video/demos/content/videos/baby.mp4";
video.width = 200;
video.height = 100;
video.muted = true;
document.body.appendChild(video);
video.style.visibility = "hidden";
var playPromise;
var isDone = false;
document.body.addEventListener("touchend",function() {
if (isDone) {
return;
}
video.style.visibility = "visible";
isDone = true;
playPromise = video.play();
if (playPromise !== undefined) {
playPromise.then(function () {
log("result #2 : succeeded");
}
).catch(function (error) {
log("result #2 : failed due to " + error);
});
}
});
</script>
</html>