Skip to content

Commit cf683c7

Browse files
greggmanphemavax
authored andcommitted
fix for iOS
1 parent ed61193 commit cf683c7

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

video/video.html

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@
8989
<body>
9090
<canvas id="c"></canvas>
9191
<div id="b"><a href="http://twgljs.org">twgl.js</a> - video texture</div>
92-
<video id="vid" style="display: none;">
93-
<source src="../color-adjust/sample-video.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
94-
<source src="../color-adjust/sample-video.theora.ogv" type='video/ogg; codecs="theora, vorbis"' />
95-
<source src="../color-adjust/sample-video.webmvp8.webm" type='video/webm; codecs="vp8, vorbis"' />
96-
</video>
9792
<div id="start" class="fulldialog">
9893
<div>
9994
<img src="start.svg" />
@@ -170,7 +165,6 @@
170165
<script src="../js/twgl-full.min.js"></script>
171166
<script>
172167
"use strict";
173-
var isiOS = window.navigator.userAgent.match(/iPhone|iPad|iPod/i);
174168
twgl.setDefaults({attribPrefix: "a_"});
175169
var m4 = twgl.m4;
176170
var gl = twgl.getWebGLContext(document.getElementById("c"));
@@ -244,7 +238,9 @@
244238
var audio;
245239
var copyVideo;
246240
var setVideo;
247-
var video = document.getElementById("vid");
241+
var video = document.createElement("video");
242+
video.playsInline = true;
243+
video.src = "../color-adjust/sample-video.mp4";
248244
video.addEventListener("playing", function() {
249245
copyVideo = true;
250246
}, true);
@@ -271,26 +267,7 @@
271267
}
272268
once = true;
273269
start.style.display = "none";
274-
if (isiOS) {
275-
// iOS9 doesn't let us play video without going fullscreen :(
276-
// so a workaround, which I'm sure Apple will *fix* as in "make it not work"
277-
// is to create an audio tag using the same video
278-
// play the audio. DON'T PLAY THE VIDEO. Set the video's currentTime to match
279-
// the audio. I can't believe this works
280-
audio = document.createElement("audio");
281-
audio.src = "../color-adjust/sample-video.mp4";
282-
audio.addEventListener("ended", function() {
283-
audio.currentTime = 0;
284-
audio.play();
285-
});
286-
audio.play();
287-
video.addEventListener("canplaythrough", function() {
288-
setVideo = true;
289-
}, true);
290-
video.load();
291-
} else {
292-
video.play();
293-
}
270+
video.play();
294271
}
295272
}
296273

0 commit comments

Comments
 (0)