Monday, March 9, 2009

Support : setMediaTime does not work for AMR files


When using the Player method to seek the media time in an Adaptive Multi-Rate (AMR) encoded file, seeking past the first 58 KB of the file does not work. Seeking is possible within the first 58 KB of the AMR file, provided the file size is known, and setMediaTime is called after the PlayerListener.STARTED event is received.

To work around this limitation, implement and call a custom DataSource method to handle the seeking separately.

See DB-00612 for instructions on creating a custom DataSource and SourceStream.

The SourceStream implementation should contain a special operation to handle the AMR seeking. The following is an example for 12.2kbps AMR files, which is the encoding standard used for files recorded on the BlackBerry device. AMR files are broken into 20 millisecond frames, and 12.2kbps files have 32bytes per frame. Each AMR file also has a 6 byte header.

public void amrSeek(long millis) {
int frame = (int) millis/20;
readLocation = (framenumber * 32) + 6;
}

The SourceStream read method should use the readLocation variable to define where reads to the media stream will start because it is the beginning of the frame that has been seeked.

1 comment:

Place your comments here...