MPMediaItemPropertyAssetURL仅为iPhone 5s返回null [英] MPMediaItemPropertyAssetURL returning null only for iPhone 5s

查看:481
本文介绍了MPMediaItemPropertyAssetURL仅为iPhone 5s返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用以下代码从MPMediaItemPickerController返回的MPMediaItem对象中提取资产网址,以便我可以将用户iPhone itunes音乐库中的音乐文件复制到文档文件夹进行处理,但在iPhone 5s上我总是从MPMediaItemPropertyAssetURL获取一个空值,但是当我在iPhone 4或iPhone 5上运行相同的代码时,它应该返回一个正确的URL。

I have been using the following code to extract the asset url from the MPMediaItem object returned from the MPMediaItemPickerController so that I can copy music files from a users iPhone itunes music library to the documents folder for processing, but on iPhone 5s I always get a null value from the MPMediaItemPropertyAssetURL, but when I run the same code on iPhone 4 or iPhone 5 it works as it should returning a proper url.

- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection {

    [self dismissViewControllerAnimated:YES completion:nil];

        if(mediaItemCollection){
           MPMediaItem *mediaItem = (MPMediaItem *)[mediaItemCollection.items objectAtIndex: 0];
           NSString *songTitle = [mediaItem valueForProperty: MPMediaItemPropertyTitle];
           NSLog(@"songtitle: %@", songTitle);
           NSURL *assetURL = [mediaItem valueForProperty: MPMediaItemPropertyAssetURL];
           NSLog(@"%@", assetURL);
        }

}

我试过从有效中删除arm64架构并且只为armv7和armv7s构建,但这并没有解决这个问题。

I have tried removing arm64 from valid architectures and only building for armv7 and armv7s, but that didn't fix this problem.

有谁知道为什么会发生这种情况以及我如何解决它或者是否有我可以使用的解决方法?我需要能够将音乐从iPhone的音乐库复制到文档文件夹,以便我可以正确处理dj应用程序的音乐。

Does anyone know why this is happening and how I can fix it or if there is a workaround I can use? I need to be able to copy music from the iPhone's music library to the documents folder so that I can process the music properly for a dj application.

谢谢

推荐答案

我发现问题是我试图获取MPMediaItemPropertyAssetURL属性的歌实际上不在我的设备上。它被列在媒体库中,但实际上仍然在iCloud中。一旦我将歌曲下载到我的设备,问题就解决了。尽管我不喜欢回答我自己的问题,但我还是采用了Jeroen的建议,以便能够帮助他人。

I found out that the problem was the song I was trying to get the MPMediaItemPropertyAssetURL property for was actually not on my device. It was listed in the media library, but was actually still in iCloud. Once I downloaded the song to my device then the problem was solved. As much as I don't like answering my own question I took Jeroen's advice so that it can hopefully help others.

这篇关于MPMediaItemPropertyAssetURL仅为iPhone 5s返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆