Created
April 1, 2019 09:46
-
-
Save MohammadSamandari/f41155cad0885890ab21a341ef7f7eb6 to your computer and use it in GitHub Desktop.
Working with Media Player
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defining a Media Player: | |
MediaPlayer mediaPlayer; | |
// Giving the Media Player a sound to play | |
mediaPlayer =MediaPlayer.create(this,R.raw.music); | |
// Getting lenght of file in media player. | |
int musicLength = mediaPlayer.getDuration(); | |
// getting the current position of sound while playing | |
int curPosition = mediaPlayer.getCurrentPosition(); | |
// Moving sound to a certain time and playing from there. | |
mediaPlayer.seekTo(progress); | |
// Stating the Play of sound | |
mediaPlayer.start(); | |
// Pauseing the Play of Sound. | |
mediaPlayer.pause(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment