Skip to content

Commit

Permalink
fix: Stop playback when you leave the player
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu-dgl committed Nov 18, 2024
1 parent 8ac402e commit b8d3c87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kDrive/UI/View/Files/Preview/VideoCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class VideoCollectionViewCell: PreviewCollectionViewCell {

override func prepareForReuse() {
super.prepareForReuse()
videoPlayer?.stopPlayback()
previewFrameImageView.image = nil
previewDownloadTask?.cancel()
}
Expand Down Expand Up @@ -97,6 +98,7 @@ class VideoCollectionViewCell: PreviewCollectionViewCell {
let navController = VideoPlayerNavigationController(rootViewController: playerViewController)
navController.disappearCallback = { [weak self] in
MatomoUtils.track(eventWithCategory: .mediaPlayer, name: "pause")
self?.videoPlayer?.stopPlayback()
self?.presentFloatingPanel()
}
navController.setNavigationBarHidden(true, animated: false)
Expand Down
4 changes: 4 additions & 0 deletions kDriveCore/VideoPlayer/VideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,8 @@ public final class VideoPlayer {
}
return MediaMetadata(title: title, artist: artist, artwork: artwork)
}

public func stopPlayback() {
player?.pause()
}
}

0 comments on commit b8d3c87

Please sign in to comment.