/** * Sets the bus to use for dispatching Events that correspond to the callbacks listed in {@link * com.devbrackets.android.exomedia.listener.EMVideoViewControlsCallback} * * @param bus The EventBus to dispatch events on */ public void setBus(@Nullable EMEventBus bus) { this.bus = bus; listenerMux.setBus(bus); if (defaultControls != null) { defaultControls.setBus(bus); } }
/** * Sets the Uri location for the video to play * * @param uri The video's Uri * @param defaultMediaType The MediaType to use when auto-detection fails */ public void setVideoURI(Uri uri, MediaUtil.MediaType defaultMediaType) { videoUri = uri; if (!useExo) { videoView.setVideoURI(uri); } else { if (uri == null) { emExoPlayer.replaceRenderBuilder(null); } else { emExoPlayer.replaceRenderBuilder( getRendererBuilder(VideoType.get(uri), uri, defaultMediaType)); listenerMux.setNotifiedCompleted(false); } // Makes sure the listeners get the onPrepared callback listenerMux.setNotifiedPrepared(false); emExoPlayer.seekTo(0); } if (defaultControls != null) { defaultControls.restartLoading(); } }
/** * Retrieves the current position of the audio playback. If an audio item is not currently in * playback then the value will be 0. This should only be called after the item is prepared (see * {@link #setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener)}) * * @return The millisecond value for the current position */ public long getCurrentPosition() { if (overridePosition) { return positionOffset + overriddenPositionStopWatch.getTime(); } if (!listenerMux.isPrepared()) { return 0; } if (!useExo) { return positionOffset + videoView.getCurrentPosition(); } return positionOffset + emExoPlayer.getCurrentPosition(); }
/** * Retrieves the duration of the current audio item. This should only be called after the item is * prepared (see {@link #setOnPreparedListener(android.media.MediaPlayer.OnPreparedListener)}). If * {@link #overrideDuration(int)} is set then that value will be returned. * * @return The millisecond duration of the video */ public long getDuration() { if (overriddenDuration >= 0) { return overriddenDuration; } if (!listenerMux.isPrepared()) { return 0; } if (!useExo) { return videoView.getDuration(); } return emExoPlayer.getDuration(); }
/** * Sets the listener to inform of media information events. * * @param listener The listener */ public void setOnInfoListener(MediaPlayer.OnInfoListener listener) { listenerMux.setOnInfoListener(listener); }
/** * Sets the listener to inform of playback errors. This can also be accessed through the bus event * {@link com.devbrackets.android.exomedia.event.EMMediaErrorEvent} * * @param listener The listener */ public void setOnErrorListener(MediaPlayer.OnErrorListener listener) { listenerMux.setOnErrorListener(listener); }
/** * Sets the listener to inform of VideoPlayer completion events. This can also be accessed through * the bus event {@link com.devbrackets.android.exomedia.event.EMMediaCompletionEvent} * * @param listener The listener */ public void setOnCompletionListener(MediaPlayer.OnCompletionListener listener) { listenerMux.setOnCompletionListener(listener); }
/** * Sets the listener to inform of VideoPlayer prepared events. This can also be accessed through * the bus event {@link com.devbrackets.android.exomedia.event.EMMediaPreparedEvent} * * @param listener The listener */ public void setOnPreparedListener(MediaPlayer.OnPreparedListener listener) { listenerMux.setOnPreparedListener(listener); }
/** * Removes the specified listener for the ExoPlayer. * * @param listener The listener to remove */ public void removeExoPlayerListener(ExoPlayerListener listener) { listenerMux.removeExoPlayerListener(listener); }
/** * Sets the listener to inform of any exoPlayer events * * @param listener The listener */ public void addExoPlayerListener(ExoPlayerListener listener) { listenerMux.addExoPlayerListener(listener); }