OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML"> |
| 2 <html> |
| 3 <head> |
| 4 <script src=media-file.js></script> |
| 5 <script src=video-test.js></script> |
| 6 |
| 7 <script type="text/javascript"> |
| 8 |
| 9 function playingFromFileOnce() |
| 10 { |
| 11 consoleWrite("EVENT(playingFromFile)<br>"); |
| 12 createAndPlayMediaStream(); |
| 13 } |
| 14 |
| 15 function playingSrcObject() |
| 16 { |
| 17 consoleWrite("EVENT(playingVideo)<br>"); |
| 18 video.setAttribute('onplaying', "playingFromFileTwice()"); |
| 19 consoleWrite("MediaStream is playing. Set srcObject = null."); |
| 20 video.srcObject=null; |
| 21 } |
| 22 |
| 23 function playingFromFileTwice() |
| 24 { |
| 25 consoleWrite("EVENT(playingFromFile)<br>"); |
| 26 endTest(); |
| 27 } |
| 28 |
| 29 function startPlayFile() |
| 30 { |
| 31 findMediaElement(); |
| 32 waitForEvent("loadstart"); |
| 33 waitForEvent("waiting"); |
| 34 waitForEvent("ratechange"); |
| 35 waitForEvent("durationchange"); |
| 36 waitForEvent("pause"); |
| 37 waitForEvent("play"); |
| 38 waitForEvent("canplaythrough"); |
| 39 waitForEvent('loadeddata'); |
| 40 |
| 41 consoleWrite("Set src to local file."); |
| 42 video.setAttribute('onplaying', "playingFromFileOnce()"); |
| 43 |
| 44 var mediaFile; |
| 45 for (var i = 0; i < videoCodecs.length; ++i) { |
| 46 if (video.canPlayType(videoCodecs[i][0])) { |
| 47 mediaFile = "content/test." + videoCodecs[i][1]; |
| 48 break; |
| 49 } |
| 50 } |
| 51 video.src = mediaFile; |
| 52 } |
| 53 |
| 54 function gotStream(stream) |
| 55 { |
| 56 consoleWrite("Got a MediaStream. Start playing it."); |
| 57 video.setAttribute('onplaying', "playingSrcObject()"); |
| 58 video.srcObject = stream; |
| 59 } |
| 60 |
| 61 function gotStreamFailed(error) |
| 62 { |
| 63 consoleWrite("Failed to get access to local media. Error code was " + error.
code); |
| 64 } |
| 65 |
| 66 function createAndPlayMediaStream() |
| 67 { |
| 68 try { |
| 69 consoleWrite("Request access to local media."); |
| 70 navigator.webkitGetUserMedia({video:true}, gotStream, gotStreamFailed); |
| 71 } catch (e) { |
| 72 consoleWrite("getUserMedia error " + "(" + e.name + " / " + e.message +
")"); |
| 73 } |
| 74 } |
| 75 |
| 76 </script> |
| 77 </head> |
| 78 |
| 79 <body onload="startPlayFile()"> |
| 80 <p>Test that setting the HTMLMediaElement.srcObject overrides setting the src at
tribute and if the srcObect is set to null, media is reloaded from the src attri
bute.</p> |
| 81 <video width="320" height="240" autoplay="autoplay"></video> |
| 82 </body> |
| 83 </html> |
| 84 |
OLD | NEW |