开发者

Unable to play m4a file iPhone Device(Using iTunes affiliate search api)

开发者 https://www.devze.com 2023-01-28 07:58 出处:网络
I am trying开发者_JAVA百科 to play m4a(http://a1.phobos.apple.com/us/r1000/020/Music/ad/41/da/mzm.fkekhvue.aac.p.m4a) file from iTunes affiliates using AvAudioPlayer but can not able to play it. I thi

I am trying开发者_JAVA百科 to play m4a(http://a1.phobos.apple.com/us/r1000/020/Music/ad/41/da/mzm.fkekhvue.aac.p.m4a) file from iTunes affiliates using AvAudioPlayer but can not able to play it. I think there is issue with the link because i have downloaded the audio then rename it and hosted on my server then i am able to play it.

I have tried it with Web-View then i am able to play it. But i want to play using AvAudioPlayer. When i tried to get the data from the link then also not able to get correct data.

Also i am not able to play using UIWebView or MoviePlayer(It is working on simulator but not in iPhone device). And very interesting is not able to play in safari app also.

I am using iTunes affiliate search api(e.g. http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=jack+johnson.)

Any idea?

Thanks, Dipen Patel


I've had success using NSData:

NSData *musicData = [NSData dataWithContentsOfURL:previewUrl]; 
NSError *err;
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:musicData error:&err];


FYI - You can only play the iTunes song samples if you are in a country that has an iTunes Music Store so don't let that get in the way of your test.

http://www.apple.com/itunes/affiliates/resources/blog/song-previews.html

0

精彩评论

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