I am unable to play an online audio live stream in my app. How do I do it?

I want to play a live audio stream in my app from an URL.

I tried 

 local function onComplete(event) print("stream complete") end media.playVideo("http://radiourl.mp3", media.RemoteSource, true, onComplete )

Nothing happens. How do I do this?

The url I put here is fake btw.

There must be a way to do this. Its an essential part of my app.

What isn’t working? Are you testing on iOS, Mac OSX or Android? Are you sure your steaming site is functioning properly? Are you certain that it’s not buffering prior to being played?

Oh just read that the API is not available on the Windows version of the simulator. Let me try on a device.

Tried on an android device. The screen goes black when I call but the app does not crash

media.playVideo("http://radiourl.mp3", media.RemoteSource, true, onComplete )

After a while I get the error “Can’t play this video”

Plus I need the audio to play in the background and the screen to not change. I tried 

media.playVideo("http://radiourl.mp3", media.RemoteSource, false, onComplete )

its still the same.

This might be done with html5 but its not a cool solution. How hard can it be to get 

audio.loadStream( "http://radiourl.mp3" )

 to work. Should I play with the source code a little? I really dont want to learn xamarin to make this app.

First, Corona SDK does not offer a way to play “streams” of data.  You have to have a complete file to download in which case we can start playing it before the download completes.  You appear to be trying to download a .mp3 file.

However, that URL does not exist.  Try to go to:   in your browser and it fails to load.  In fact it tries to get to a website known as www.radiourl.mp3 which is an invalid web address.  In fact .mp3 is not a valid Internet Top Level Domain.

So if you’re trying to download a real .mp3 file, please provide the full URL for it.  If you’re trying to attach to a streaming service, Corona SDK cannot do this.

Even then not all .mp3 files are guaranteed to be handled by the media.play Video () API.

Rob

Yes I wrote a fake url above. The url Im trying in the app works 100%. I am not trying to download an mp3 file. Im trying to stream a live radio. I guess I cant do it with corona.

I see you are an Enterprise subscriber.  There is probably a way to use a native library to do it, but not with SDK as is.

Rob

Instead of a native library, is there a lua library or plugin I could use?

Rob, say I have a finished app and need to implement a native library how would I do it? I read the tutorial but still dont know how to do this. Also if I use an Android API would my app still work for iOS? Does Enterprise work on Windows?

Currently Enterprise requires a Mac.  You would have to implement both an iOS and an Android way to do things.

Rob

There must be a way to do this. Its an essential part of my app.

What isn’t working? Are you testing on iOS, Mac OSX or Android? Are you sure your steaming site is functioning properly? Are you certain that it’s not buffering prior to being played?

Oh just read that the API is not available on the Windows version of the simulator. Let me try on a device.

Tried on an android device. The screen goes black when I call but the app does not crash

media.playVideo("http://radiourl.mp3", media.RemoteSource, true, onComplete )

After a while I get the error “Can’t play this video”

Plus I need the audio to play in the background and the screen to not change. I tried 

media.playVideo("http://radiourl.mp3", media.RemoteSource, false, onComplete )

its still the same.

This might be done with html5 but its not a cool solution. How hard can it be to get 

audio.loadStream( "http://radiourl.mp3" )

 to work. Should I play with the source code a little? I really dont want to learn xamarin to make this app.

First, Corona SDK does not offer a way to play “streams” of data.  You have to have a complete file to download in which case we can start playing it before the download completes.  You appear to be trying to download a .mp3 file.

However, that URL does not exist.  Try to go to:   in your browser and it fails to load.  In fact it tries to get to a website known as www.radiourl.mp3 which is an invalid web address.  In fact .mp3 is not a valid Internet Top Level Domain.

So if you’re trying to download a real .mp3 file, please provide the full URL for it.  If you’re trying to attach to a streaming service, Corona SDK cannot do this.

Even then not all .mp3 files are guaranteed to be handled by the media.play Video () API.

Rob

Yes I wrote a fake url above. The url Im trying in the app works 100%. I am not trying to download an mp3 file. Im trying to stream a live radio. I guess I cant do it with corona.

I see you are an Enterprise subscriber.  There is probably a way to use a native library to do it, but not with SDK as is.

Rob

Instead of a native library, is there a lua library or plugin I could use?

Rob, say I have a finished app and need to implement a native library how would I do it? I read the tutorial but still dont know how to do this. Also if I use an Android API would my app still work for iOS? Does Enterprise work on Windows?

Currently Enterprise requires a Mac.  You would have to implement both an iOS and an Android way to do things.

Rob