diff --git a/Model/Player/Backends/AVPlayerBackend.swift b/Model/Player/Backends/AVPlayerBackend.swift index 7e71208f..576fc78d 100644 --- a/Model/Player/Backends/AVPlayerBackend.swift +++ b/Model/Player/Backends/AVPlayerBackend.swift @@ -160,6 +160,13 @@ final class AVPlayerBackend: PlayerBackend { return } + // After the video has ended, hitting play restarts the video from the beginning. + if currentTime?.seconds.formattedAsPlaybackTime() == model.playerTime.duration.seconds.formattedAsPlaybackTime() && + currentTime!.seconds > 0 && model.playerTime.duration.seconds > 0 + { + seek(to: 0, seekType: .loopRestart) + } + avPlayer.play() model.objectWillChange.send() } diff --git a/Model/Player/Backends/MPVBackend.swift b/Model/Player/Backends/MPVBackend.swift index 223cdf78..107f63d9 100644 --- a/Model/Player/Backends/MPVBackend.swift +++ b/Model/Player/Backends/MPVBackend.swift @@ -365,6 +365,13 @@ final class MPVBackend: PlayerBackend { setRate(model.currentRate) + // After the video has ended, hitting play restarts the video from the beginning. + if currentTime?.seconds.formattedAsPlaybackTime() == model.playerTime.duration.seconds.formattedAsPlaybackTime() && + currentTime!.seconds > 0 && model.playerTime.duration.seconds > 0 + { + seek(to: 0, seekType: .loopRestart) + } + client?.play() } @@ -530,8 +537,6 @@ final class MPVBackend: PlayerBackend { guard client.eofReached else { return } - - getTimeUpdates() eofPlaybackModeAction() }