-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements on ExoPlayer audio navigator (#542)
- Loading branch information
Showing
13 changed files
with
222 additions
and
115 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
.../audio/src/main/java/org/readium/adapter/exoplayer/audio/DefaultExoPlayerCacheProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.readium.adapter.exoplayer.audio | ||
|
||
import androidx.annotation.OptIn | ||
import androidx.media3.common.util.UnstableApi | ||
import androidx.media3.datasource.cache.Cache | ||
import org.readium.r2.shared.DelicateReadiumApi | ||
import org.readium.r2.shared.publication.Publication | ||
import org.readium.r2.shared.util.Url | ||
|
||
/** | ||
* Uses the given cache only for remote publications and URLs resolved against the | ||
* publication base URL as cache keys. | ||
*/ | ||
@OptIn(UnstableApi::class) | ||
public class DefaultExoPlayerCacheProvider( | ||
private val cache: Cache | ||
) : ExoPlayerCacheProvider { | ||
|
||
@kotlin.OptIn(DelicateReadiumApi::class) | ||
override fun getCache(publication: Publication): Cache? = | ||
cache.takeUnless { publication.baseUrl == null } | ||
|
||
override fun computeKey(publication: Publication, url: Url): String = | ||
(publication.baseUrl?.resolve(url) ?: url).normalize().toString() | ||
} |
11 changes: 0 additions & 11 deletions
11
...o/src/main/java/org/readium/adapter/exoplayer/audio/DefaultExoPlayerDataSourceProvider.kt
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...oplayer/audio/src/main/java/org/readium/adapter/exoplayer/audio/ExoPlayerCacheProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.readium.adapter.exoplayer.audio | ||
|
||
import androidx.annotation.OptIn | ||
import androidx.media3.common.util.UnstableApi | ||
import androidx.media3.datasource.cache.Cache | ||
import org.readium.r2.shared.publication.Publication | ||
import org.readium.r2.shared.util.Url | ||
|
||
/** | ||
* To be implemented to provide ExoPlayer with caching ability. | ||
*/ | ||
@OptIn(UnstableApi::class) | ||
public interface ExoPlayerCacheProvider { | ||
|
||
/** | ||
* Returns the cache to use or null if caching is not necessary with the given publication. | ||
*/ | ||
public fun getCache(publication: Publication): Cache? | ||
|
||
/** | ||
* Computes a unique cache key for the resource of [publication] at [url] . It can be an | ||
* absolute URL or a mix of [url] with some publication identifier. | ||
*/ | ||
public fun computeKey(publication: Publication, url: Url): String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
...er/audio/src/main/java/org/readium/adapter/exoplayer/audio/ExoPlayerDataSourceProvider.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.