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

Commit

Permalink
Refactoring CarPlay JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T committed Aug 9, 2021
1 parent defc85f commit 76d8ae5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Client/Application/Delegates/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 76d8ae5

Please sign in to comment.