获取描述很容易,只需使用
var descriptionText: String? { get }
从MPMediaPlaylist
要获取用户定义的图像,您必须使用私有 API,这是一个可用于获取存储在磁盘上的图像或获取图像的扩展URL
:
extension MPMediaPlaylist {
/**
User selected image for playlist stored on disk.
*/
var userImage: UIImage? {
guard let catalog = value(forKey: "artworkCatalog") as? NSObject else {
return nil
}
let sel = NSSelectorFromString("bestImageFromDisk")
guard catalog.responds(to: sel),
let value = catalog.perform(sel)?.takeUnretainedValue(),
let image = value as? UIImage else {
return nil
}
return image
}
/**
URL for playlist's image.
*/
var imageUrl: URL? {
if let catalog = value(forKey: "artworkCatalog") as? NSObject,
let token = catalog.value(forKey: "token") as? NSObject,
let url = token.value(forKey: "availableArtworkToken") as? String {
return URL(string: "https://is2-ssl.mzstatic.com/image/thumb/\(url)/260x260cc.jpg")
}
return nil
}
}
与往常一样,请记住,当 Apple 在后台更改内容或您的应用程序可能被 App Store 拒绝时,它可能随时停止工作。