2544d804 by David LaPalomento

Adjust test page to allow segment-by-segment testing

Make the debug video and media source available in a larger scope. Every time a new segment is selected, forward they bytes into the active source buffer.
1 parent cb74d9c0
...@@ -119,9 +119,33 @@ ...@@ -119,9 +119,33 @@
119 workingBoxes = document.querySelector('.working-boxes'), 119 workingBoxes = document.querySelector('.working-boxes'),
120 120
121 vjsOutput = document.querySelector('.vjs-hls-output'), 121 vjsOutput = document.querySelector('.vjs-hls-output'),
122 workingOutput = document.querySelector('.working-output'); 122 workingOutput = document.querySelector('.working-output'),
123
124 video = document.createElement('video'),
125 mediaSource = new MediaSource(),
126
127 logevent = function(event) {
128 console.log(event.type);
129 };
130
131 mediaSource.addEventListener('sourceopen', function() {
132 var
133 buffer = mediaSource.addSourceBuffer('video/mp4;codecs=avc1.4d400d'),
134 one = false;
135 buffer.addEventListener('updatestart', logevent);
136 buffer.addEventListener('updateend', logevent);
137 buffer.addEventListener('error', logevent);
138 window.vjsMediaSource = mediaSource;
139 window.vjsSourceBuffer = buffer;
140 window.vjsVideo = video;
141 });
142 mediaSource.addEventListener('error', logevent);
143 mediaSource.addEventListener('opened', logevent);
144 mediaSource.addEventListener('closed', logevent);
145 mediaSource.addEventListener('sourceended', logevent);
146 video.src = URL.createObjectURL(mediaSource);
147 video.addEventListener('error', console.log.bind(console));
123 148
124 // webkit dash-mp4 mime: 'video/mp4;codecs=avc1.4d0020,mp4a.40.2'
125 149
126 videojs.log = console.log.bind(console); 150 videojs.log = console.log.bind(console);
127 151
...@@ -146,26 +170,6 @@ ...@@ -146,26 +170,6 @@
146 170
147 // XXX media source testing 171 // XXX media source testing
148 172
149 var video = document.createElement('video');
150 var mediaSource = new MediaSource();
151 mediaSource.addEventListener('sourceopen', function() {
152 var buffer = mediaSource.addSourceBuffer('video/mp4;codecs=avc1.4d400d');
153 buffer.addEventListener('updatestart', console.log.bind(console));
154 buffer.addEventListener('updateend', console.log.bind(console));
155 buffer.addEventListener('error', console.log.bind(console));
156 buffer.appendBuffer(videojs.mp4.initSegment());
157 console.log('done');
158 window.vjsMediaSource = mediaSource;
159 window.vjsSourceBuffer = buffer;
160 window.vjsVideo = video;
161 });
162 mediaSource.addEventListener('error', console.log.bind(console));
163 mediaSource.addEventListener('opened', console.log.bind(console));
164 mediaSource.addEventListener('closed', console.log.bind(console));
165 mediaSource.addEventListener('sourceended', console.log.bind(console));
166 video.src = URL.createObjectURL(mediaSource);
167 video.addEventListener('error', console.log.bind(console));
168
169 vjsBoxes.innerHTML = JSON.stringify(videojs.inspectMp4(videojs.mp4.initSegment()), null, ' '); 173 vjsBoxes.innerHTML = JSON.stringify(videojs.inspectMp4(videojs.mp4.initSegment()), null, ' ');
170 }); 174 });
171 reader.readAsArrayBuffer(this.files[0]); 175 reader.readAsArrayBuffer(this.files[0]);
...@@ -187,7 +191,8 @@ ...@@ -187,7 +191,8 @@
187 workingOutput.innerHTML = hex; 191 workingOutput.innerHTML = hex;
188 192
189 // XXX Media Sources Testing 193 // XXX Media Sources Testing
190 194 window.vjsSourceBuffer.appendBuffer(bytes);
195 console.log('appended bytes');
191 }); 196 });
192 reader.readAsArrayBuffer(this.files[0]); 197 reader.readAsArrayBuffer(this.files[0]);
193 }, false); 198 }, false);
......