diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0724a81..525400ea4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## Unreleased + +### Fixed + +- Fixed an issue where the Lockscreen showed enabled controls when the player has no valid source. ### Added diff --git a/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift b/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift index 92635d4b2..5bbcb02ff 100644 --- a/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +++ b/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift @@ -9,6 +9,7 @@ class THEOplayerRCTRemoteCommandsManager: NSObject { private weak var player: THEOplayer? private var isLive: Bool = false private var inAd: Bool = false + private var hasSource: Bool = false private var mediaControlConfig = MediaControlConfig() // MARK: player Listeners @@ -40,6 +41,7 @@ class THEOplayerRCTRemoteCommandsManager: NSObject { private func initRemoteCommands() { self.isLive = false self.inAd = false + self.hasSource = false let commandCenter = MPRemoteCommandCenter.shared() commandCenter.playCommand.isEnabled = false @@ -80,13 +82,14 @@ class THEOplayerRCTRemoteCommandsManager: NSObject { let commandCenter = MPRemoteCommandCenter.shared() // update the enabled state to have correct visual representation in the lockscreen - commandCenter.playCommand.isEnabled = !self.inAd - commandCenter.pauseCommand.isEnabled = !self.inAd - commandCenter.togglePlayPauseCommand.isEnabled = !self.inAd - commandCenter.stopCommand.isEnabled = !self.inAd - commandCenter.changePlaybackPositionCommand.isEnabled = !self.isLive && !self.inAd - commandCenter.skipForwardCommand.isEnabled = !self.isLive && !self.inAd - commandCenter.skipBackwardCommand.isEnabled = !self.isLive && !self.inAd + commandCenter.pauseCommand.isEnabled = self.hasSource && !self.inAd + commandCenter.playCommand.isEnabled = self.hasSource && !self.inAd + commandCenter.pauseCommand.isEnabled = self.hasSource && !self.inAd + commandCenter.togglePlayPauseCommand.isEnabled = self.hasSource && !self.inAd + commandCenter.stopCommand.isEnabled = self.hasSource && !self.inAd + commandCenter.changePlaybackPositionCommand.isEnabled = self.hasSource && !self.isLive && !self.inAd + commandCenter.skipForwardCommand.isEnabled = self.hasSource && !self.isLive && !self.inAd + commandCenter.skipBackwardCommand.isEnabled = self.hasSource && !self.isLive && !self.inAd commandCenter.nextTrackCommand.isEnabled = !self.isLive && !self.inAd commandCenter.previousTrackCommand.isEnabled = !self.isLive && !self.inAd @@ -228,6 +231,7 @@ class THEOplayerRCTRemoteCommandsManager: NSObject { self.sourceChangeListener = player.addEventListener(type: PlayerEventTypes.SOURCE_CHANGE) { [weak self] event in self?.isLive = false self?.inAd = false + self?.hasSource = (event.source != nil) self?.updateRemoteCommands() }