Buffering API
This page lists JavaScript API support for getting the buffered attribute and for listening to the progress event. We test against the following expectations:
- The buffered attribute should return the range(s) of the video that are buffered.
- The progress event should frequently fire while the buffered range(s) are changing.
- When the buffer is running empty, an event should get fired to indicate this is happening.
This page also includes a test to determine what happens when a buffer underrun happens. In order to determine if a specific event is fired in response to this, the test listens to the events loadeddata, progress, waiting, stalled, suspend, playing, canplay and canplaythrough. Unfortunately, no clear pattern in broadcasting of these events could be found.
Results
| Browser | buffered range | progress event | buffer underrun |
|---|---|---|---|
| Firefox 20 | multiple ranges | frequently sent | Waiting event; playback stalls |
| Chrome 26 | single range | frequently sent | No event; stuttering playback |
| Safari 6 | single range 1 | frequently sent | Waiting event; playback restarts |
| Internet Explorer 9 | single range 2 | frequently sent | No event; stuttering playback |
| Internet Explorer 10 | single range 2 | frequently sent | Stalled event; playback restarts |
| Opera 11.5 | multiple ranges | frequently sent | No event; playback stalls |
| iOS 4 (iPod) | single range 2 | frequently sent | Stalled event; video pauses |
| iOS 5 (iPad) | single range 2 | frequently sent | Stalled event; video pauses |
| iOS 6 (iPad) | single range 2 | frequently sent | Stalled event; video pauses |
| Android 2.2 (HTC Legend) | - | - | No event; playback stalls 3 |
| Android 2.3 (HTC Desire) | - | - | No event; playback stalls 3 |
| Android 4.0 (Galaxy S2) | - | - | No event; playback stalls 3 |
| Android 4.1 (Nexus 7) | single range 2 | frequently sent | No event; playback stalls 3 |
| WinPho 7.5 (Lumia 800) | - | - | No event; playback stalls |
- Seeking to a not-yet-buffered part is denied.
- Only one buffered range (the most recent one) is available.
- Media rendered ignores proxy, hence no way to test underruns.
See the W3C video spec for more details on the media elements API.
Test Tag
Here's a video tag with some javascript operators for testing. The tag uses the preload=none attribute:
The buffer underrun test is performed using a proxy tool (like Charles). First, video buffering is throttled for a while with 2000 kbps. Next, throttling is set to 200 kbps until the video buffer is emptied. After that has happened, throttling is set to 2000 kbps again.