How to detect if an MPMediaItem represents a DRM-protected audio track on iOS

前端 未结 7 2090
粉色の甜心
粉色の甜心 2020-12-01 12:31

I would like to know if an MPMediaItem that represents a music track is for a Fairplay/DRM-protected item. Any way to do this?

7条回答
  •  清歌不尽
    2020-12-01 13:06

    From iOS 4.2 the AVAsset class has a property hasProtectedContent so you can check:

    NSURL *assetURL = [item valueForProperty:MPMediaItemPropertyAssetURL];
    AVAsset *asset = [AVAsset assetWithURL:assetURL];
    
    if ([asset hasProtectedContent] == NO) {..do your stuff..}
    

提交回复
热议问题