Ios authorizationStatus()关于MPMediaLibrary访问
我想访问媒体库以显示歌曲列表。因此,我正在检查媒体库的授权状态。当我们在权限警报中选择“不允许”时,获得的授权状态为Ios authorizationStatus()关于MPMediaLibrary访问,ios,swift2,itunes,mpmediaitem,mpmediaquery,Ios,Swift2,Itunes,Mpmediaitem,Mpmediaquery,我想访问媒体库以显示歌曲列表。因此,我正在检查媒体库的授权状态。当我们在权限警报中选择“不允许”时,获得的授权状态为.Denied,但应用程序可以获取媒体项目。如果没有媒体权限,我们也可以访问库吗?如果是,代码级别的媒体权限需要什么?下面是代码 func checkMediaLibraryPermissions() { if #available(iOS 9.3, *) { func requestAuthorization() { MPMedia
.Denied
,但应用程序可以获取媒体项目。如果没有媒体权限,我们也可以访问库吗?如果是,代码级别的媒体权限需要什么?下面是代码
func checkMediaLibraryPermissions() {
if #available(iOS 9.3, *) {
func requestAuthorization() {
MPMediaLibrary.requestAuthorization { (status) in
switch status {
case .Authorized:
// Go for the further actions
case .NotDetermined: break // We are already request the authorization above
case .Denied,
.Restricted:
let qrySongs = MPMediaQuery.songsQuery()
debugPrint(qrySongs.count)
// Require to show the alert about the permission enable
}
}
}
let authorizeStatus = MPMediaLibrary.authorizationStatus()
switch authorizeStatus {
case .Authorized:
// Go for the further actions
case .NotDetermined:
requestAuthorization()
case .Restricted,
.Denied:
let qrySongs = MPMediaQuery.songsQuery()
debugPrint(qrySongs.count)
// Require to show the alert about the permission enable
}
}
}