You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/windows/WindowsVideoPlayerState.kt
+49-54Lines changed: 49 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -263,6 +263,11 @@ class WindowsVideoPlayerState : VideoPlayerState {
263
263
privatevar skiaBitmapWidth:Int=0
264
264
privatevar skiaBitmapHeight:Int=0
265
265
266
+
// Adaptive frame interval (ms) based on the video's native frame rate.
267
+
// Mirrors macOS approach: poll at the video frame rate, not faster.
268
+
// This prevents starving the audio thread on the shared SourceReader.
269
+
privatevar frameIntervalMs:Long=16L// Default ~60fps, updated after open
270
+
266
271
// Variable to store the last opened URI
267
272
privatevar lastUri:String?=null
268
273
@@ -292,65 +297,43 @@ class WindowsVideoPlayerState : VideoPlayerState {
292
297
return// Already disposing
293
298
}
294
299
295
-
// Cancel the scope immediately to stop all coroutines
296
-
scope.cancel()
297
-
298
-
// Use runBlocking to ensure resources are cleaned up synchronously
299
-
runBlocking {
300
-
try {
301
-
// Cancel all jobs with immediate effect
302
-
videoJob?.cancel()
303
-
resizeJob?.cancel()
304
-
305
-
// Wait a bit for coroutines to cancel
306
-
delay(50)
307
-
308
-
mediaOperationMutex.withLock {
309
-
// Stop playing if active
310
-
_isPlaying=false
311
-
val instance = videoPlayerInstance
312
-
if (instance !=0L) {
313
-
try {
314
-
// Stop playback before releasing resources
315
-
val hr = player.SetPlaybackState(instance, false, true)
0 commit comments