Java Code Examples for android.media.MediaPlayer.OnCompletionListener

The following examples show how to use android.media.MediaPlayer.OnCompletionListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: letv   Source File: RedPacketDialog.java    License: Apache License 2.0 6 votes vote down vote up
private void soundShake() {
    try {
        this.mPlayer = MediaPlayer.create(RedPacketSdkManager.getInstance().getApplicationContext(), R.raw.shake_sound);
        if (this.mPlayer != null) {
            this.mPlayer.start();
            this.mPlayer.setOnCompletionListener(new OnCompletionListener() {
                public void onCompletion(MediaPlayer mp) {
                    RedPacketDialog.this.mPlayer.release();
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (this.mPlayer != null) {
            this.mPlayer.release();
        }
    }
}
 
Example 2
Source Project: media-button-router   Source File: ReceiverSelector.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Takes appropriate action to notify user and dismiss activity on timeout.
 */
private void onTimeout() {
    Log.d(TAG, "Media Button Selector: Timed out waiting for user interaction, finishing activity");
    final MediaPlayer timeoutPlayer = MediaPlayer.create(this, R.raw.dismiss);
    timeoutPlayer.start();
    // not having an on error listener results in on completion listener
    // being called anyway
    timeoutPlayer.setOnCompletionListener(new OnCompletionListener() {

        public void onCompletion(MediaPlayer mp) {
            timeoutPlayer.release();
        }
    });

    // If the user has set their preference not to confirm actions, we'll
    // just forward automatically to whoever was last selected. If no one is
    // selected, it just acts like finish anyway.
    if (preferences.getBoolean(Constants.CONFIRM_ACTION_PREF_KEY, true)) {
        finish();
    } else {
        select();
    }
}
 
Example 3
Source Project: Multiwii-Remote   Source File: Utilities.java    License: Apache License 2.0 6 votes vote down vote up
public static void playNotification(Activity myActivity) {
	Uri defaultRingtoneUri = RingtoneManager
			.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
	try {
		MediaPlayer mediaPlayer = new MediaPlayer();
		mediaPlayer.setDataSource(myActivity.getBaseContext(),
				defaultRingtoneUri);
		mediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
		mediaPlayer.prepare();
		mediaPlayer.setOnCompletionListener(new OnCompletionListener() {

			public void onCompletion(MediaPlayer mp) {
				mp.release();
			}

		});
		mediaPlayer.start();

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 4
Source Project: zom-android-matrix   Source File: AudioWife.java    License: Apache License 2.0 5 votes vote down vote up
/****
 * Add custom playback completion listener. Adding multiple listeners will queue up all the
 * listeners and fire them on media playback completes.
 */
public AudioWife addOnCompletionListener(OnCompletionListener listener) {

    // add default click listener to the top
    // so that it is the one that gets fired first
    mCompletionListeners.add(0, listener);

    return this;
}
 
Example 5
Source Project: datmusic-android   Source File: AudioWife.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * *
 * Add custom playback completion listener. Adding multiple listeners will queue up all the
 * listeners and fire them on media playback completes.
 */
public AudioWife addOnCompletionListener(OnCompletionListener listener) {

    // add default click listener to the top
    // so that it is the one that gets fired first
    mCompletionListeners.add(0, listener);

    return this;
}
 
Example 6
Source Project: Zom-Android-XMPP   Source File: AudioWife.java    License: GNU General Public License v3.0 5 votes vote down vote up
/****
 * Add custom playback completion listener. Adding multiple listeners will queue up all the
 * listeners and fire them on media playback completes.
 */
public AudioWife addOnCompletionListener(OnCompletionListener listener) {

    // add default click listener to the top
    // so that it is the one that gets fired first
    mCompletionListeners.add(0, listener);

    return this;
}
 
Example 7
Source Project: BotLibre   Source File: VideoView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener listener) {
	System.out.println("OnCompletionList...");
	Platform.runLater(new Runnable() {
		@Override
		public void run() {
			try {
				if (mediaPlayer != null) {
					mediaPlayer.stop();
				}
			} catch (Exception e) {
				System.out.println("SetOnCompletionListener\nError Player Video: " + e.toString());
			}
		}
	});
}
 
Example 8
Source Project: BotLibre   Source File: VideoView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener listener) {
	System.out.println("OnCompletionList...");
	Platform.runLater(new Runnable() {
		@Override
		public void run() {
			try {
				if (mediaPlayer != null) {
					mediaPlayer.stop();
				}
			} catch (Exception e) {
				System.out.println("SetOnCompletionListener\nError Player Video: " + e.toString());
			}
		}
	});
}
 
Example 9
Source Project: audio-wife   Source File: AudioWife.java    License: MIT License 5 votes vote down vote up
/****
 * Add custom playback completion listener. Adding multiple listeners will queue up all the
 * listeners and fire them on media playback completes.
 */
public AudioWife addOnCompletionListener(OnCompletionListener listener) {

	// add default click listener to the top
	// so that it is the one that gets fired first
	mCompletionListeners.add(0, listener);

	return this;
}
 
Example 10
Source Project: coursera-android   Source File: MediaPlaybackService.java    License: MIT License 5 votes vote down vote up
@Override
public void setOnCompletionListener(OnCompletionListener listener) {
    if (mCompatMode) {
        mCompletion = listener;
    } else {
        super.setOnCompletionListener(listener);
    }
}
 
Example 11
Source Project: CuXtomCam   Source File: SoundEffectPlayer.java    License: Apache License 2.0 5 votes vote down vote up
private MediaPlayer createSoundEffect(Context ctx, int resource) {
	final MediaPlayer effect = MediaPlayer.create(ctx, resource);
	effect.setOnCompletionListener(new OnCompletionListener() {
		@Override
		public void onCompletion(MediaPlayer arg0) {
			if (effect != null) {
				effect.seekTo(0);
			}
		}
	});
	return effect;
}
 
Example 12
Source Project: CameraV   Source File: ODKSeekBar.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void reInit(java.io.File recordingFile, final OnCompletionListener ocl) {
	mr.reset();
	this.recordingFile.delete();
	
	initMediaRecorder();
	init(recordingFile, ocl);
}
 
Example 13
Source Project: zom-android-matrix   Source File: AudioWife.java    License: Apache License 2.0 4 votes vote down vote up
private void fireCustomCompletionListeners(MediaPlayer mp) {
    for (OnCompletionListener listener : mCompletionListeners) {
        listener.onCompletion(mp);
    }
}
 
Example 14
public void setOnCompletionListener(OnCompletionListener l) {
}
 
Example 15
Source Project: letv   Source File: VideoViewH264m3u8.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 16
Source Project: letv   Source File: VideoViewH264LeMobile.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 17
Source Project: letv   Source File: VideoViewH264m3u8Hw.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 18
Source Project: letv   Source File: VideoViewH264m3u8HwLeMobile.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 19
Source Project: letv   Source File: VideoViewH264mp4.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 20
Source Project: letv   Source File: VideoViewTV.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 21
Source Project: letv   Source File: VideoViewH264m3u8_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 22
Source Project: letv   Source File: VideoViewH264LeMobile_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 23
Source Project: letv   Source File: VideoViewH264mp4_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 24
Source Project: letv   Source File: VideoViewH264m3u8Hw_4D.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
    this.mOnCompletionListener = l;
}
 
Example 25
Source Project: letv   Source File: FFMpegPlayer.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener listener) {
    this.mOnCompletionListener = listener;
}
 
Example 26
Source Project: OTTLivePlayer_vlc   Source File: VideoView.java    License: MIT License 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
}
 
Example 27
Source Project: OTTLivePlayer_vlc   Source File: VideoView.java    License: MIT License 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
}
 
Example 28
public void setOnCompletionListener(OnCompletionListener l) {
}
 
Example 29
Source Project: libvlc-sdk-android   Source File: VideoView.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void setOnCompletionListener(OnCompletionListener l) {
}
 
Example 30
Source Project: datmusic-android   Source File: AudioWife.java    License: Apache License 2.0 4 votes vote down vote up
private void fireCustomCompletionListeners(MediaPlayer mp) {
    for (OnCompletionListener listener : mCompletionListeners) {
        listener.onCompletion(mp);
    }
}