The BMediaTrack class provides access to a particular track in a media file. It's always instantiated using the BMediaFile::TrackAt() or BMediaFile::CreateTrack() function.

The BMediaTrack constructor searches for a codec that can handle the encoded data in the track; once that's been done, the track is ready to be used.

If you opened the file for writing, you can write data into the track. If you specified the B_MEDIA_FILE_REPLACE_MODE flag when constructing the BMediaFile, you can both read and write from the file. If no decoder is available for the track, you can still use ReadChunk() to access the encoded data directly.

After instantiating the BMediaTrack, using the BMediaFile functions for doing so, you should call InitCheck() to be sure the track is valid. You can then use ReadFrames() and WriteFrames() to read and write data to the file, as appropriate. For video data, you should work one frame at a time.

You can also seek particular times or frames using SeekToTime() or SeekToFrame().

For an example of how to use BMediaTrack to read and write tracks in media files, see "Reading and Writing Media Files"


As a general rule, you can't use wildcards in any structures used by BMediaTrack functions. You tell BMediaTrack what format you have, and BMediaTrack will simply tell you whether or not that format is supported.

Creative Commons License
Legal Notice
This work is licensed under a Creative Commons Attribution-Non commercial-No Derivative Works 3.0 License.