Как удалить MPRemoteCommandCenter с экрана блокировки, когда я (выход из системы) перехожу к другому контроллеру представления? - PullRequest
0 голосов
/ 07 августа 2020

Это шаги, выполненные в моем проекте

Шаг 1: AppDelegate class.

fun c application (_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {configureRemoteCommandCenter () return true}

func configureRemoteCommandCenter(){
    
    MPRemoteCommandCenter.shared().playCommand.isEnabled = true
    MPRemoteCommandCenter.shared().playCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        
        print("play command")
        
        return .success
    }
    
    MPRemoteCommandCenter.shared().pauseCommand.isEnabled = true
    MPRemoteCommandCenter.shared().pauseCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        
    
        print("pause Command")
        
        return .success
    }

    MPRemoteCommandCenter.shared().previousTrackCommand.isEnabled = true
    MPRemoteCommandCenter.shared().previousTrackCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
       
        print("previousTrackCommand")
        
        return .success
    }

    MPRemoteCommandCenter.shared().nextTrackCommand.isEnabled = true
    MPRemoteCommandCenter.shared().nextTrackCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
        
        print("nextTrackCommand")
        
        return .success
    }
    
}

Шаг 2: Я использую AVPlayer и пробовал это

func logout(){
        
  player.pause()

  UIApplication.shared.endReceivingRemoteControlEvents()

  MPNowPlayingInfoCenter.default().nowPlayingInfo = [:]
            
}

Результат не найден. Я что-то здесь пропускаю?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...