Code example for MediaPlayer.OnCompletionListener

Methods: onCompletion

0
            //ÊÓƵ²¥·ÅÍê³Éʱµ÷Óà
            mMediaPlayer.setOnCompletionListener(new OnCompletionListener() {
				 
				public void onCompletion(MediaPlayer mp) {
		            if (mOnCompletionListener != null) {
		                mOnCompletionListener.onCompletion(mMediaPlayer);
		            } 
		        } 
			}); 
            //ÊÓƵ¼ÓÔØÍê³Éʱµ÷Óà
            mMediaPlayer.setOnPreparedListener(mPreparedListener);
  
            //ÉèÖûò²¥·Åʱ£¬²úÉú´íÎóʱ µ÷Óà
            mMediaPlayer.setOnErrorListener(mErrorListener);
            mDuration = -1;//ÊÓƵµÄ×Üʱ³¤     
            //Êý¾ÝÔ´ 
            mMediaPlayer.setDataSource(mContext, uri);
            //ÉèÖÃÏÔʾÄÚÈÝ 
            mMediaPlayer.setDisplay(mSurfaceHolder);
            //ÉùÒôÀàÐÍ 
            mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);