-
Notifications
You must be signed in to change notification settings - Fork 0
feat(lecteur): régler la vitesse, et la retrouver au lancement suivant #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c0133d2
feat(lecteur): régler la vitesse, et la retrouver au lancement suivant
InstaZDLL 51f9620
fix(lecteur): tenir la vitesse quand le disque, ou la liste, se dérobe
InstaZDLL 9c3d279
fix(reglages): le thème non plus n'emporte l'application quand le dis…
InstaZDLL b6ada7f
fix(preferences): une clé au mauvais type ne doit pas emporter l'appl…
InstaZDLL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,80 @@ | ||
| package app.waveflow.model | ||
|
|
||
| /** | ||
| * La vitesse de lecture, et ce qui la tient dans des limites raisonnables. | ||
| * | ||
| * Un nombre et non une énumération comme [ThemeChoice] : la vitesse est une | ||
| * grandeur continue, pas un choix parmi des noms. En faire un jeu de constantes | ||
| * obligerait à baptiser chaque palier, et interdirait d'ajouter un réglage plus | ||
| * fin sans réécrire ce qui est déjà sur le disque. [PROPOSEES] dit ce que | ||
| * l'interface offre aujourd'hui ; le format persisté, lui, ne s'y limite pas. | ||
| */ | ||
| object PlaybackSpeed { | ||
|
|
||
| /** La vitesse d'origine, celle du disque tel qu'il a été gravé. */ | ||
| const val NORMALE = 1f | ||
|
|
||
| /** | ||
| * Les bornes du réglage. | ||
| * | ||
| * En dessous de la moitié, l'étirement temporel de Media3 rend une bouillie | ||
| * plutôt qu'un ralenti ; au-delà du double, plus personne ne suit une | ||
| * parole, et la musique n'y survit pas du tout. | ||
| */ | ||
| const val MIN = 0.5f | ||
| const val MAX = 2f | ||
|
|
||
| /** | ||
| * Ce que la feuille de réglage propose. | ||
| * | ||
| * Des quarts entre l'unité et le double, là où se joue l'écoute d'une | ||
| * parole ; la moitié et les trois quarts en dessous, utiles pour repiquer | ||
| * un passage à l'instrument. Un pas plus fin ajouterait des lignes sans | ||
| * ajouter de choix : personne ne distingue ×1,4 de ×1,45. | ||
| */ | ||
| val PROPOSEES = listOf(0.5f, 0.75f, 1f, 1.25f, 1.5f, 1.75f, 2f) | ||
|
|
||
| /** | ||
| * Ramène [speed] dans les bornes, et rend [NORMALE] de ce qui n'est pas un | ||
| * nombre. | ||
| * | ||
| * Ce n'est pas une précaution de style : la valeur vient du disque, donc | ||
| * potentiellement d'une version future qui aurait élargi les bornes, ou | ||
| * d'un fichier abîmé. Une vitesse nulle figerait la lecture sans rien dire, | ||
| * et un `NaN` — que `coerceIn` laisse passer tel quel — ferait lever Media3 | ||
| * au moment de l'appliquer, loin de l'endroit où il a été lu. | ||
| */ | ||
| fun borner(speed: Float): Float = | ||
| if (speed.isFinite()) speed.coerceIn(MIN, MAX) else NORMALE | ||
|
|
||
| /** | ||
| * La vitesse telle qu'elle s'écrit : « ×1 », « ×1,5 », « ×0,75 ». | ||
| * | ||
| * Formatée à la main plutôt qu'avec `String.format` : celui-ci suit la | ||
| * locale de l'appareil, qui décide aussi bien du séparateur décimal que du | ||
| * jeu de chiffres. L'interface est en français, la virgule y est donc | ||
| * constante — et les chiffres doivent le rester. | ||
| * | ||
| * Les zéros inutiles tombent : « ×1 » et non « ×1,00 », qui suggérerait une | ||
| * précision que le réglage n'offre pas. | ||
| */ | ||
| fun format(speed: Float): String { | ||
| val centiemes = Math.round(borner(speed) * CENTIEMES) | ||
| val entier = centiemes / CENTIEMES | ||
| val reste = centiemes % CENTIEMES | ||
|
|
||
| val decimales = when { | ||
| reste == 0 -> "" | ||
| // ×1,50 s'écrit « ×1,5 » : le zéro final ne dit rien de plus. | ||
| reste % DIXIEMES == 0 -> ",${reste / DIXIEMES}" | ||
| // ×1,05 garde le sien, sans quoi il se lirait « ×1,5 ». | ||
| reste < DIXIEMES -> ",0$reste" | ||
| else -> ",$reste" | ||
| } | ||
|
|
||
| return "×$entier$decimales" | ||
| } | ||
|
|
||
| private const val CENTIEMES = 100 | ||
| private const val DIXIEMES = 10 | ||
| } |
This file contains hidden or 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
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🤖 get_repo_knowledge executed:
get_repo_knowledge InstaZDLL/waveflow-android /tmp/coderabbit-repo-knowledge/instazdll-waveflow-android-a2e39a6a/conventionsLength of output: 5118
🏁 Script executed:
Repository: InstaZDLL/waveflow-android
Length of output: 740
🏁 Script executed:
Repository: InstaZDLL/waveflow-android
Length of output: 50383
🏁 Script executed:
Repository: InstaZDLL/waveflow-android
Length of output: 22891
🏁 Script executed:
Repository: InstaZDLL/waveflow-android
Length of output: 40044
Garantir la vitesse avant la première lecture Media3.
observePlaybackSpeedcollectePreferencesStore.preferencesdans une coroutine après la création deMediaLibrarySession. La première émission deDataStorepeut être suspendue.Media3PlaybackControllerpeut alors exécuterprepare()puisplay()avantplayer.setPlaybackSpeed(...). Si la vitesse enregistrée diffère de×1, la lecture peut commencer temporairement à×1.Ajoutez un test de démarrage à froid qui retarde la première émission de
PreferencesStore, envoie immédiatement une commande de lecture, puis vérifie la vitesse avant le rendu. Si le test échoue, retardez l’acceptation de la première lecture jusqu’à l’application de la préférence, sans bloquer le thread principal.🤖 Prompt for AI Agents