Best code examples for MediaPlayer setOnErrorListener method (android.media.MediaPlayer.setOnErrorListener)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for MediaPlayer setOnErrorListener method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

MediaPlayer setOnErrorListener examples from Open Source projects
This code example shows how to use the following methods: setOnCompletionListener, setOnErrorListener
	@Override 
	public void onCreate() 
	{ 
		super.onCreate(); 
		Log.i(TAG,"onCreate()");
		player = new MediaPlayer();
		setupPlayerListeners(); 
	} 
	 
	private void setupPlayerListeners() 
	{ 
		if(player != null)
		{ 
			player.setOnCompletionListener(new OnCompletionListener() {
 
				@Override 
				public void onCompletion(MediaPlayer mp) {
					Log.i(TAG,"onCompletion called");
					 
				} }); 

8
CodeRank
This code example shows how to use the following methods: setAudioStreamType, setDataSource, setLooping, setOnErrorListener
    vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
    player = createPlayer();
  } 
 
  private MediaPlayer createPlayer() {
    MediaPlayer newPlayer = new MediaPlayer();
    try { 
      Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
      newPlayer.setOnErrorListener(playerErrorListener);
      newPlayer.setDataSource(context, ringtoneUri);
      newPlayer.setLooping(true);
      newPlayer.setAudioStreamType(AudioManager.STREAM_RING);
      return newPlayer;
    } catch (IOException e) {
      Log.e(TAG, "Failed to create player for incoming call ringer");
      return null; 
    } 
  } 
 
  public void start() { 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setAudioStreamType, setOnBufferingUpdateListener, setOnCompletionListener, setOnErrorListener, setOnPreparedListener
This code example shows how to use the following methods: prepare, setDataSource, setOnCompletionListener, setOnErrorListener, start
This code example shows how to use the following methods: setOnCompletionListener, setOnErrorListener
	protected void setListeners() 
	{ 
		if(player != null)
		{ 
			if(onCompletionListener != null)
				player.setOnCompletionListener(onCompletionListener);
			if(onErrorListener != null)
				player.setOnErrorListener(onErrorListener);
		} 
	} 
	 
	/** 
	 * play a file with given resource id 
	 *  
	 * @param context 
	 * @param resid 
	 */ 
	synchronized public void play(Context context, int resid)
	{ 
		Logger.v("trying to play: " + resid);
Full Snippet Info
7
CodeRank
Related MediaPlayer setOnErrorListener Questions & Answers:
setOnErrorListener Method Overview
Register a callback to be invoked when an error has happened during an asynchronous operation.
See Code Examples for other Android MediaPlayer Methods: