/** * Moves the current video progress to the specified location. * * @param milliSeconds The time to move the playback to */ public void seekTo(int milliSeconds) { if (videoControls != null) { videoControls.showLoading(false); } videoViewImpl.seekTo(milliSeconds); }
/** * Stops the playback and releases all resources attached to this EMVideoView. This should not be * called manually unless {@link #setReleaseOnDetachFromWindow(boolean)} has been set. */ public void release() { videoControls = null; stopPlayback(); overriddenPositionStopWatch.stop(); videoViewImpl.release(); }
/** * 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(OnPreparedListener)}) * * @return The millisecond value for the current position */ public int getCurrentPosition() { if (overridePosition) { return positionOffset + overriddenPositionStopWatch.getTimeInt(); } return positionOffset + videoViewImpl.getCurrentPosition(); }
/** * Retrieves the duration of the current audio item. This should only be called after the item is * prepared (see {@link #setOnPreparedListener(OnPreparedListener)}). If {@link * #overrideDuration(int)} is set then that value will be returned. * * @return The millisecond duration of the video */ public int getDuration() { if (overriddenDuration >= 0) { return overriddenDuration; } return videoViewImpl.getDuration(); }
/** * Starts the playback for the video specified in {@link #setVideoURI(android.net.Uri)} or {@link * #setVideoPath(String)}. This should be called after the VideoView is correctly prepared (see * {@link #setOnPreparedListener(OnPreparedListener)}) */ public void start() { videoViewImpl.start(); setKeepScreenOn(true); if (videoControls != null) { videoControls.updatePlaybackState(true); } }
/** * Sets the Uri location for the video to play * * @param uri The video's Uri * @param renderBuilder RenderBuilder that should be used */ public void setVideoURI(@Nullable Uri uri, @Nullable RenderBuilder renderBuilder) { videoUri = uri; videoViewImpl.setVideoUri(uri, renderBuilder); if (videoControls != null) { videoControls.showLoading(true); } }
/** * Sets the Uri location for the video to play * * @param uri The video's Uri */ public void setVideoURI(@Nullable Uri uri) { videoUri = uri; videoViewImpl.setVideoUri(uri); if (videoControls != null) { videoControls.showLoading(true); } }
/** If a video is currently in playback then the playback will be suspended */ public void suspend() { videoViewImpl.suspend(); setKeepScreenOn(false); if (videoControls != null) { videoControls.updatePlaybackState(false); } }
/** * Performs the initialization of the view including inflating the correct backing layout, linking * the implementation, and finding the necessary view references. * * @param context The context for the initialization * @param attrs The xml attributes associated with this instance */ protected void initView(Context context, @Nullable AttributeSet attrs) { inflateVideoView(context, attrs); previewImageView = (ImageView) findViewById(R.id.exomedia_video_preview_image); videoViewImpl = (VideoViewApi) findViewById(R.id.exomedia_video_view); muxNotifier = new MuxNotifier(); listenerMux = new EMListenerMux(muxNotifier); videoViewImpl.setListenerMux(listenerMux); }
/** * If the video has completed playback, calling {@code restart} will seek to the beginning of the * video, and play it. * * @return {@code true} if the video was successfully restarted, otherwise {@code false} */ public boolean restart() { if (videoUri == null) { return false; } if (videoViewImpl.restart()) { if (videoControls != null) { videoControls.showLoading(true); } return true; } else { return false; } }
@Override public void setOnTouchListener(OnTouchListener listener) { videoViewImpl.setOnTouchListener(listener); super.setOnTouchListener(listener); }
/** * Sets the rotation for the Video * * @param rotation The rotation to apply to the video */ public void setVideoRotation(@IntRange(from = 0, to = 359) int rotation) { videoViewImpl.setVideoRotation(rotation, true); }
/** * Measures the underlying {@link VideoViewApi} using the video's aspect ratio if {@code true} * * @param measureBasedOnAspectRatioEnabled whether to measure using the video's aspect ratio or * not */ public void setMeasureBasedOnAspectRatioEnabled(boolean measureBasedOnAspectRatioEnabled) { videoViewImpl.setMeasureBasedOnAspectRatioEnabled(measureBasedOnAspectRatioEnabled); }
/** * Sets how the video should be scaled in the view * * @param scaleType how to scale the videos */ public void setScaleType(@NonNull ScaleType scaleType) { videoViewImpl.setScaleType(scaleType); }
/** * Retrieves a list of available tracks to select from. Typically {@link * #trackSelectionAvailable()} should be called before this. * * @return A list of available tracks associated with each track type (see {@link * com.devbrackets.android.exomedia.annotation.TrackRenderType}) */ @Nullable public Map<Integer, List<MediaFormat>> getAvailableTracks() { return videoViewImpl.getAvailableTracks(); }
/** * Changes to the track with <code>trackIndex</code> for the specified <code>trackType</code> * * @param trackType The type for the track to switch to the selected index * @param trackIndex The index for the track to swith to */ public void setTrack(@TrackRenderType int trackType, int trackIndex) { videoViewImpl.setTrack(trackType, trackIndex); }
/** * Determines if the current video player implementation supports track selection for audio or * video tracks. * * @return True if tracks can be manually specified */ public boolean trackSelectionAvailable() { return videoViewImpl.trackSelectionAvailable(); }
/** * Retrieves the current buffer percent of the video. If a video is not currently prepared or * buffering the value will be 0. This should only be called after the video is prepared (see * {@link #setOnPreparedListener(OnPreparedListener)}) * * @return The integer percent that is buffered [0, 100] inclusive */ public int getBufferPercentage() { return videoViewImpl.getBufferedPercent(); }
/** * Sets the volume level for devices that support the ExoPlayer (JellyBean or greater). * * @param volume The volume range [0.0 - 1.0] * @return True if the volume was set */ public boolean setVolume(@FloatRange(from = 0.0, to = 1.0) float volume) { return videoViewImpl.setVolume(volume); }
/** * Returns if a video is currently in playback * * @return True if a video is playing */ public boolean isPlaying() { return videoViewImpl.isPlaying(); }