Skip to content

Commit 091f9ac

Browse files
authored
Deprecate media1 and media2 navigators (#512)
1 parent 0f23b6b commit 091f9ac

31 files changed

+41
-137
lines changed

readium/navigator-media2/src/main/java/org/readium/navigator/media2/DefaultMetadataFactory.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import org.readium.r2.shared.publication.Publication
1212
import org.readium.r2.shared.publication.services.cover
1313

1414
@Suppress("DEPRECATION")
15-
@ExperimentalMedia2
1615
internal class DefaultMetadataFactory(private val publication: Publication) : MediaMetadataFactory {
1716

1817
private val coroutineScope =

readium/navigator-media2/src/main/java/org/readium/navigator/media2/ExoPlayerDataSource.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import com.google.android.exoplayer2.upstream.DataSpec
1818
import com.google.android.exoplayer2.upstream.TransferListener
1919
import java.io.IOException
2020
import kotlinx.coroutines.runBlocking
21+
import org.readium.r2.shared.InternalReadiumApi
2122
import org.readium.r2.shared.publication.Publication
2223
import org.readium.r2.shared.util.data.ReadException
2324
import org.readium.r2.shared.util.getOrThrow
2425
import org.readium.r2.shared.util.resource.Resource
2526
import org.readium.r2.shared.util.resource.buffered
2627
import org.readium.r2.shared.util.toUrl
2728

29+
@InternalReadiumApi
2830
public sealed class ExoPlayerDataSourceException(message: String, cause: Throwable?) : IOException(
2931
message,
3032
cause
@@ -40,6 +42,7 @@ public sealed class ExoPlayerDataSourceException(message: String, cause: Throwab
4042
/**
4143
* An ExoPlayer's [DataSource] which retrieves resources from a [Publication].
4244
*/
45+
@InternalReadiumApi
4346
public class ExoPlayerDataSource internal constructor(private val publication: Publication) : BaseDataSource(/* isNetwork = */
4447
true
4548
) {

readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaMetadataFactory.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
package org.readium.navigator.media2
44

55
import androidx.media2.common.MediaMetadata
6+
import org.readium.r2.shared.InternalReadiumApi
67

78
/**
89
* Factory for the [MediaMetadata] associated with the publication and its resources.
910
*
1011
* The metadata are used for example in the media-style Android notification.
1112
*/
1213
@Deprecated("Use the new MediaMetadataFactory from the readium-navigator-media-common module.")
14+
@InternalReadiumApi
1315
public interface MediaMetadataFactory {
1416

1517
/**

readium/navigator-media2/src/main/java/org/readium/navigator/media2/MediaNavigator.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.readium.navigator.media2.MediaNavigator.Companion.create
3636
import org.readium.r2.navigator.Navigator
3737
import org.readium.r2.navigator.extensions.normalizeLocator
3838
import org.readium.r2.shared.DelicateReadiumApi
39+
import org.readium.r2.shared.InternalReadiumApi
3940
import org.readium.r2.shared.publication.Link
4041
import org.readium.r2.shared.publication.Locator
4142
import org.readium.r2.shared.publication.Publication
@@ -55,8 +56,10 @@ import timber.log.Timber
5556
* providing [create] with it. If you don't, ExoPlayer will be used, without cache.
5657
* You can build your own [SessionPlayer] based on [ExoPlayer] using [ExoPlayerDataSource].
5758
*/
58-
@ExperimentalMedia2
59-
@Deprecated("Use the new AudioNavigator from the readium-navigator-media-audio module.")
59+
@Deprecated(
60+
"Use the new AudioNavigator from the readium-navigator-media-audio module. This class will be removed in a future 3.x release."
61+
)
62+
@InternalReadiumApi
6063
@OptIn(ExperimentalTime::class)
6164
public class MediaNavigator private constructor(
6265
public val publication: Publication,
@@ -393,7 +396,6 @@ public class MediaNavigator private constructor(
393396
return true
394397
}
395398

396-
@ExperimentalMedia2
397399
public companion object {
398400

399401
public suspend fun create(

readium/navigator-media2/src/main/java/org/readium/navigator/media2/OptIn.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.

readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerCallback.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ import androidx.media2.common.MediaItem
1212
import androidx.media2.common.MediaMetadata
1313
import androidx.media2.common.SessionPlayer
1414
import kotlin.time.Duration
15-
import kotlin.time.ExperimentalTime
1615
import kotlinx.coroutines.*
1716
import kotlinx.coroutines.channels.SendChannel
1817
import kotlinx.coroutines.flow.MutableStateFlow
1918
import kotlinx.coroutines.flow.StateFlow
2019
import timber.log.Timber
2120

22-
@OptIn(ExperimentalTime::class)
2321
internal class SessionPlayerCallback(
2422
private val positionRefreshDelay: Duration,
2523
private val seekCompletedSender: SendChannel<Long>

readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerFacade.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import kotlin.coroutines.resume
2020
import kotlin.coroutines.suspendCoroutine
2121
import kotlin.time.Duration
2222
import kotlin.time.Duration.Companion.milliseconds
23-
import kotlin.time.ExperimentalTime
2423
import kotlinx.coroutines.MainScope
2524
import kotlinx.coroutines.TimeoutCancellationException
2625
import kotlinx.coroutines.channels.ReceiveChannel
@@ -42,7 +41,6 @@ import timber.log.Timber
4241
* - in case of failure, the playback can be left in an intermediate state
4342
* - the behaviour is undefined if any external controller takes actions at the same time
4443
*/
45-
@OptIn(ExperimentalTime::class)
4644
internal class SessionPlayerFacade(
4745
private val sessionPlayer: SessionPlayer,
4846
private val seekCompletedReceiver: ReceiveChannel<Long>,

readium/navigator-media2/src/main/java/org/readium/navigator/media2/SessionPlayerHelpers.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,39 +137,32 @@ internal val SessionPlayer.playbackSpeedNullable
137137
internal val SessionPlayer.currentIndexNullable
138138
get() = currentMediaItemIndex.takeUnless { it == SessionPlayer.INVALID_ITEM_INDEX }
139139

140-
@ExperimentalTime
141140
internal val SessionPlayer.currentPositionDuration: Duration?
142141
get() = msToDuration(currentPosition)
143142

144-
@ExperimentalTime
145143
internal val SessionPlayer.bufferedPositionDuration: Duration?
146144
get() = msToDuration(bufferedPosition)
147145

148-
@ExperimentalTime
149146
internal val SessionPlayer.currentDuration: Duration?
150147
get() = msToDuration(duration)
151148

152-
@ExperimentalTime
153149
private fun msToDuration(ms: Long): Duration? =
154150
if (ms == SessionPlayer.UNKNOWN_TIME) {
155151
null
156152
} else {
157153
ms.milliseconds
158154
}
159155

160-
@ExperimentalTime
161156
internal val MediaMetadata.duration: Duration?
162157
get() = getLong(MediaMetadata.METADATA_KEY_DURATION)
163158
.takeUnless { it == 0L }
164159
?.milliseconds
165160

166-
@ExperimentalTime
167161
internal val List<MediaMetadata>.durations: List<Duration>?
168162
get() {
169163
val durations = mapNotNull { it.duration }
170164
return durations.takeIf { it.size == this.size }
171165
}
172166

173-
@ExperimentalTime
174167
internal val List<MediaItem>.metadata: List<MediaMetadata>
175168
get() = map { it.metadata!! }

readium/navigator-media2/src/main/java/org/readium/navigator/media2/SmartSeeker.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
package org.readium.navigator.media2
88

99
import kotlin.time.Duration
10-
import kotlin.time.ExperimentalTime
1110

1211
/**
1312
* Computes relative seeks across playlist items.
1413
*/
15-
@ExperimentalTime
1614
internal object SmartSeeker {
1715

1816
data class Result(val index: Int, val position: Duration)

readium/navigator/src/main/java/org/readium/r2/navigator/DecorableNavigator.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import org.readium.r2.shared.util.Url
2626
/**
2727
* A navigator able to render arbitrary decorations over a publication.
2828
*/
29-
@ExperimentalDecorator
3029
public interface DecorableNavigator : Navigator {
3130
/**
3231
* Declares the current state of the decorations in the given decoration [group].
@@ -98,7 +97,6 @@ public interface DecorableNavigator : Navigator {
9897
* @param extras Additional context data specific to a reading app. Readium does not use it.
9998
*/
10099
@Parcelize
101-
@ExperimentalDecorator
102100
public data class Decoration(
103101
val id: DecorationId,
104102
val locator: Locator,
@@ -145,11 +143,9 @@ public data class Decoration(
145143
}
146144

147145
/** Unique identifier for a decoration. */
148-
@ExperimentalDecorator
149146
public typealias DecorationId = String
150147

151148
/** Represents an atomic change in a list of [Decoration] objects. */
152-
@ExperimentalDecorator
153149
public sealed class DecorationChange {
154150
public data class Added(val decoration: Decoration) : DecorationChange()
155151
public data class Updated(val decoration: Decoration) : DecorationChange()
@@ -162,7 +158,6 @@ public sealed class DecorationChange {
162158
*
163159
* The changes need to be applied in the same order, one by one.
164160
*/
165-
@ExperimentalDecorator
166161
public suspend fun List<Decoration>.changesByHref(target: List<Decoration>): Map<Url, List<DecorationChange>> = withContext(
167162
Dispatchers.Default
168163
) {

0 commit comments

Comments
 (0)