Class VideoPlayer
-
- All Implemented Interfaces:
public abstract class VideoPlayerA video player interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceVideoPlayer.PlayerListenerListener of this player.
public classVideoPlayer.Companion
-
Field Summary
Fields Modifier and Type Field Description public final static IntegerUNLIMITED_MAX_BITRATE_KBPSprivate FloatcachedVolumeprivate final Contextcontextpublic final static VideoPlayer.CompanionCompanion
-
Constructor Summary
Constructors Constructor Description VideoPlayer(Context context)Constructors a new VideoPlayer instance.
-
Method Summary
Modifier and Type Method Description final FloatgetCachedVolume()cached volume value, used to restore volume after mute. final UnitsetCachedVolume(Float cachedVolume)cached volume value, used to restore volume after mute. final ContextgetContext()the context. abstract AudioFocusManagergetAudioFocusManager()abstract UnitsetVideoTextureView(TextureView textureView)Sets the TextureView onto which video will be rendered. UnitsetBackBufferDurationMillis(Integer backBufferDurationMillis)백 버퍼 지속시간을 설정합니다. abstract UnitsetBufferDurationsMs(BufferDurationsMs bufferDurationsMs)비디오 플레이어의 버퍼링 지속시간을 설정합니다. abstract UnitsetVideoPath(String uri)Sets the URI of the video to play. abstract UnitsetVideoPath(Uri uri)Sets the Uri of the video to play. abstract UnitsetMaxBitrateKbps(Integer maxBitrateKbps)sets maximum bitrate(kbps) of the video to play. abstract PlaybackStategetPlaybackState()Returns the current PlaybackState of the player. abstract BooleanisPlaying()Returns whether the player is playing. final Unitplay()Play the currently loaded video from its current position. abstract UnitplayInternal()final Unitpause()Pauses playback. abstract UnitpauseInternal()abstract UnitsetPlayWhenReady(Boolean playWhenReady)Sets whether playback should proceed when getPlaybackState == PlaybackState.PREPARED. abstract BooleangetPlayWhenReady()Whether playback will proceed when getPlaybackState == PlaybackState.PREPARED. final Unitstop()Stops playback without resetting the playlist. abstract UnitstopInternal()final Unitrelease()Releases the player. abstract UnitreleaseInternal()abstract LonggetDuration()Returns the duration of the current content or ad in milliseconds, or -1if the duration is not known.abstract LonggetCurrentPosition()Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if the . abstract LonggetBufferedPosition()Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds. abstract BooleanisLoading()Whether the player is currently loading the source. abstract UnitseekTo(Long positionMillis)Seeks to a position specified in milliseconds in the current MediaItem. final Unitmute(Boolean mute)Sets the mute state of the current audio stream. abstract UnitmuteInternal(Boolean mute)abstract BooleanisMuted()Returns the mute state of the current audio stream. abstract FloatgetVolume()Returns the audio volume, with 0 being silence and 1. UnitsetVolume(Float volume)Sets the player volume. abstract UnitaddPlayerListener(VideoPlayer.PlayerListener listener)Registers a listener to receive all events from the player. abstract UnitremovePlayerListener(VideoPlayer.PlayerListener listener)Unregister a listener registered through addPlayerListener. final static VideoPlayercreate(Context context)create a VideoPlayer instance. -
-
Constructor Detail
-
VideoPlayer
VideoPlayer(Context context)
Constructors a new VideoPlayer instance.
-
-
Method Detail
-
getCachedVolume
final Float getCachedVolume()
cached volume value, used to restore volume after mute.
-
setCachedVolume
final Unit setCachedVolume(Float cachedVolume)
cached volume value, used to restore volume after mute.
-
getContext
final Context getContext()
the context.
-
getAudioFocusManager
abstract AudioFocusManager getAudioFocusManager()
-
setVideoTextureView
abstract Unit setVideoTextureView(TextureView textureView)
Sets the TextureView onto which video will be rendered. The player will track the lifecycle of the surface automatically.
- Parameters:
textureView- the texture view
-
setBackBufferDurationMillis
@Deprecated(message = "This method is deprecated. Use setBufferDurationsMs() instead.", replaceWith = @ReplaceWith(imports = {}, expression = "setBufferDurationsMs(BufferDurationsMs(backBufferDurationMillis = backBufferDurationMillis))")) Unit setBackBufferDurationMillis(Integer backBufferDurationMillis)
백 버퍼 지속시간을 설정합니다.
- Parameters:
backBufferDurationMillis- 백 버퍼 지속시간 (밀리초)
-
setBufferDurationsMs
abstract Unit setBufferDurationsMs(BufferDurationsMs bufferDurationsMs)
비디오 플레이어의 버퍼링 지속시간을 설정합니다. 버퍼링 성능 최적화를 위해 다양한 버퍼 파라미터를 한번에 설정할 수 있습니다.
- Parameters:
bufferDurationsMs- 버퍼 지속시간 설정 객체
-
setVideoPath
abstract Unit setVideoPath(String uri)
Sets the URI of the video to play.
- Parameters:
uri- the URI.
-
setVideoPath
abstract Unit setVideoPath(Uri uri)
Sets the Uri of the video to play.
- Parameters:
uri- the Uri.
-
setMaxBitrateKbps
abstract Unit setMaxBitrateKbps(Integer maxBitrateKbps)
sets maximum bitrate(kbps) of the video to play. default is UNLIMITED_MAX_BITRATE_KBPS.
-
getPlaybackState
abstract PlaybackState getPlaybackState()
Returns the current PlaybackState of the player.
- Returns:
the current PlaybackState.
-
isPlaying
abstract Boolean isPlaying()
Returns whether the player is playing.
- Returns:
whether the player is playing.
-
playInternal
abstract Unit playInternal()
-
pause
final Unit pause()
Pauses playback. Equivalent to setPlayWhenReady to false.
-
pauseInternal
abstract Unit pauseInternal()
-
setPlayWhenReady
abstract Unit setPlayWhenReady(Boolean playWhenReady)
Sets whether playback should proceed when getPlaybackState == PlaybackState.PREPARED.
If the player is already in the ready state then this method pauses and resumes playback.
- Parameters:
playWhenReady- whether playback should proceed when ready.
-
getPlayWhenReady
abstract Boolean getPlayWhenReady()
Whether playback will proceed when getPlaybackState == PlaybackState.PREPARED.
- Returns:
whether playback will proceed when ready.
-
stop
final Unit stop()
Stops playback without resetting the playlist. Use pause rather than this method if the intention is to pause playback.
-
stopInternal
abstract Unit stopInternal()
-
release
final Unit release()
Releases the player. This method must be called when the player is no longer required. The player must not be used after calling this method.
-
releaseInternal
abstract Unit releaseInternal()
-
getDuration
abstract Long getDuration()
Returns the duration of the current content or ad in milliseconds, or
-1if the duration is not known.
-
getCurrentPosition
abstract Long getCurrentPosition()
Returns the playback position in the current content or ad, in milliseconds, or the prospective position in milliseconds if the .getCurrentTimeline is empty.
-
getBufferedPosition
abstract Long getBufferedPosition()
Returns an estimate of the position in the current content or ad up to which data is buffered, in milliseconds.
-
isLoading
abstract Boolean isLoading()
Whether the player is currently loading the source.
- Returns:
Whether the player is currently loading the source.
-
seekTo
abstract Unit seekTo(Long positionMillis)
Seeks to a position specified in milliseconds in the current MediaItem.
-
muteInternal
abstract Unit muteInternal(Boolean mute)
-
getVolume
abstract Float getVolume()
Returns the audio volume, with 0 being silence and 1.
- Returns:
The linear gain applied to all audio channels.
-
setVolume
@Deprecated(message = "Typically mute is used to control the volume") Unit setVolume(Float volume)
Sets the player volume.
- Parameters:
volume- 0 being silence and 1 being full volume.
-
addPlayerListener
abstract Unit addPlayerListener(VideoPlayer.PlayerListener listener)
Registers a listener to receive all events from the player.
- Parameters:
listener- the listener to register.
-
removePlayerListener
abstract Unit removePlayerListener(VideoPlayer.PlayerListener listener)
Unregister a listener registered through addPlayerListener. The listener will no longer receive events.
-
create
final static VideoPlayer create(Context context)
create a VideoPlayer instance.
-
-
-
-