views:

656

answers:

4

Hello, I used the sample code from http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html. it runs OK with default URL. But when I replace with my URL "http://dl.mp3.kapsule.info/fsfsdfdsfdserwrwq3/fc90613208cc3f16ae6d6ba05d21880c/4b5244f0/b/7e/b7e80afa18d06fdd3dd9f9fa44b51fc0.mp3?filename=Every-Day-I-Love-You.mp3", this app shows an message as "Audio not Found". But when I put my URL on Address Bar of Web Browser, I can download this .mp3 file.

really, I can't understand why it is?

pleased tell me!

Thank you very much

A: 

Thats because the default url directly points to a file in the webserver, whereas the the url you've mentioned is a HTTP (POST/GET) operation, which the application may not be designed to handle.

Vivek Bernard
Then it would be a very poorly designed application.
Pekka
so could you tell me how to handle a HTTP (POST/GET) operation for streaming .mp3 audio files on IPhone
Check out what the problem is first. Put your file to a normal URL and see whether it works.
Pekka
I dont know to do it in IPhone (.Net Guy), But usually when dealing with websites, the request is sent as an HTTPRequest, for which an HTTPResponse may be recived, Eg: when you request the "www.foo.com/bar" the response may contain a HTML or XML or JSON data, which you have to deal within your application the request may be the URL in your Question and response may be the correct (Direct) URL to the MP3 File
Vivek Bernard
That does not make sense. Any request that you can reproduce by entering the URL into a web browser is a `GET`. It doesn't matter if there are parameters.
Sidnicious
+1  A: 

My guess would be that the app is designed to play a MP3 encoded audio stream with no limit in length (which is different from your ordinary music file). To set this up, you need a streaming server on the client side.

I think you can find out for sure by trying with a different radio station that transmits in MP3. If that works, it's most likely that your app doesn't like your file.

You should, as Vivek recommends, also try using a simpler download URL for your file, in case the App gets confused by the URL's length and/or structure.

Pekka
A: 

As mentioned, this is due to the URL of the file. The AudioStreamer code specifically checks for the extension of the file and tries to figure out the audio type based on that. If you change that logic to handle your custom URLs, it will start working

So to point you in the right direction: open AudioStreamer.m and look for the references of

hintForFileExtension:

This function returns the type of file based on the extension. If you know the file type won't change (always mp3), the quick and dirty solution is to always assign mp3 type without any logic... like this:

err = AudioFileStreamOpen(self, MyPropertyListenerProc, MyPacketsProc, kAudioFileMP3Type, &audioFileStream);

Note: I've put kAudioFileMP3Type constant instead of calculated value

PS yes, it does work with static mp3 files, even though it's designed for streams and hence misses some of the functionality one would expect from a player that plays a static file on the server (caching, prefetching, proper seeking)

Nick
A: 

I suspect that your URL is one-time-use. When I try to visit it, I see 408 - Request Timeout.

Many links on mass file sharing websites are like this. If you could download the file directly, you wouldn't sit through a page of ads and premium account offers.

Try again with a file on a normal website, like this one.

Sidnicious