| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <title>Test of concurrent HTML5 audio</title> | 2 <title>Test of concurrent HTML5 audio</title> |
| 3 <body> | 3 <body> |
| 4 | 4 |
| 5 <p>Test that multiple audio elements can play concurrently.</p> | 5 <p>Test that multiple audio elements can play concurrently.</p> |
| 6 | 6 |
| 7 <script src=video-test.js></script> | 7 <script src=video-test.js></script> |
| 8 <script src=media-file.js></script> | 8 <script src=media-file.js></script> |
| 9 <script> | 9 <script> |
| 10 var maxPlayers = 2; // Number of concurrent audio elements to test. For
larger values a longer media file is needed. | 10 var maxPlayers = 2; // Number of concurrent audio elements to test. For
larger values a longer media file is needed. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 this.play(); | 25 this.play(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 function playingListener(event) | 28 function playingListener(event) |
| 29 { | 29 { |
| 30 consoleWrite("EVENT(" + audioElementCount + ", playing)"); | 30 consoleWrite("EVENT(" + audioElementCount + ", playing)"); |
| 31 } | 31 } |
| 32 | 32 |
| 33 function timeupdateListener(event) | 33 function timeupdateListener(event) |
| 34 { | 34 { |
| 35 ++timeupdateEventCount; | 35 // Make sure time is advancing. |
| 36 | 36 if (this.currentTime > 0) { |
| 37 // wait 2 timeupdate events so we are sure the media engine is | |
| 38 // playing the media. | |
| 39 if (timeupdateEventCount >= 2) { | |
| 40 // make sure time is advancing | |
| 41 testElement = this; | |
| 42 testExpected(audioElementCount + ", testElement.currentTime", 0,
'>'); | |
| 43 this.removeEventListener('timeupdate', timeupdateListener); | 37 this.removeEventListener('timeupdate', timeupdateListener); |
| 44 if (++audioElementCount >= maxPlayers) { | 38 if (++audioElementCount >= maxPlayers) { |
| 45 // All audio elements have been started playing. Make sure | 39 // All audio elements have been started playing. Make sure |
| 46 // all of them are still playing. | 40 // all of them are still playing. |
| 47 consoleWrite("Making sure all " + maxPlayers + " audio eleme
nts are in playing state:"); | 41 consoleWrite("Making sure all " + maxPlayers + " audio eleme
nts are in playing state:"); |
| 48 for (var i = 0; i < maxPlayers; i++) { | 42 for (var i = 0; i < maxPlayers; i++) { |
| 49 testElement = document.getElementsByTagName('audio')[i]; | 43 testElement = document.getElementsByTagName('audio')[i]; |
| 50 testExpected(i + ", testElement.paused", false); | 44 testExpected(i + ", testElement.paused", false); |
| 51 } | 45 } |
| 52 endTest(); | 46 endTest(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 70 | 64 |
| 71 consoleWrite("Starting a total of " + maxPlayers + " concurrent audio el
ements."); | 65 consoleWrite("Starting a total of " + maxPlayers + " concurrent audio el
ements."); |
| 72 for (var i = 0; i < maxPlayers; i++) | 66 for (var i = 0; i < maxPlayers; i++) |
| 73 document.write("<audio controls></audio>"); | 67 document.write("<audio controls></audio>"); |
| 74 | 68 |
| 75 testAudioElement(0); | 69 testAudioElement(0); |
| 76 </script> | 70 </script> |
| 77 | 71 |
| 78 </body> | 72 </body> |
| 79 </html> | 73 </html> |
| OLD | NEW |