Understanding the Media Player Oddities

In general, the MediaPlayer is very systematic, so you need to call operations in a specific order to initialize a media player properly and prepare it for playback. This list summarizes some of the oddities of using the media APIs:

• Once you set the data source of a MediaPlayer, you cannot dynamically change it to another one—you'll have to create a new MediaPlayer or call the reset() method to reinitialize the state of the player.

• After you call prepare(), you can call getCurrentPosition(), getDuration(), and isPlaying() to get the current state of the player. You can also call the setLooping() and setVolume() methods after the call to prepare().

• After you call start(), you can call pause(), stop(), and seekTo().

• Every MediaPlayer creates a new thread, so be sure to call the release() method when you are done with the media player. The VideoView takes care of this in the case of video playback, but you'll have to do it manually if you decide to use MediaPlayer instead of VideoView.

Now let's explore recording media.

0 0

Post a comment