![]() ![]() reset(): The reset() method is used to play a media from its beginning.stop(): The stop() method completely stops the media, and if you play it again, then it starts from the beginning.pause(): The pause() method is used to pause a current media if it’s playing.It returns true if the media is playing and false if not playing. isPlaying(): The isPlaying() method is used to know whether or not a media is playing.getDuration(): The getDuration() method provides us with the length of a particular song or media in milliseconds. ![]() Now let’s see a few of the essential methods for us to know to work with the Android Media Player class. The point to note is that Android Media Player is not thread-safe, and whatever you wish to access or control should be in the same thread. MediaPlayerObj = MediaPlayer.create(this, R.raw.my_music_file) To work with Android Media Player, you first need to create an object of the Media Player, as shown below.Ĭode: lateinit var mediaPlayerObj: MediaPlayer Even the media player provides you with playback controls such as play/pause/stop. Android Media Player provides you with an API to manage several audio/video present on the device or the network. Media Player is a class provided by Android to manage audio/video files and streams. ![]() Android Event Handling What is Android Media Player? Before we proceed further, you must ensure that you are ready with the following tools and know the topics mentioned below.ģ. ![]()
0 Comments
Leave a Reply. |