mpmediaitem

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

老子叫甜甜 提交于 2019-11-27 08:19:38
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? Here's how I do it: MPMediaItem* item; NSURL* assetURL = [item valueForProperty:MPMediaItemPropertyAssetURL]; NSString *title=[item valueForProperty:MPMediaItemPropertyTitle]; if (!assetURL) { /* * !!!: When MPMediaItemPropertyAssetURL is nil, it typically means the file * in question is protected by DRM. (old m4p files) */ NSLog(@"%@ has DRM",title); } Since iOS 4.2 there is a way. There may be a more effective way then the example here (but for my app I needed to

MPMediaItems raw song data

别等时光非礼了梦想. 提交于 2019-11-27 02:51:45
I was wondering how to access an MPMediaItem's raw data. Any ideas? MIchael you can obtain the media item's data in such way: -(void)mediaItemToData { // Implement in your project the media item picker MPMediaItem *curItem = musicPlayer.nowPlayingItem; NSURL *url = [curItem valueForProperty: MPMediaItemPropertyAssetURL]; AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil]; AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset presetName: AVAssetExportPresetPassthrough]; exporter.outputFileType = @"public.mpeg-4"; NSString *exportFile = [[self

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

南笙酒味 提交于 2019-11-26 22:17:43
问题 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? 回答1: Here's how I do it: MPMediaItem* item; NSURL* assetURL = [item valueForProperty:MPMediaItemPropertyAssetURL]; NSString *title=[item valueForProperty:MPMediaItemPropertyTitle]; if (!assetURL) { /* * !!!: When MPMediaItemPropertyAssetURL is nil, it typically means the file * in question is protected by DRM. (old m4p files) */ NSLog(@"%@ has DRM",title); } 回答2: