English 中文(简体)
Unable to play m4a file iPhone Device(Using iTunes affiliate search api)
原标题:

I am trying 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





相关问题
The codec could not be accessed. (-66672)

I am trying to convert caf file to m4a file using AudioUnit. I have implemented the code to convert. When I tried to run the application, I am getting following error message; couldn t set ...

what is AudioStreamBasicDescription for m4a file format

I have tried with more AudioStreamBasicDescription for m4a file format. Still I am getting some issues with that. Please anyone tell me the exact AudioStreamBasicDescription for m4a file format.

How to record voice in .m4a format

Already I have created an iPhone application to record. It will record in .caf file. But I want to record in .m4a format. Please help me to do this. Thanks.

flash audio player for m4a (AAC) audio file embedded in html

I m looking for a (free) flash player that I can embed in my site and use to play a .m4a (.mp4 with AAC audio) file that will be obtained using a URL (i.e. it s not local to the server hosting the web ...

WPF MediaElement: SpeedRatio not working for .m4a files?

I m working with a simple mediaplayer based on this msdn example where the user can control volume, playback speed (SpeedRatio) and seek (Position) using 3 sliders. Everything works correctly when I ...

How to read tags out of m4a files in .NET?

I ve got some heavily modified code that ultimately came from the Windows Media SDK that works great for reading tags out of MP3 and WMV files. Somewhere along the line, Windows Media Player added ...

热门标签