| <!DOCTYPE html> |
| <body></body> |
| <script> |
| window.internals.settings.setAutoplayPolicy('user-gesture-required-for-cross-origin'); |
| window.internals.runtimeFlags.autoplayMutedVideosEnabled = true; |
| |
| { |
| var video = document.createElement('video'); |
| video.id = 'video'; |
| video.src = 'test.ogv'; |
| video.autoplay = true; |
| video.loop = true; |
| document.body.appendChild(video); |
| } |
| |
| { |
| var video = document.createElement('video'); |
| video.id = 'video-muted'; |
| video.src = 'test.ogv'; |
| video.muted = true; |
| video.autoplay = true; |
| video.loop = true; |
| document.body.appendChild(video); |
| } |
| |
| var video = document.querySelector("#video"); |
| var videoMuted = document.querySelector("#video-muted"); |
| |
| video.addEventListener('canplay', _ => { |
| console.log('video canplay'); |
| window.parent.postMessage({ |
| msg: 'canplay', |
| videoId: video.id, |
| isPaused: video.paused, |
| readyState: video.readyState |
| }, "*"); |
| }); |
| |
| videoMuted.addEventListener('play', _ => { |
| console.log('videoMuted play'); |
| console.log(videoMuted.id); |
| window.parent.postMessage({ |
| msg: 'play', |
| videoId: videoMuted.id, |
| }, "*"); |
| }); |
| |
| </script> |