New Player
The default implementation of the NewPlayer interface is NewPlayerImpl.
An instance of NewPlayer will contain the business logic of the whole NewPlayer. NewPlayerImpl will therefore also contain the instance of Player.
Keep ind mind that a NewPlayer instance must live in an Application instance. Otherwise, the NewPlayer instance can not outlive an Activity or Service. NewPlayer must be able to do this though in order to
Run in background
If it's executed on a TV: Stop when the main activity is closed. (The reason the NewPlayer instance should not be hosted inside a MediaService, since on TV there should not be a playback service.)
Inheritors
Properties
Same as ExoPlayer's bufferedPercentage. See Player.getBufferedPercentage
The chapters which are available for the currently playing stream. If the current stream has no chapters the list will be empty.
All the tracks that the current item provides. The list contains the tracks of all available stream.
The currently playing MediaItem. If null no MediaItem is playing.
The index into the playlist. It points to the currently playing MediaItem.
The tracks that are currently reproduced by ExoPlayer
Same as ExoPlayer's currentPosition. See Player.getCurrentPosition
Overrides the preferredStreamLanguages and picks one specific language This value then only works for the current stream. If the stream changes this value switches back to null, and the preferredStreamLanguages are used for stream selection. This is used to pick one specific stream.
Same as ExoPlayer's duration. See Player.getDuration
The exoPlayer NewPlayer uses. Since NewPlayer might kill its exoplayer depending on the playback state, the player itself is wrapped in a StateFlow. This way the NewPlayerUI can be notified of a new ExoPlayer being created once the playback state switches away from IDLE.
Amount of seconds that should be skipped on a fast seek action.
The Icon that should be shown in the media notification.
The class of the activity that holds the NewPlayerUI.
Represents the current playlist of ExoPlayer. It is derived from ExoPlayer's Player.getCurrentTimeline, and its updated on a timeline change.
Same as ExoPlayer's playWhenReady. See Player.setPlayWhenReady
Sets the default languages the user prefers. This can be overridden per stream via currentStreamLanguageConstraint.
Same as ExoPlayer's repeatMode. See Player.getRepeatMode However, ExoPlayer's repeatMode ist based on an integer, while NewPayer defines it as an enum class.
The media repository from which media data is pulled from. This has to be provided by the user.
This callback allows to recover from errors that happened during stream playback. When this callback is called the user has a chance to recover from that error. By returning a StreamExceptionResponse the user can decide how NewPlayer should continue. The default implementation by NewPlayerImpl will always return NoResponse. This will cause the exception to be directly forwarded to errorFlow.
Same as ExoPlayer's shuffle. See Player.getShuffleModeEnabled
Functions
Adds a new item to the playlist.
Returns the Item corresponding to the MediaItem Please keep int mind that only MediaItem re supported that were created by NewPlayer itself. Otherwise the corresponding item can not be found and the function throws a NewPlayerException.
Same as ExoPlayer's movePlaylistItem. See Player.moveMediaItem
Same as ExoPlayer's Player.pause
Same as ExoPlayer's Player.play.
Same as ExoPlayer's Player.prepare.
Same as ExoPlayer's release. See Player.release In addition to releasing the /** @hide */ internal ExoPlayer, NewPlayer will also clean up other things that do not need to exist while NewPlayer is in IDLE mode. This includes the ExoPlayer instance itself.
Same as ExoPlayer's removePlaylistItem. See Player.removeMediaItem
This will seek to the chapter selected by index. If its tried to select a chapter which does not exist an out of bound exception is though.