mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-20 08:12:05 +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
|
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 {
|
if success {
|
||||||
print("KSPlayerView: Seek successful to \(time)")
|
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 {
|
} else {
|
||||||
print("KSPlayerView: Seek failed to \(time)")
|
print("KSPlayerView: Seek failed to \(time)")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -849,6 +849,8 @@ const KSPlayerCore: React.FC = () => {
|
||||||
const onPaused = () => {
|
const onPaused = () => {
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
setPaused(true);
|
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
|
// IMMEDIATE: Send immediate pause update to Trakt when user pauses
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
|
|
@ -919,8 +921,9 @@ const KSPlayerCore: React.FC = () => {
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
const seekTime = Math.min(value, duration - END_EPSILON);
|
const seekTime = Math.min(value, duration - END_EPSILON);
|
||||||
seekToTime(seekTime);
|
seekToTime(seekTime);
|
||||||
// If the video was playing before the drag, ensure we remain in playing state after the seek
|
// Only resume playback if the video was playing before the drag AND is not currently paused
|
||||||
if (wasPlayingBeforeDragRef.current) {
|
// This ensures that if the user paused during or before the drag, it stays paused
|
||||||
|
if (wasPlayingBeforeDragRef.current && !paused) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
setPaused(false);
|
setPaused(false);
|
||||||
|
|
@ -988,14 +991,6 @@ const KSPlayerCore: React.FC = () => {
|
||||||
completeOpeningAnimation();
|
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)
|
// Periodic check for disabled audio track (every 3 seconds, max 3 attempts)
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (now - lastAudioTrackCheck > 3000 && !paused && duration > 0 && audioTrackFallbackAttempts < 3) {
|
if (now - lastAudioTrackCheck > 3000 && !paused && duration > 0 && audioTrackFallbackAttempts < 3) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue