Code example for MediaPlayer: Playing audio and video

Methods: start

0
     * android.media.MediaPlayer.OnPreparedListener#onPrepared(android.media 
     * .MediaPlayer) 
     */ 
    public void onPrepared(MediaPlayer mediaplayer) {
        if (mp != null) {
            mp.start();
        } 
    } 
 
    /* 
     * (non-Javadoc) 
     *  
     * @see 
     * android.media.MediaPlayer.OnCompletionListener#onCompletion(android.media 
     * .MediaPlayer) 
     */ 
    public void onCompletion(MediaPlayer mediaplayer) {
        Timer endSound = new Timer();
        endSound.schedule(new TimerTask() {
            public void run() { 
                if (mp != null) {