Search code examples
androidvideo-streamingmedia-playerseek

MediaPlayer cannot seek to unbuffered position


This only happens to some specific video files in all version of Android (for example this file) but when playing in iOS or WP or even in Andorid using Vitamio plugin, it is seekable. I think a streaming video file must meet some conditions to be seekable. Is that right? If so, please tell me what conditions to make a streaming video seekable. Thanks you.

This is error log when I tried to seek to unbuffered position of above file.

12-06 12:01:50.705: E/MediaPlayer(909): Error (1,-1007)

Solution

  • For what it's worth, Google Chrome, and Internet Explorer can't seek that file either, unless it's completely downloaded.

    Could it be a problem with the web server, rather than the file?

    The server must support seeking via the content-range request header in order to seek. (A description of the mechanism here: http://benramsey.com/blog/2008/05/206-partial-content-and-range-requests/ ). An accurate content-type is also required. And I THINK the android media player also makes uses DLNA headers in the HTTP response in certain cases, although I'm not certain of this.

    You may want to compare headers in the HTTP response from sites that do and don't work.

    Of particular interest would be the "accept-ranges" header, in the response. Android definitely won't seek if that's not present. It may also require, or benefit from a "ContentFeatures.DLNA.ORG" header in thhe response That's a DLNA header that describes the streaming and seeking capabilities of thge server, along with a more detailed description of the video's encoding.