Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ internal class TtsSessionAdapter<E : TtsEngine.Error>(
COMMAND_SET_SPEED_AND_PITCH,
COMMAND_GET_CURRENT_MEDIA_ITEM,
COMMAND_GET_METADATA,
COMMAND_GET_TEXT
COMMAND_GET_TEXT,
COMMAND_GET_TIMELINE
).build()

override fun getApplicationLooper(): Looper {
Expand Down Expand Up @@ -457,11 +458,16 @@ internal class TtsSessionAdapter<E : TtsEngine.Error>(

override fun getCurrentTimeline(): Timeline {
// MediaNotificationManager requires a non-empty timeline to start foreground playing.
return TtsTimeline(mediaItems)
// Report a single-item timeline in order to show a notification, but without skip buttons.
return if (mediaItems.isNotEmpty()) {
TtsTimeline(listOf(mediaItems[currentMediaItemIndex]))
} else {
TtsTimeline(emptyList())
}
}

override fun getCurrentPeriodIndex(): Int {
return ttsPlayer.utterance.value.position.resourceIndex
return 0
}

@Deprecated("Deprecated in Java", ReplaceWith("currentMediaItemIndex"))
Expand All @@ -470,7 +476,8 @@ internal class TtsSessionAdapter<E : TtsEngine.Error>(
}

override fun getCurrentMediaItemIndex(): Int {
return ttsPlayer.utterance.value.position.resourceIndex
// Reporting a single-item timeline, so index is always 0.
return 0
}

@Deprecated("Deprecated in Java", ReplaceWith("nextMediaItemIndex"))
Expand Down Expand Up @@ -575,7 +582,7 @@ internal class TtsSessionAdapter<E : TtsEngine.Error>(

override fun isCurrentMediaItemLive(): Boolean {
val timeline = currentTimeline
return !timeline.isEmpty && timeline.getWindow(currentMediaItemIndex, window).isLive()
return !timeline.isEmpty && timeline.getWindow(currentMediaItemIndex, window).isLive
}

override fun getCurrentLiveOffset(): Long {
Expand Down