Android MediaPlayer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MediaPlayer class.

This code example shows how to use the following methods: release, stop
    public void onCompletion(MediaPlayer mediaplayer) {
        Timer endSound = new Timer();
        endSound.schedule(new TimerTask() {
            public void run() { 
                if (mp != null) {
                    mp.stop();
                    mp.release();
                    mp = null;
                } 
            } 
        }, 200); 
 
    } 
 
    /** 
     * Play sound, either locally (from assets) or remotely via URL. 
     *  
     * @param soundUri 
     *            the sound uri 
     */ 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isPlaying, release, stop
	} 
 
	@Override 
	protected void onDialogClosed(final boolean positiveResult) {
		if (mMediaPlayer != null) {
			if (mMediaPlayer.isPlaying()) {
				mMediaPlayer.stop();
			} 
			mMediaPlayer.release();
			mMediaPlayer = null;
		} 
		if (positiveResult) {
			callChangeListener(mSelectedItem);
		} 
	} 
 
	@Override 
	protected void onPrepareDialogBuilder(final Builder builder) {
		builder.setSingleChoiceItems(getEntries(), mSelectedItem, new OnClickListener() {
 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: release, stop
		}  
	} 
	 
	void unloadSound(){ 
		if(player!=null){
			player.release();
			player = null;
		} 
 
		if(soundID!=-1){
			pool.unload(soundID);
		} 
		fileName = null;
		soundID = -1;
		streamID = -1;
		bIsLoaded = false;
		bIsPlaying = false;
	} 
	 
	void play(){ 

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    } 
 
    @Override 
    protected void setUp() throws Exception { 
      super.setUp(); 
      mPlayer = new MediaPlayer();
    } 
 
    @Override 
    protected void tearDown() throws Exception { 
        mPlayer.release();
        super.tearDown(); 
    } 
 
    // Generate a random number, sends it to the ping test player. 
    @Suppress 
    @MediumTest 
    public void testPing() throws Exception { 
        mPlayer.setDataSource("test:invoke_mock_media_player.so?url=ping");
 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isPlaying, stop
    } 
  } 
   
  @Override 
  public void onPause() { 
    if (player.isPlaying()) {
      player.stop();
    } 
     
    super.onPause(); 
  } 
   
  public void onPrepared(MediaPlayer player) {
    player.start();
  } 
} 
Full Snippet Info
9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android MediaPlayer Questions & Answers:

Other Android MediaPlayer Examples

11:	
12:	            @Override
13:	            public void onCompletion(MediaPlayer mp) {
14:	                // TODO Auto-generated method stub
15:	                mp.release();

Read More

4:		@Override
5:		public void onCompletion(MediaPlayer arg0) {
6:	
7:			// check for repeat is ON or OFF
8:			if(isRepeat){

Read More

21:		private boolean hasFlash;
22:		Parameters params;
23:		MediaPlayer mp;
24:	
25:		@Override
-
144:	
145:	            @Override
146:	            public void onCompletion(MediaPlayer mp) {
147:	                // TODO Auto-generated method stub
148:	                mp.release();

Read More

See Code Examples for Android MediaPlayer Methods: