Code example for MediaPlayer: Playing audio and video

Methods: isPlayingprepareresetsetDataSourcestartstop

0
    @Override 
    public void startPlaying() throws IllegalArgumentException, 
	    IllegalStateException, IOException { 
 
	if (mPlayer != null) {
	    if (mPlayer.isPlaying())
		mPlayer.stop();
	    mPlayer.reset();
	} else { 
	    mPlayer = new MediaPlayer();
	    mPlayer.setOnCompletionListener(this);
	} 
	mPlayer.setDataSource(mFile);
	mPlayer.prepare();
	mPlayer.start();
    } 
 
    @Override 
    public boolean isPlaying() { 
	return mPlayer != null && mPlayer.isPlaying();
    }