Java Code Examples for android.media.MediaPlayer#OnErrorListener
The following examples show how to use
android.media.MediaPlayer#OnErrorListener .
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 check out the related API usage on the sidebar.
Example 1
Source File: RxAudioPlayer.java From RxAndroidAudio with MIT License | 6 votes |
private void setMediaPlayerListener(final MediaPlayer player, final MediaPlayer.OnCompletionListener onCompletionListener, final MediaPlayer.OnErrorListener onErrorListener) { player.setOnCompletionListener(mp -> { Log.d(TAG, "OnCompletionListener::onCompletion"); // could not call stopPlay immediately, otherwise the second sound // could not play, thus no complete notification // TODO discover why? Observable.timer(50, TimeUnit.MILLISECONDS).subscribe(aLong -> { stopPlay(); onCompletionListener.onCompletion(mp); }, throwable -> Log.d(TAG, "OnCompletionListener::onError, " + throwable.getMessage())); }); player.setOnErrorListener((mp, what, extra) -> { Log.d(TAG, "OnErrorListener::onError" + what + ", " + extra); onErrorListener.onError(mp, what, extra); stopPlay(); return true; }); }
Example 2
Source File: AndroidMediaPlayerFacade.java From no-player with Apache License 2.0 | 5 votes |
@Override public boolean onError(MediaPlayer mp, int what, int extra) { NoPlayerLog.d("Error: " + what + "," + extra); currentState = PlaybackState.ERROR; MediaPlayer.OnErrorListener onErrorForwarder = forwarder.onErrorListener(); if (onErrorForwarder == null) { throw new IllegalStateException("Should bind a OnErrorListener. Cannot forward events."); } return onErrorForwarder.onError(mediaPlayer, what, extra); }
Example 3
Source File: MediaPlayerErrorListener.java From no-player with Apache License 2.0 | 5 votes |
@Override public boolean onError(MediaPlayer mp, int what, int extra) { boolean handled = false; for (MediaPlayer.OnErrorListener listener : listeners) { handled = listener.onError(mp, what, extra) || handled; } return handled; }
Example 4
Source File: MediaPlayerForwarder.java From no-player with Apache License 2.0 | 4 votes |
public MediaPlayer.OnErrorListener onErrorListener() { return errorListener; }
Example 5
Source File: MediaPlayerBridge.java From 365browser with Apache License 2.0 | 4 votes |
protected void setOnErrorListener(MediaPlayer.OnErrorListener listener) { getLocalPlayer().setOnErrorListener(listener); }
Example 6
Source File: ScalableVideoView.java From Android-ScalableVideoView with Apache License 2.0 | 4 votes |
public void setOnErrorListener(@Nullable MediaPlayer.OnErrorListener listener) { mMediaPlayer.setOnErrorListener(listener); }
Example 7
Source File: MediaPlayerBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
protected void setOnErrorListener(MediaPlayer.OnErrorListener listener) { getLocalPlayer().setOnErrorListener(listener); }
Example 8
Source File: DSL.java From anvil with MIT License | 4 votes |
public static Void onError(MediaPlayer.OnErrorListener arg) { return BaseDSL.attr("onError", arg); }
Example 9
Source File: AndroidMediaPlayerFacadeTest.java From no-player with Apache License 2.0 | 4 votes |
private void whenErroring() { ArgumentCaptor<MediaPlayer.OnErrorListener> argumentCaptor = ArgumentCaptor.forClass(MediaPlayer.OnErrorListener.class); verify(mediaPlayer).setOnErrorListener(argumentCaptor.capture()); argumentCaptor.getValue().onError(mediaPlayer, ANY_ERROR_WHAT, ANY_ERROR_EXTRA); }
Example 10
Source File: MusicPlayer.java From PhotoMovie with Apache License 2.0 | 4 votes |
public void setErrorListener(MediaPlayer.OnErrorListener onErrorListener) { mMediaPlayer.setOnErrorListener(onErrorListener); }
Example 11
Source File: MediaPlayerErrorListener.java From no-player with Apache License 2.0 | 4 votes |
void add(MediaPlayer.OnErrorListener listener) { listeners.add(listener); }
Example 12
Source File: SurfaceVideoView.java From VideoRecord with MIT License | 4 votes |
public void setOnErrorListener(MediaPlayer.OnErrorListener l) { mOnErrorListener = l; }
Example 13
Source File: MediaPlayerBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
protected void setOnErrorListener(MediaPlayer.OnErrorListener listener) { getLocalPlayer().setOnErrorListener(listener); }
Example 14
Source File: WXVideoView.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public void setOnErrorListener(MediaPlayer.OnErrorListener l) { mOnErrorListener = l; if (mVideoView != null) { mVideoView.setOnErrorListener(l); } }
Example 15
Source File: AlphaMovieView.java From alpha-movie with Apache License 2.0 | 4 votes |
public void setOnErrorListener(MediaPlayer.OnErrorListener onErrorListener){ mediaPlayer.setOnErrorListener(onErrorListener); }
Example 16
Source File: NativeSurfaceVideoView.java From ExoMedia with Apache License 2.0 | 2 votes |
/** * Register a callback to be invoked when an error occurs * during playback or setup. If no listener is specified, * or if the listener returned false, TextureVideoView will inform * the user of any errors. * * @param listener The callback that will be run */ public void setOnErrorListener(@Nullable MediaPlayer.OnErrorListener listener) { delegate.setOnErrorListener(listener); }
Example 17
Source File: UniversalVideoView.java From LLApp with Apache License 2.0 | 2 votes |
/** * Register a callback to be invoked when an error occurs * during playback or setup. If no listener is specified, * or if the listener returned false, VideoView will inform * the user of any errors. * * @param l The callback that will be run */ public void setOnErrorListener(MediaPlayer.OnErrorListener l) { mOnErrorListener = l; }
Example 18
Source File: NativeTextureVideoView.java From ExoMedia with Apache License 2.0 | 2 votes |
/** * Register a callback to be invoked when an error occurs * during playback or setup. If no listener is specified, * or if the listener returned false, TextureVideoView will inform * the user of any errors. * * @param listener The callback that will be run */ public void setOnErrorListener(@Nullable MediaPlayer.OnErrorListener listener) { delegate.setOnErrorListener(listener); }
Example 19
Source File: MediaVideoViewOld.java From Slide with GNU General Public License v3.0 | 2 votes |
/** * Register a callback to be invoked when an error occurs * during playback or setup. If no listener is specified, * or if the listener returned false, VideoView will inform * the user of any errors. * * @param l The callback that will be run */ public void setOnErrorListener(MediaPlayer.OnErrorListener l) { mOnErrorListener = l; }
Example 20
Source File: NativeVideoDelegate.java From ExoMedia with Apache License 2.0 | 2 votes |
/** * Register a callback to be invoked when an error occurs * during playback or setup. If no listener is specified, * or if the listener returned false, TextureVideoView will inform * the user of any errors. * * @param listener The callback that will be run */ public void setOnErrorListener(@Nullable MediaPlayer.OnErrorListener listener) { onErrorListener = listener; }