mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
ksplayer pause fix
This commit is contained in:
parent
348cbf86d8
commit
e9a331dbd5
2 changed files with 21 additions and 11 deletions
|
|
@ -457,9 +457,24 @@ class KSPlayerView: UIView {
|
|||
return
|
||||
}
|
||||
|
||||
playerView.seek(time: time) { success in
|
||||
// Capture the current paused state before seeking
|
||||
let wasPaused = isPaused
|
||||
print("KSPlayerView: Seeking to \(time), paused state before seek: \(wasPaused)")
|
||||
|
||||
playerView.seek(time: time) { [weak self] success in
|
||||
guard let self = self else { return }
|
||||
|
||||
if success {
|
||||
print("KSPlayerView: Seek successful to \(time)")
|
||||
|
||||
// Restore the paused state after seeking
|
||||
// KSPlayer's seek may resume playback, so we need to re-apply the paused state
|
||||
if wasPaused {
|
||||
DispatchQueue.main.async {
|
||||
self.playerView.pause()
|
||||
print("KSPlayerView: Restored paused state after seek")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print("KSPlayerView: Seek failed to \(time)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -849,6 +849,8 @@ const KSPlayerCore: React.FC = () => {
|
|||
const onPaused = () => {
|
||||
if (isMounted.current) {
|
||||
setPaused(true);
|
||||
// Reset the wasPlayingBeforeDrag ref so that seeking while paused doesn't resume playback
|
||||
wasPlayingBeforeDragRef.current = false;
|
||||
|
||||
// IMMEDIATE: Send immediate pause update to Trakt when user pauses
|
||||
if (duration > 0) {
|
||||
|
|
@ -919,8 +921,9 @@ const KSPlayerCore: React.FC = () => {
|
|||
if (duration > 0) {
|
||||
const seekTime = Math.min(value, duration - END_EPSILON);
|
||||
seekToTime(seekTime);
|
||||
// If the video was playing before the drag, ensure we remain in playing state after the seek
|
||||
if (wasPlayingBeforeDragRef.current) {
|
||||
// Only resume playback if the video was playing before the drag AND is not currently paused
|
||||
// This ensures that if the user paused during or before the drag, it stays paused
|
||||
if (wasPlayingBeforeDragRef.current && !paused) {
|
||||
setTimeout(() => {
|
||||
if (isMounted.current) {
|
||||
setPaused(false);
|
||||
|
|
@ -988,14 +991,6 @@ const KSPlayerCore: React.FC = () => {
|
|||
completeOpeningAnimation();
|
||||
}
|
||||
|
||||
// If time is advancing right after seek and we previously intended to play,
|
||||
// ensure paused state is false to keep UI in sync
|
||||
if (wasPlayingBeforeDragRef.current && paused && !isDragging) {
|
||||
setPaused(false);
|
||||
// Reset the intent once corrected
|
||||
wasPlayingBeforeDragRef.current = false;
|
||||
}
|
||||
|
||||
// Periodic check for disabled audio track (every 3 seconds, max 3 attempts)
|
||||
const now = Date.now();
|
||||
if (now - lastAudioTrackCheck > 3000 && !paused && duration > 0 && audioTrackFallbackAttempts < 3) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue