Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix Playlist Managed popup showing when it shouldn't
Browse files Browse the repository at this point in the history
Fix Playlist not pausing the web-page video on iPad when playing (so users hear double audio)
Fix Playlist not continuing to the next video/audio in Picture-In-Picture

Signed-off-by: Brandon T <[email protected]>
  • Loading branch information
Brandon-T committed Dec 13, 2023
1 parent e9f185f commit ae5348f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ extension PlaylistListViewController: UITableViewDataSource {
header.onAddPlaylist = { [unowned self] in
guard let sharedFolderUrl = folder.sharedFolderUrl else { return }

if PlayListDownloadType(rawValue: Preferences.Playlist.autoDownloadVideo.value) != nil {
if PlayListDownloadType(rawValue: Preferences.Playlist.autoDownloadVideo.value) != .off {
let controller = PopupViewController(rootView: PlaylistFolderSharingManagementView(onAddToPlaylistPressed: { [unowned self] in
self.dismiss(animated: true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ extension PlaylistListViewController {
return
}

playerView.stop()
playerView.pause()
playerView.bringSubviewToFront(activityIndicator)
activityIndicator.startAnimating()
activityIndicator.isHidden = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ extension PlaylistViewController: PlaylistViewControllerDelegate {
stop(playerView)

// Cancel all loading.
PlaylistManager.shared.playbackTask?.cancel()
PlaylistManager.shared.playbackTask = nil
}

Expand Down Expand Up @@ -864,7 +865,12 @@ extension PlaylistViewController: VideoViewDelegate {
}

func load(_ videoView: VideoView, asset: AVURLAsset, autoPlayEnabled: Bool) async throws /*`MediaPlaybackError`*/ {
self.clear()
// Task will be nil if the playback has stopped, but not paused
// If it is paused, and we're loading another track, don't bother clearing the player
// as this will break PIP
if PlaylistManager.shared.playbackTask == nil {
self.clear()
}

let isNewItem = try await player.load(asset: asset)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ public class PlaylistCarplayManager: NSObject {

func getPlaylistController(tab: Tab?, initialItem: PlaylistInfo?, initialItemPlaybackOffset: Double) -> PlaylistViewController {

// If background playback is enabled, tabs will continue to play media
// If background playback is enabled (on iPhone), tabs will continue to play media
// Even if another controller is presented and even when PIP is enabled in playlist.
// Therefore we need to stop the page/tab from playing when using playlist.
if Preferences.General.mediaAutoBackgrounding.value {
tab?.stopMediaPlayback()
}
// On iPad, media will continue to play with or without the background play setting.
tab?.stopMediaPlayback()

// If there is no media player, create one,
// pass it to the play-list controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ window.__firefox__.includeOnce("Playlist", function($) {
style.visibility !== 'hidden';
}

function getAllVideoElements() {
return [...document.querySelectorAll('video')].reverse();
}

function getAllAudioElements() {
return [...document.querySelectorAll('audio')].reverse();
}

function setupLongPress() {
Object.defineProperty(window.__firefox__, '$<playlistLongPressed>', {
enumerable: false,
Expand Down Expand Up @@ -220,14 +228,6 @@ window.__firefox__.includeOnce("Playlist", function($) {
// MARK: ---------------------------------------

function setupDetector() {
function getAllVideoElements() {
return [...document.querySelectorAll('video')].reverse();
}

function getAllAudioElements() {
return [...document.querySelectorAll('audio')].reverse();
}

function requestWhenIdleShim(fn) {
var start = Date.now()
return setTimeout(function () {
Expand Down

0 comments on commit ae5348f

Please sign in to comment.