开发者

iOS: Get NSData of mp3

开发者 https://www.devze.com 2023-02-21 17:42 出处:网络
I w开发者_高级运维ant to send an mp3 file from music library from my iphone over wifi. So I need a way to get NSData of mp3 file.

I w开发者_高级运维ant to send an mp3 file from music library from my iphone over wifi. So I need a way to get NSData of mp3 file. Is it possible? How can i access it?


NSString *msg = [[NSBundle mainBundle] pathForResource:@"Rab" ofType:@"mp3"];
NSData* data =[[NSData alloc]init];
data = [NSData dataWithContentsOfFile:msg];


use

[NSData dataWithContentsOfFile:filePath]


Since iOS 4, you can use AVFoundation and MPMediaPickerController to export songs from the library. It's not simple, but it's doable. See http://www.subfurther.com/blog/2010/07/.


The current API does not allow you to access the user's media library in this way.


You may want to try using method:

(id)dataWithContentsOfURL:(NSURL *)aURL

0

精彩评论

暂无评论...
验证码 换一张
取 消