Skip to content

Commit bfdc842

Browse files
committed
docs(comments): translate French comments to English
1 parent 95b5a1e commit bfdc842

6 files changed

Lines changed: 58 additions & 58 deletions

File tree

mediaplayer/src/androidMain/kotlin/io/github/kdroidfilter/composemediaplayer/VideoPlayerState.android.kt

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ open class DefaultVideoPlayerState(
102102
private var updateJob: Job? = null
103103
private val coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob())
104104

105-
// Protection contre les race conditions
105+
// Protection against race conditions
106106
private var isPlayerReleased = false
107107
private val playerInitializationLock = Object()
108108
private var playerListener: Player.Listener? = null
@@ -185,7 +185,7 @@ open class DefaultVideoPlayerState(
185185

186186
internal fun attachPlayerView(view: PlayerView?) {
187187
if (view == null) {
188-
// Détacher la vue actuelle
188+
// Detach the current view
189189
playerView?.player = null
190190
playerView = null
191191
return
@@ -289,12 +289,12 @@ open class DefaultVideoPlayerState(
289289
val manufacturer = android.os.Build.MANUFACTURER
290290
val model = android.os.Build.MODEL
291291

292-
// Liste des appareils connus pour avoir des problèmes MediaCodec
292+
// List of devices known to have MediaCodec issues
293293
val problematicDevices =
294294
setOf(
295295
"SM-A155F", // Galaxy A15
296296
"SM-A156B", // Galaxy A15 5G
297-
// Ajouter d'autres modèles problématiques ici
297+
// Add other problematic models here
298298
)
299299

300300
return device in problematicDevices ||
@@ -333,7 +333,7 @@ open class DefaultVideoPlayerState(
333333
synchronized(playerInitializationLock) {
334334
if (!isPlayerReleased && wasPlayingBeforeScreenLock && exoPlayer != null) {
335335
try {
336-
// Ajouter un petit délai pour s'assurer que le système est prêt
336+
// Add a small delay to ensure the system is ready
337337
coroutineScope.launch {
338338
delay(200)
339339
if (!isPlayerReleased) {
@@ -390,13 +390,13 @@ open class DefaultVideoPlayerState(
390390
): AudioSink = audioSink
391391
}.apply {
392392
setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER)
393-
// Activer le fallback du décodeur pour une meilleure stabilité
393+
// Enable decoder fallback for better stability
394394
setEnableDecoderFallback(true)
395395

396-
// Sur les appareils problématiques, utiliser des paramètres plus conservateurs
396+
// On problematic devices, use more conservative settings
397397
if (shouldUseConservativeCodecHandling()) {
398-
// On ne peut pas désactiver l'async queueing car la méthode n'existe pas
399-
// Mais on peut utiliser le MediaCodecSelector par défaut
398+
// Cannot disable async queueing as the method does not exist
399+
// But we can use the default MediaCodecSelector
400400
setMediaCodecSelector(MediaCodecSelector.DEFAULT)
401401
}
402402
}
@@ -417,7 +417,7 @@ open class DefaultVideoPlayerState(
417417
.setWakeMode(if (manageFocus) C.WAKE_MODE_LOCAL else C.WAKE_MODE_NONE)
418418
.setAudioAttributes(audioAttributes, manageFocus)
419419
.setPauseAtEndOfMediaItems(false)
420-
.setReleaseTimeoutMs(2000) // Augmenter le timeout de libération
420+
.setReleaseTimeoutMs(2000) // Increase the release timeout
421421
.build()
422422
.apply {
423423
playerListener = createPlayerListener()
@@ -430,7 +430,7 @@ open class DefaultVideoPlayerState(
430430
private fun createPlayerListener() =
431431
object : Player.Listener {
432432
override fun onPlaybackStateChanged(playbackState: Int) {
433-
// Ajouter une vérification de sécurité
433+
// Add a safety check
434434
if (isPlayerReleased) return
435435

436436
when (playbackState) {
@@ -484,7 +484,7 @@ open class DefaultVideoPlayerState(
484484
override fun onPlayerError(error: PlaybackException) {
485485
androidVideoLogger.e { "Player error occurred: ${error.errorCode} - ${error.message}" }
486486

487-
// Créer un rapport d'erreur détaillé
487+
// Create a detailed error report
488488
val errorDetails =
489489
mapOf(
490490
"error_code" to error.errorCode.toString(),
@@ -501,13 +501,13 @@ open class DefaultVideoPlayerState(
501501
// Log the error details (you can send this to your crash reporting service)
502502
androidVideoLogger.e { "Detailed error info: $errorDetails" }
503503

504-
// Gestion des erreurs spécifiques au codec
504+
// Codec-specific error handling
505505
when (error.errorCode) {
506506
PlaybackException.ERROR_CODE_DECODER_INIT_FAILED,
507507
PlaybackException.ERROR_CODE_DECODER_QUERY_FAILED,
508508
-> {
509509
_error = VideoPlayerError.CodecError("Decoder error: ${error.message}")
510-
// Tenter une récupération pour les erreurs de codec
510+
// Attempt recovery for codec errors
511511
attemptPlayerRecovery()
512512
}
513513
PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED,
@@ -531,7 +531,7 @@ open class DefaultVideoPlayerState(
531531

532532
private fun attemptPlayerRecovery() {
533533
coroutineScope.launch {
534-
delay(100) // Petit délai pour laisser le système nettoyer
534+
delay(100) // Small delay to let the system clean up
535535

536536
synchronized(playerInitializationLock) {
537537
if (!isPlayerReleased) {
@@ -541,22 +541,22 @@ open class DefaultVideoPlayerState(
541541
val wasPlaying = player.isPlaying
542542

543543
try {
544-
// Retirer le listener avant de libérer
544+
// Remove the listener before releasing
545545
playerListener?.let { player.removeListener(it) }
546546

547-
// Libérer le lecteur actuel
547+
// Release the current player
548548
player.release()
549549

550-
// Réinitialiser
550+
// Reinitialize
551551
initializePlayer()
552552

553-
// Restaurer l'élément média et la position
553+
// Restore the media item and position
554554
currentMediaItem?.let {
555555
exoPlayer?.apply {
556556
setMediaItem(it)
557557
prepare()
558558
seekTo(currentPosition)
559-
// Restaurer l'état de lecture si nécessaire
559+
// Restore the playback state if needed
560560
if (wasPlaying) {
561561
play()
562562
} else {
@@ -635,15 +635,15 @@ open class DefaultVideoPlayerState(
635635
_error = null
636636
resetStates(keepMedia = true)
637637

638-
// Extraire les métadonnées avant de préparer le lecteur
638+
// Extract metadata before preparing the player
639639
extractMediaItemMetadata(mediaItem)
640640

641641
player.setMediaItem(mediaItem)
642642
player.prepare()
643643
player.volume = volume
644644
player.repeatMode = if (loop) Player.REPEAT_MODE_ALL else Player.REPEAT_MODE_OFF
645645

646-
// Contrôler l'état de lecture initial
646+
// Control the initial playback state
647647
if (initializeplayerState == InitialPlayerState.PLAY) {
648648
player.play()
649649
_hasMedia = true
@@ -832,7 +832,7 @@ open class DefaultVideoPlayerState(
832832

833833
try {
834834
exoPlayer?.let { player ->
835-
// Retirer le listener spécifiquement
835+
// Remove the listener specifically
836836
playerListener?.let { listener ->
837837
player.removeListener(listener)
838838
}

mediaplayer/src/androidMain/kotlin/io/github/kdroidfilter/composemediaplayer/VideoPlayerSurface.android.kt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private fun VideoPlayerSurfaceInternal(
106106
DisposableEffect(playerState) {
107107
onDispose {
108108
try {
109-
// Détacher la vue du player
109+
// Detach the view from the player
110110
if (playerState is DefaultVideoPlayerState) {
111111
playerState.attachPlayerView(null)
112112
}
@@ -173,15 +173,15 @@ private fun VideoPlayerContent(
173173
),
174174
factory = { context ->
175175
try {
176-
// Créer PlayerView avec le type de surface approprié
176+
// Create PlayerView with the appropriate surface type
177177

178178
createPlayerViewWithSurfaceType(context, surfaceType).apply {
179179
if (playerState is DefaultVideoPlayerState) {
180-
// Attacher cette vue à l'état du lecteur
180+
// Attach this view to the player state
181181
playerState.attachPlayerView(this)
182182

183183
if (playerState.exoPlayer != null) {
184-
// Attacher le lecteur depuis l'état
184+
// Attach the player from the state
185185
player = playerState.exoPlayer
186186
}
187187
}
@@ -191,28 +191,28 @@ private fun VideoPlayerContent(
191191
setShutterBackgroundColor(android.graphics.Color.TRANSPARENT)
192192
setBackgroundColor(android.graphics.Color.TRANSPARENT)
193193

194-
// Mapper ContentScale vers les modes de redimensionnement ExoPlayer
194+
// Map ContentScale to ExoPlayer resize modes
195195
resizeMode = mapContentScaleToResizeMode(contentScale)
196196

197-
// Désactiver la vue de sous-titres native car nous utilisons des sous-titres basés sur Compose
197+
// Disable the native subtitle view since we use Compose-based subtitles
198198
subtitleView?.visibility = android.view.View.GONE
199199
}
200200
} catch (e: Exception) {
201201
androidVideoLogger.e { "Error creating PlayerView: ${e.message}" }
202-
// Retourner une vue vide en cas d'erreur
202+
// Return an empty view in case of error
203203
PlayerView(context).apply {
204204
setBackgroundColor(android.graphics.Color.BLACK)
205205
}
206206
}
207207
},
208208
update = { playerView ->
209209
try {
210-
// Vérifier que le player est toujours valide avant la mise à jour
210+
// Verify that the player is still valid before updating
211211
if (playerState is DefaultVideoPlayerState &&
212212
playerState.exoPlayer != null &&
213213
playerView.player != null
214214
) {
215-
// Mettre à jour le mode de redimensionnement lorsque contentScale change
215+
// Update the resize mode when contentScale changes
216216
playerView.resizeMode = mapContentScaleToResizeMode(contentScale)
217217
}
218218
} catch (e: Exception) {
@@ -221,7 +221,7 @@ private fun VideoPlayerContent(
221221
},
222222
onReset = { playerView ->
223223
try {
224-
// Nettoyer les ressources lorsque la vue est recyclée dans une LazyList
224+
// Clean up resources when the view is recycled in a LazyList
225225
playerView.player = null
226226
playerView.onPause()
227227
} catch (e: Exception) {
@@ -230,23 +230,23 @@ private fun VideoPlayerContent(
230230
},
231231
onRelease = { playerView ->
232232
try {
233-
// Nettoyer complètement la vue lors de sa libération
233+
// Fully clean up the view on release
234234
playerView.player = null
235235
} catch (e: Exception) {
236236
androidVideoLogger.e { "Error releasing PlayerView: ${e.message}" }
237237
}
238238
},
239239
)
240240

241-
// Ajouter une couche de sous-titres basée sur Compose
241+
// Add a Compose-based subtitle layer
242242
if (playerState.subtitlesEnabled && playerState.currentSubtitleTrack != null) {
243-
// Calculer le temps actuel en millisecondes
243+
// Calculate the current time in milliseconds
244244
val currentTimeMs =
245245
remember(playerState.sliderPos, playerState.durationText) {
246246
(playerState.sliderPos / 1000f * playerState.durationText.toTimeMs()).toLong()
247247
}
248248

249-
// Calculer la durée en millisecondes
249+
// Calculate the duration in milliseconds
250250
val durationMs =
251251
remember(playerState.durationText) {
252252
playerState.durationText.toTimeMs()
@@ -264,8 +264,8 @@ private fun VideoPlayerContent(
264264
}
265265
}
266266

267-
// Rendre le contenu de l'overlay au-dessus de la vidéo avec le modificateur fillMaxSize
268-
// pour s'assurer qu'il prend toute la hauteur du Box parent
267+
// Render the overlay content above the video with the fillMaxSize modifier
268+
// to ensure it takes the full height of the parent Box
269269
Box(modifier = Modifier.fillMaxSize()) {
270270
overlay()
271271
}
@@ -289,7 +289,7 @@ private fun createPlayerViewWithSurfaceType(
289289
surfaceType: SurfaceType,
290290
): PlayerView =
291291
try {
292-
// Essayer d'abord d'inflater les layouts personnalisés
292+
// First try to inflate the custom layouts
293293
val layoutId =
294294
when (surfaceType) {
295295
SurfaceType.SurfaceView -> R.layout.player_view_surface
@@ -300,16 +300,16 @@ private fun createPlayerViewWithSurfaceType(
300300
} catch (e: Exception) {
301301
androidVideoLogger.e { "Error inflating PlayerView layout: ${e.message}, creating programmatically" }
302302

303-
// Créer PlayerView programmatiquement pour éviter les problèmes de ressources manquantes
303+
// Create PlayerView programmatically to avoid missing resource issues
304304
try {
305305
PlayerView(context).apply {
306-
// Désactiver complètement les contrôles pour éviter l'inflation du layout des contrôles
306+
// Fully disable controls to avoid inflating the controls layout
307307
useController = false
308308

309-
// Configurer le type de surface programmatiquement
309+
// Configure the surface type programmatically
310310
when (surfaceType) {
311311
SurfaceType.TextureView -> {
312-
// Utiliser TextureView si disponible
312+
// Use TextureView if available
313313
videoSurfaceView?.let { view ->
314314
if (view is TextureView) {
315315
androidVideoLogger.d { "Using TextureView" }
@@ -318,19 +318,19 @@ private fun createPlayerViewWithSurfaceType(
318318
}
319319

320320
SurfaceType.SurfaceView -> {
321-
// SurfaceView est le défaut
321+
// SurfaceView is the default
322322
androidVideoLogger.d { "Using SurfaceView" }
323323
}
324324
}
325325

326-
// Désactiver les fonctionnalités qui pourraient causer des problèmes
326+
// Disable features that could cause issues
327327
controllerAutoShow = false
328328
controllerHideOnTouch = false
329329
setShowBuffering(PlayerView.SHOW_BUFFERING_NEVER)
330330
}
331331
} catch (e2: Exception) {
332332
androidVideoLogger.e { "Error creating PlayerView programmatically: ${e2.message}" }
333-
// Dernier recours : créer une vue vide pour éviter le crash
333+
// Last resort: create an empty view to avoid crashing
334334
throw e2
335335
}
336336
}

mediaplayer/src/iosMain/kotlin/io/github/kdroidfilter/composemediaplayer/VideoPlayerSurface.ios.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ fun VideoPlayerSurfaceImpl(
114114
when (contentScale) {
115115
ContentScale.Crop,
116116
ContentScale.FillHeight,
117-
-> AVLayerVideoGravityResizeAspectFill // ⬅️ changement
118-
ContentScale.FillWidth -> AVLayerVideoGravityResizeAspectFill // (même logique)
119-
ContentScale.FillBounds -> AVLayerVideoGravityResize // pas d’aspect-ratio
117+
-> AVLayerVideoGravityResizeAspectFill
118+
ContentScale.FillWidth -> AVLayerVideoGravityResizeAspectFill
119+
ContentScale.FillBounds -> AVLayerVideoGravityResize // no aspect-ratio
120120
ContentScale.Fit,
121121
ContentScale.Inside,
122122
-> AVLayerVideoGravityResizeAspect

mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/mac/MacVideoPlayerState.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ class MacVideoPlayerState : VideoPlayerState {
456456
if (width > 0 && height > 0) {
457457
width.toFloat() / height.toFloat()
458458
} else {
459-
// Au lieu de forcer 16f/9f, ne changez pas l’aspect si la vidéo n’est pas encore prête.
460-
// Par exemple, on peut conserver l’ancien aspect ratio :
459+
// Instead of forcing 16f/9f, don’t change the aspect if the video is not ready yet.
460+
// For example, we can keep the previous aspect ratio:
461461
_aspectRatio.value
462462
}
463463

@@ -480,7 +480,7 @@ class MacVideoPlayerState : VideoPlayerState {
480480
metadata.audioChannels = if (audioChannels == 0) null else audioChannels
481481
metadata.audioSampleRate = if (audioSampleRate == 0) null else audioSampleRate
482482

483-
// Met à jour l’aspect ratio seulement si width/height valides
483+
// Update the aspect ratio only if width/height are valid
484484
_aspectRatio.value = newAspectRatio
485485
}
486486

0 commit comments

Comments
 (0)