Skip to content

Commit 173a580

Browse files
authored
Merge pull request #15761 from Mugen87/dev23
Examples: Fix webgl_material_video for Chrome and Safari
2 parents 572ace7 + 7eab9ef commit 173a580

File tree

1 file changed

+54
-3
lines changed

1 file changed

+54
-3
lines changed

examples/webgl_materials_video.html

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,52 @@
2626
z-index:100;
2727
}
2828

29+
#overlay {
30+
position: absolute;
31+
z-index: 1;
32+
top: 0;
33+
left: 0;
34+
width: 100%;
35+
height:100%;
36+
display: flex;
37+
align-items: center;
38+
justify-content: center;
39+
opacity: 1;
40+
background-color: #000000;
41+
color: #ffffff;
42+
}
43+
44+
#overlay > div {
45+
text-align: center;
46+
}
47+
48+
#overlay > div > button {
49+
height: 20px;
50+
width: 100px;
51+
background: transparent;
52+
color: #ffffff;
53+
outline: 1px solid #ffffff;
54+
border: 0px;
55+
cursor: pointer;
56+
}
57+
58+
#overlay > div > p {
59+
color: #777777;
60+
font-size: 12px;
61+
}
62+
2963
</style>
3064
</head>
3165
<body>
3266

67+
<div id="overlay">
68+
<div>
69+
<button id="startButton">Click to Play</button>
70+
<p>Automatic video playback with audio requires a user interaction.</p>
71+
</div>
72+
</div>
73+
<div id="container"></div>
74+
3375
<div id="info">
3476
<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl video demo. playing <a href="http://durian.blender.org/" target="_blank" rel="noopener">sintel</a> trailer
3577
</div>
@@ -47,7 +89,7 @@
4789

4890
<script src="js/WebGL.js"></script>
4991

50-
<video id="video" autoplay loop crossOrigin="anonymous" webkit-playsinline style="display:none">
92+
<video id="video" loop crossOrigin="anonymous" webkit-playsinline style="display:none">
5193
<source src="textures/sintel.ogv" type='video/ogg; codecs="theora, vorbis"'>
5294
<source src="textures/sintel.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
5395
</video>
@@ -82,11 +124,19 @@
82124
xgrid = 20,
83125
ygrid = 10;
84126

85-
init();
86-
animate();
127+
var startButton = document.getElementById( 'startButton' );
128+
startButton.addEventListener( 'click', function () {
129+
130+
init();
131+
animate();
132+
133+
}, false );
87134

88135
function init() {
89136

137+
var overlay = document.getElementById( 'overlay' );
138+
overlay.remove();
139+
90140
container = document.createElement( 'div' );
91141
document.body.appendChild( container );
92142

@@ -105,6 +155,7 @@
105155
container.appendChild( renderer.domElement );
106156

107157
video = document.getElementById( 'video' );
158+
video.play();
108159

109160
texture = new THREE.VideoTexture( video );
110161

0 commit comments

Comments
 (0)