| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>Test media source config changes.</title> | 3 <title>Test media source config changes.</title> |
| 4 </head> | 4 </head> |
| 5 <body onload="runTest();"> | 5 <body onload="runTest();"> |
| 6 <video controls></video> | 6 <video controls></video> |
| 7 <script src="media_utils.js" type="text/javascript"></script> | 7 <script src="media_utils.js" type="text/javascript"></script> |
| 8 <script src="media_source_utils.js" type="text/javascript"></script> | 8 <script src="media_source_utils.js" type="text/javascript"></script> |
| 9 <script src="encrypted_media_utils.js" type="text/javascript"></script> | 9 <script src="encrypted_media_utils.js" type="text/javascript"></script> |
| 10 <script type="text/javascript"> | 10 <script type="text/javascript"> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 var DELTA = 0.1; | 33 var DELTA = 0.1; |
| 34 // Append MEDIA_2 source at APPEND_TIME, so expected total duration is: | 34 // Append MEDIA_2 source at APPEND_TIME, so expected total duration is: |
| 35 var TOTAL_DURATION = APPEND_TIME + MEDIA_2_LENGTH; | 35 var TOTAL_DURATION = APPEND_TIME + MEDIA_2_LENGTH; |
| 36 | 36 |
| 37 function appendNextSource(mediaSource) { | 37 function appendNextSource(mediaSource) { |
| 38 console.log('Appending next media source at ' + APPEND_TIME + 'sec.'); | 38 console.log('Appending next media source at ' + APPEND_TIME + 'sec.'); |
| 39 var xhr = new XMLHttpRequest(); | 39 var xhr = new XMLHttpRequest(); |
| 40 xhr.open("GET", MEDIA_2); | 40 xhr.open("GET", MEDIA_2); |
| 41 xhr.responseType = 'arraybuffer'; | 41 xhr.responseType = 'arraybuffer'; |
| 42 xhr.addEventListener('load', function(e) { | 42 xhr.addEventListener('load', function(e) { |
| 43 var onUpdateEnd = function(e) { |
| 44 console.log('Second buffer append ended.'); |
| 45 srcBuffer.removeEventListener('updateend', onUpdateEnd); |
| 46 mediaSource.endOfStream(); |
| 47 if (!mediaSource.duration || |
| 48 Math.abs(mediaSource.duration - TOTAL_DURATION) > DELTA) { |
| 49 failTest('Unexpected mediaSource.duration = ' + |
| 50 mediaSource.duration + ', expected duration = ' + |
| 51 TOTAL_DURATION); |
| 52 return; |
| 53 } |
| 54 video.play(); |
| 55 }; |
| 56 console.log('Appending next media source at ' + APPEND_TIME + 'sec.'); |
| 43 var srcBuffer = mediaSource.sourceBuffers[0]; | 57 var srcBuffer = mediaSource.sourceBuffers[0]; |
| 58 srcBuffer.addEventListener('updateend', onUpdateEnd); |
| 44 srcBuffer.timestampOffset = APPEND_TIME; | 59 srcBuffer.timestampOffset = APPEND_TIME; |
| 45 srcBuffer.append(new Uint8Array(e.target.response)); | 60 srcBuffer.appendBuffer(new Uint8Array(e.target.response)); |
| 46 mediaSource.endOfStream(); | |
| 47 if (!mediaSource.duration || | |
| 48 Math.abs(mediaSource.duration - TOTAL_DURATION) > DELTA) { | |
| 49 failTest('Unexpected mediaSource.duration = ' + | |
| 50 mediaSource.duration + ', expected duration = ' + | |
| 51 TOTAL_DURATION); | |
| 52 return; | |
| 53 } | |
| 54 video.play(); | |
| 55 }); | 61 }); |
| 56 xhr.send(); | 62 xhr.send(); |
| 57 } | 63 } |
| 58 | 64 |
| 59 function onTimeUpdate() { | 65 function onTimeUpdate() { |
| 60 // crbug.com/246308 | 66 // crbug.com/246308 |
| 61 //checkVideoProperties(); | 67 //checkVideoProperties(); |
| 62 | 68 |
| 63 // Seek to APPEND_TIME because after a seek a timeUpdate event is fired | 69 // Seek to APPEND_TIME because after a seek a timeUpdate event is fired |
| 64 // before video width and height properties get updated. | 70 // before video width and height properties get updated. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 appendNextSource); | 123 appendNextSource); |
| 118 } else { | 124 } else { |
| 119 var mediaSource = loadMediaSource(MEDIA_1, mediaType, | 125 var mediaSource = loadMediaSource(MEDIA_1, mediaType, |
| 120 appendNextSource); | 126 appendNextSource); |
| 121 video.src = window.URL.createObjectURL(mediaSource); | 127 video.src = window.URL.createObjectURL(mediaSource); |
| 122 } | 128 } |
| 123 } | 129 } |
| 124 </script> | 130 </script> |
| 125 </body> | 131 </body> |
| 126 </html> | 132 </html> |
| OLD | NEW |