diff --git a/Client/Application/Delegates/AppDelegate.swift b/Client/Application/Delegates/AppDelegate.swift index fe712ff3cb7..96a9d7e4222 100644 --- a/Client/Application/Delegates/AppDelegate.swift +++ b/Client/Application/Delegates/AppDelegate.swift @@ -381,7 +381,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UIViewControllerRestorati AdblockResourceDownloader.shared.startLoading() PlaylistManager.shared.restoreSession() - carPlayManager = PlaylistCarplayManager.shared + carPlayManager = PlaylistCarplayManager.shared.then { + $0.browserController = browserViewController + } return shouldPerformAdditionalDelegateHandling } diff --git a/Client/Frontend/Browser/Playlist/Controller/PlaylistCarplayController.swift b/Client/Frontend/Browser/Playlist/Controller/PlaylistCarplayController.swift index 0defdbae430..9568b07f8ff 100644 --- a/Client/Frontend/Browser/Playlist/Controller/PlaylistCarplayController.swift +++ b/Client/Frontend/Browser/Playlist/Controller/PlaylistCarplayController.swift @@ -23,11 +23,11 @@ class PlaylistCarplayController: NSObject { private var playlistItemIds = [String]() private weak var browser: BrowserViewController? - init(browser: BrowserViewController, player: MediaPlayer, contentManager: MPPlayableContentManager) { + init(browser: BrowserViewController?, player: MediaPlayer, contentManager: MPPlayableContentManager) { self.browser = browser self.player = player self.contentManager = contentManager - self.mediaStreamer = PlaylistMediaStreamer(playerView: browser.view ?? UIView()) + self.mediaStreamer = PlaylistMediaStreamer(playerView: browser?.view ?? UIView()) super.init() observePlayerStates() diff --git a/Client/Frontend/Browser/Playlist/PlaylistCarplayManager.swift b/Client/Frontend/Browser/Playlist/PlaylistCarplayManager.swift index bc16a88ab21..26e195df357 100644 --- a/Client/Frontend/Browser/Playlist/PlaylistCarplayManager.swift +++ b/Client/Frontend/Browser/Playlist/PlaylistCarplayManager.swift @@ -22,6 +22,7 @@ class PlaylistCarplayManager: NSObject { var currentlyPlayingItemIndex = -1 var currentPlaylistItem: PlaylistInfo? + var browserController: BrowserViewController? // There can only ever be one instance of this class // Because there can only be a single AudioSession and MediaPlayer @@ -65,7 +66,7 @@ class PlaylistCarplayManager: NSObject { // If there is no media player, create one, // pass it to the car-play controller let mediaPlayer = self.mediaPlayer ?? MediaPlayer() - let carPlayController = PlaylistCarplayController(player: mediaPlayer, contentManager: contentManager) + let carPlayController = PlaylistCarplayController(browser: browserController, player: mediaPlayer, contentManager: contentManager) self.mediaPlayer = mediaPlayer return carPlayController }