Code example for MediaPlayer

Methods: getDuration

0
            return mSrvBinding;
        } 
         
        public void onPrepared(MediaPlayer mp) {
            mAudioSrvState = PLAYING;
            Time duration = new Time(mp.getDuration());
            Log.v(TAG, "Prepared mediaplayer for track of duration =["+duration+"]");
            mMediaPlayer.start();
        } 
         
        public void onBufferingUpdate(MediaPlayer mp, int percent) {
            Log.v(TAG, "Buffered additional=["+percent+"%]");
            mAudioSrvState = BUFFERING;
        } 
         
        public void onCompletion(MediaPlayer mp) {
            Log.i(TAG, "Completed playback");
            mMediaPlayer.stop();
            mMediaPlayer.reset();
            mAudioSrvState = NOT_PLAYING;
        }