Swift MPMusicController播放/暂停API函数,无论是否接受媒体库权限
我们正在使用MPMusicController来播放短声音,但从iOS 13.4开始,由于info.plist中缺少NSAppleMusicUsageDescription键,应用程序开始崩溃 但是,在info.plist中添加键后,MPMusicController的播放/暂停API会触发“Apple Music权限”。现在,接受或拒绝许可不会影响通过MPMusicController播放的声音,这让我感到奇怪Swift MPMusicController播放/暂停API函数,无论是否接受媒体库权限,swift,mpmusicplayercontroller,apple-music,mpmedialibrary,Swift,Mpmusicplayercontroller,Apple Music,Mpmedialibrary,我们正在使用MPMusicController来播放短声音,但从iOS 13.4开始,由于info.plist中缺少NSAppleMusicUsageDescription键,应用程序开始崩溃 但是,在info.plist中添加键后,MPMusicController的播放/暂停API会触发“Apple Music权限”。现在,接受或拒绝许可不会影响通过MPMusicController播放的声音,这让我感到奇怪 理想情况下,当权限被拒绝时,它不应运行,如果有人对此有想法或解释,我将不胜感激。检
理想情况下,当权限被拒绝时,它不应运行,如果有人对此有想法或解释,我将不胜感激。检查苹果音乐权限
func appleMusicRequestPermission() -> Bool{
var isAllowAccess: Bool = false
switch SKCloudServiceController.authorizationStatus(){
case .notDetermined:
print("The user hasn't decided yet - so we'll break out of the switch and ask them.")
let allow = self.askAppleMusicPermissio()
isAllowAccess = allow
break
case .denied:
print("The user has selected 'Don't Allow' in the past - so we're going to show them a different dialog to push them through to their Settings page and change their mind, and exit the function early.")
isAllowAccess = false
break
case .restricted:
print("User may be restricted; for example, if the device is in Education mode, it limits external Apple Music usage. This is similar behavior to Denied.")
isAllowAccess = false
break
case .authorized:
print("The user's already authorized - we don't need to do anything more here, so we'll exit early.")
isAllowAccess = true
break
default:
isAllowAccess = false
break
}
return isAllowAccess
}