//readium-navigator-media2/org.readium.navigator.media2/MediaNavigator
MediaNavigator¶
[androidJvm]\ class MediaNavigator : Navigator
An audiobook navigator to connect to a MediaSession from Jetpack Media2.
Use create to get an instance for a given publication, and build a session from it with the session method. Apps are responsible for attaching this session to a service able to expose it.
You can build a MediaNavigator upon any Media2 SessionPlayer implementation providing create with it. If you don't, ExoPlayer will be used, without cache. You can build your own SessionPlayer based on ExoPlayer using ExoPlayerDataSource.
Types¶
| Name | Summary |
|---|---|
| Companion | [androidJvm] object Companion |
| Configuration | [androidJvm] data class Configuration(val positionRefreshRate: Double = 2.0, val skipForwardInterval: Duration = 30.seconds, val skipBackwardInterval: Duration = 30.seconds) |
| Exception | [androidJvm] sealed class Exception : Exception |
| Playback | [androidJvm] @ExperimentalTime data class Playback(val state: MediaNavigator.Playback.State, val rate: Double, val resource: MediaNavigator.Playback.Resource, val buffer: MediaNavigator.Playback.Buffer) |
Functions¶
| Name | Summary |
|---|---|
| close | [androidJvm] fun close() Stops the playback. |
| go | [androidJvm] suspend fun go(link: Link): Try<Unit, MediaNavigator.Exception> Seeks to the beginning of the given link. [androidJvm] suspend fun go(locator: Locator): Try<Unit, MediaNavigator.Exception> Seeks to the given locator. [androidJvm] open override fun go(link: Link, animated: Boolean, completion: () -> Unit): Boolean open override fun go(locator: Locator, animated: Boolean, completion: () -> Unit): Boolean |
| goBackward | [androidJvm] suspend fun goBackward(): Try<Unit, MediaNavigator.Exception> Skips to a little amount of time before. [androidJvm] open override fun goBackward(animated: Boolean, completion: () -> Unit): Boolean |
| goForward | [androidJvm] suspend fun goForward(): Try<Unit, MediaNavigator.Exception> Skips to a little amount of time later. [androidJvm] open override fun goForward(animated: Boolean, completion: () -> Unit): Boolean |
| pause | [androidJvm] suspend fun pause(): Try<Unit, MediaNavigator.Exception> Pauses the playback. |
| play | [androidJvm] suspend fun play(): Try<Unit, MediaNavigator.Exception> Resumes or start the playback at the current location. |
| seek | [androidJvm] suspend fun seek(index: Int, position: Duration): Try<Unit, MediaNavigator.Exception> Seeks to the given time at the given resource. |
| session | [androidJvm] fun session(context: Context, activityIntent: PendingIntent, id: String? = null): MediaSession Builds a MediaSession for this navigator. |
| setPlaybackRate | [androidJvm] suspend fun setPlaybackRate(rate: Double): Try<Unit, MediaNavigator.Exception> Sets the speed of the media playback. |
Properties¶
| Name | Summary |
|---|---|
| currentLocation | [androidJvm] open val ~~currentLocation~~: Locator? |
| currentLocator | [androidJvm] open override val currentLocator: StateFlow<Locator> |
| playback | [androidJvm] val playback: StateFlow<MediaNavigator.Playback> Indicates the navigator current state. |
| publication | [androidJvm] open override val publication: Publication |