Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>Media Capture from DOM Elements (video/audio) Browser Test</title> | |
| 5 </head> | |
| 6 <body> | |
| 7 <div> Capture and playback from video/audio elements.</div> | |
| 8 <video id="video"></video> | |
| 9 <audio id="audio"></audio> | |
| 10 </body> | |
| 11 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | |
| 12 <script> | |
| 13 | |
| 14 'use strict'; | |
| 15 | |
| 16 const NUMBER_OF_RECORDED_EVENTS = 100; | |
| 17 | |
| 18 function testCaptureFromMediaElement(filename, | |
| 19 has_video, | |
| 20 has_audio, | |
| 21 use_audio_tag) { | |
| 22 const element = use_audio_tag ? document.getElementById('audio') | |
| 23 : document.getElementById('video'); | |
| 24 assertTrue(element, 'Error resolving tag'); | |
| 25 | |
| 26 element.src = filename; | |
| 27 element.onerror = function(e) { | |
| 28 failTest("error playing back [" + filename + "] " + e); | |
| 29 } | |
| 30 | |
| 31 var recorded_events = 0; | |
| 32 element.onloadedmetadata = function() { | |
| 33 const stream = element.captureStream(); | |
| 34 assertTrue(stream, 'Error creating MediaStream'); | |
| 35 assertEquals(has_video, stream.getVideoTracks().length); | |
| 36 assertEquals(has_audio, stream.getAudioTracks().length); | |
| 37 | |
| 38 const recorder = new MediaRecorder(stream); | |
| 39 assertTrue(recorder, 'Error creating recorder out of the MediaStream'); | |
| 40 | |
| 41 recorder.ondataavailable = function(event) { | |
| 42 if (recorded_events++ > NUMBER_OF_RECORDED_EVENTS) | |
|
tommi (sloooow) - chröme
2016/06/29 07:52:37
nit: as is, due to using postfix, the condition is
mcasas
2016/06/29 18:22:24
Done.
Also renamed to NUMBER_OF_EVENTS_TO_RECORD
| |
| 43 reportTestSuccess(); | |
| 44 }; | |
| 45 | |
| 46 recorder.start(); | |
| 47 element.play(); | |
| 48 }; | |
| 49 } | |
| 50 | |
| 51 </script> | |
| 52 </body> | |
| 53 </html> | |
| OLD | NEW |