mp3player RemoteControl кнопки не отображаются при блокировке экрана - PullRequest
0 голосов
/ 23 мая 2019

Здравствуйте. В моем приложении есть mp3-плеер, я хочу, чтобы, когда бы я ни проигрывал песню, и на экране блокировки переходов отображался проигрыватель с паузой воспроизведения, как в других плеерах.я делаю так, но id не появляется никаких кнопок, после этого кода ничего не происходит

 if UIApplication.shared.responds(to: #selector(UIApplication.beginReceivingRemoteControlEvents)){
            UIApplication.shared.beginReceivingRemoteControlEvents()
            UIApplication.shared.beginBackgroundTask(expirationHandler: { () -> Void in
            })
        }

override func remoteControlReceived(with event: UIEvent?) {


        if event!.type == UIEvent.EventType.remoteControl{
            switch event!.subtype{
            case UIEventSubtype.remoteControlPlay:
               // play(self)
                break
            case UIEventSubtype.remoteControlPause:break
             //   play(self)
            case UIEventSubtype.remoteControlNextTrack:break
              //  next(self)
            case UIEventSubtype.remoteControlPreviousTrack:break
              //  previous(self)
            default:
                print("There is an issue with the control")
            }
        }
    }
...