remote-video-control-pausing-manual.html (2274B)
1 <!DOCTYPE html> 2 <html> 3 <link rel="stylesheet" href="styles.css" /> 4 <title>Test that pause() on the local video is reflected on the remote device</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/common/media.js"></script> 8 <script> 9 setup({ explicit_timeout: true }); 10 </script> 11 <body> 12 <div id="pick-device"> 13 <p> 14 Click the button below to prompt for a remote playback device and select 15 one! 16 </p> 17 <p> 18 <button id="prompt-button">Pick device</button> 19 </p> 20 </div> 21 <video src="/media/green-at-15.mp4" id="video"></video> 22 <div id="evaluate" style="display: none"> 23 <p> 24 Did the playback on the remote device pause and show the following 25 timestamp? (can vary by some frames) 26 </p> 27 <p id="timestamp" style="font-weight: bold"></p> 28 <p> 29 <button id="yes">Yes</button> 30 </p> 31 <p> 32 <button id="no">No</button> 33 </p> 34 </div> 35 </body> 36 <script> 37 let v = document.getElementById("video"); 38 39 async_test(t => { 40 let button = document.getElementById("prompt-button"); 41 button.onclick = t.step_func(() => { 42 promise_test(() => { 43 return v.remote.prompt().then(() => { 44 v.play(); 45 }); 46 }, "Prompt resolves"); 47 }); 48 49 let timestampLabel = document.getElementById("timestamp"); 50 v.ontimeupdate = () => { 51 let seconds = Math.floor(v.currentTime) + ""; 52 let frames = Math.ceil((v.currentTime - seconds) * 30) + ""; 53 timestampLabel.innerText = 54 seconds.padStart(2, "0") + ":" + frames.padStart(2, "0"); 55 if (v.currentTime >= 2) { 56 v.pause(); 57 document.getElementById("evaluate").style.display = "block"; 58 } 59 }; 60 61 let evaluate = success => 62 assert_true(success, "Video paused and has correct play position."); 63 64 document.getElementById("yes").onclick = t.step_func_done(() => 65 evaluate(true) 66 ); 67 document.getElementById("no").onclick = t.step_func_done(() => 68 evaluate(false) 69 ); 70 }, "Test that pause() on the local video is reflected on the remote device."); 71 </script> 72 </html>