Is it possible to play streaming audio ?

Hello,

I am trying to play an internet radio, given by its url. Unfortunately, it looks like sounds must be embedded into the projetct, as caf files.
Is there any solution, like the one used to play video, for example ?

Many thanks,

Olivier.

This is a complete GUESS because I'm a very new Corona user (still using the trial version), but at least one way might be to use one of the Web Popups to open a page where you use the HTML5 audio tag to play your audio file.

What's a Web Popup? "Web popups let you open local or remote web page specified by URL." You can see more here:
https://developer.anscamobile.com/content/native-ui-features#Web_Popups

Again, I don't know if that will work, but it *sounds* like it should. =:)

Jay Jennings

I'm trying to do the same, and the only solution I've found so far is to use a native webpopup to load an html using the audio tag pointing to the streaming source.
You could also point directly to the streaming source, without html, but doing that will result in opening the media player interface (not sure if that's the name, but basically the same interface of media.playVideo).

The main problems in this approach are:
1) you can have only one webpopup open, so if you need to open a webpopup to show a webpage or do something you'll interrupt the streaming
2) there are no way to control the playback (play/pause) or change volume
3) you can't move or change opacity to a webpopup without closing and reopening it.. so if you want to move it somewhere or hide it, it will stop the streaming
4) when you open a webpopup in Corona, even setting a transparent background, it shows as a gray block at the beginning before loading the page.. I'm not sure if it's the same in xcode, but kinda sucks because you can "feel" is something not really integrated with your app

So probably the only way to do something with streaming radio is to create a html interface to play/pause the streaming and open it with a webpopup.

By the way, I've tried using media.playVideo, since it can load from remote sources, and it works.. but you're stuck with the fullscreen media player interface.

It would be great if media.playSound or audio.loadStream could use remote sources. That would be the perfect solution for streaming internet radio...

Any advice?

@shedder: did you put to work a streaming in html5 on iphone..

I can't.. :(

I've:

local options = { hasBackground=true, baseUrl=system.ResourceDirectory }
native.showWebPopup ("audio.html", options )

and then on my audio.html

1
2
3
4
5
6
7
8
9
10
11
12
    <style type="text/css"> 
        html {        -webkit-text-size-adjust: none;  }
        </style>
    <head>
    <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
    <title>audio testing live stream!</title>
    </head>
    <body>
    <audio controls="controls" autoplay="autoplay" src="http://oggvorbis.tb-stream.net:80/technobase.ogg">
    </audio>
 
    </body>

This is the html that used to work.
I changed my radio address with the one in your example and in mobile Safari it works. Haven't tried on xcode simulator (but if it works in mobile safari I guess it should also work in a corona webview).
I really wanted to add a streaming radio, but this solution (even if it works) is quite not pro..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
<head> 
<title>Radio</title> 
<meta name="viewport" content="maximum-scale=1, minimum-scale=1, width=device-width, user-scalable=no;"/>
  <meta name="apple-mobile-web-app-capable" content="yes" />
<style type="text/css"> 
   html { -webkit-text-size-adjust: none; }
        body {margin: 3px 3px 3px 3px;}
</style>
</head> 
<body> 
<audio id="audio" controls autoplay src="http://oggvorbis.tb-stream.net:80/technobase.ogg;"></audio>
<script type="text/javascript"> 
  window.onload = function() {
  var audioPlayer = document.getElementById("audio");
 audioPlayer.load();
 audioPlayer.play();
  };
    </script> 
 
</body>

ok, with that url it works
but when i change to: www.streampt.com/radiosines.pls
it doesn't load.

the source that i want is from this stream:
www.radiosines.com

by the way...
using this method playing in webview what happens if the phone rings?
will the sound be automaticly stopped? our will continue playing?

Regards,
B

.pls is a playlist file. here are the contents of that link

1
2
3
4
5
6
[playlist]
numberofentries=1
File1=http://88.198.22.132:8054
Title1=Radio Sines
Length1=-1
version=2

yes i know.
But even if i set the audio src to http://88.198.22.132:8054 it still doesn't work.

B

I was looking for the same (play a shoutcast radio station) and reading your posts it seems there isn't still a good solution :(
I wonder if Corona developers have any plans to make something like

1
audio.loadStream( "http://xxx.xxx.xxx.xxx:8000/;mp3" )
views:2345 update:2011/9/28 8:56:32
corona forums © 2003-2011