refactor: improve player accessibility
This commit is contained in:
+11
-5
@@ -138,13 +138,16 @@ internal class PlaybackRepositoryImpl(
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun load(record: Record) {
|
||||
override suspend fun load(
|
||||
record: Record,
|
||||
autoPlay: Boolean,
|
||||
) {
|
||||
phraseBreakJob?.cancel()
|
||||
cancelRunningBreak()
|
||||
pendingPhraseStart = null
|
||||
pendingSeekTarget = null
|
||||
|
||||
playAudio(filePath = record.audioResourcePath)
|
||||
loadAudio(filePath = record.audioResourcePath, autoPlay = autoPlay)
|
||||
subtitle.value = loadSubtitle(record = record)
|
||||
reachedPhraseIndex = upcomingPhraseIndex(position = Duration.ZERO)
|
||||
recordTitle.value = record.title
|
||||
@@ -264,12 +267,15 @@ internal class PlaybackRepositoryImpl(
|
||||
audioPlayer.seekTo(position)
|
||||
}
|
||||
|
||||
private fun playAudio(filePath: String) {
|
||||
private fun loadAudio(
|
||||
filePath: String,
|
||||
autoPlay: Boolean,
|
||||
) {
|
||||
try {
|
||||
audioPlayer.load(uri = resourceReader.uri(filePath))
|
||||
audioPlayer.play()
|
||||
if (autoPlay) audioPlayer.play()
|
||||
} catch (exception: Exception) {
|
||||
logger.error(message = "Failed to play audio: $filePath", throwable = exception)
|
||||
logger.error(message = "Failed to load audio: $filePath", throwable = exception)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -15,7 +15,10 @@ import kotlin.time.Duration
|
||||
interface PlaybackRepository {
|
||||
val playerState: Flow<PlayerState>
|
||||
|
||||
suspend fun load(record: Record)
|
||||
suspend fun load(
|
||||
record: Record,
|
||||
autoPlay: Boolean = true,
|
||||
)
|
||||
|
||||
suspend fun play()
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
<string name="subtitle_preferences_title">Sous-titres</string>
|
||||
<string name="subtitle_preferences_action">Préférences de sous-titrage</string>
|
||||
<string name="settings_open_action_description">accéder aux paramètres</string>
|
||||
<string name="subtitle_transcription_label">Transcription (BZH)</string>
|
||||
<string name="subtitle_transcription_description">Afficher la transcription bretonne</string>
|
||||
<string name="subtitle_translation_label">Traduction (FR)</string>
|
||||
@@ -48,6 +49,7 @@
|
||||
<string name="records_chapter_number">Chapitre %1$d</string>
|
||||
|
||||
<string name="player_back">Retour</string>
|
||||
<string name="player_back_action_label">revenir à la liste des contenus</string>
|
||||
<string name="player_previous_sentence">Phrase précédente</string>
|
||||
<string name="player_next_sentence">Phrase suivante</string>
|
||||
<string name="player_play">Lire</string>
|
||||
|
||||
Reference in New Issue
Block a user