Skip to main content
Inspiring
April 22, 2011
Question

AIR - Android -- A piece of ****

  • April 22, 2011
  • 23 replies
  • 7221 views

Hi,

I spent my precious 2 days time to write an application (AIR-Android) which can play internet radio stations (streamed audio). Every thing worked great when I used 'Test Movie' or Ctrl+ENTER. But same is not working when I generated the .apk and installed on HTC Desire HD (running Android 2.2 and have AIR with latest updates).

I have predefined few internet radio stations and clicking on the station name should start playing the radio. I have used the SoundChannel with 3 second buffering option. On the device application triggers the buffering event but never comes out of that or plays the audio.

I have tried few things:

1. Prepared a test file with only one station

2. In publish settings --> Audio Stream set the bit rate to 24kbps which is same as that station is streamed

3. Increased the script limit to 30 seconds

4. Tried to use Security.allowDomain() which caused runtime error (3207 Application-sandbox content cannot access this feature)

I used the station "http://stream.radiosai.net:8004" for testing. The station is active, streaming in MP3 format and able to listen through the Windows Media Player / VLC.

I prepared a self signed AIR for desktop as well and installed on my laptop (Windows 7 64-bit) but same problem.

I have prepared this using Air for Android extn for Flash CS5.

Please let me know if anybody has faced the same problem, suggest me if I am really missing anything.

Here the AS3 code used for testing.

===========================

import flash.media.Sound;

import flash.media.SoundChannel;

import flash.media.SoundLoaderContext;

import flash.net.URLRequest;

import flash.events.IOErrorEvent;

import flash.utils.Timer;

import flash.events.TimerEvent;

const AFRICA_STREAM:String = "http://stream.radiosai.net:8004";

var isPlaying:Boolean = false;

var recentlyPlayed:String = "";

var streamSound:Sound;

var streamChannel:SoundChannel;

var streamContext:SoundLoaderContext = new SoundLoaderContext(3000,false);

var streamTimer:Timer;

africa_mc.addEventListener(MouseEvent.CLICK, handleStationSelect);

function handleStationSelect(evt:MouseEvent):void {

     if (isPlaying == true) {

          streamChannel.stop();

          streamSound = null;

          streamChannel = null;

          isPlaying = false;

          streamTimer.stop();

          removeListeners();

     }

     switch (evt.target.name) {

          case "africa_mc" :

               if (recentlyPlayed != "africa_mc") {

                    playStation(AFRICA_STREAM);

                    recentlyPlayed = "africa_mc";

               }

               break;

     }

}

function playStation(streamUrl:String):void {

     streamSound = new Sound();

     addListeners();

     streamSound.load(new URLRequest(streamUrl), streamContext);

     streamChannel = streamSound.play();

     isPlaying = true;

     streamTimer = new Timer(2000);

     streamTimer.addEventListener(TimerEvent.TIMER, checkPlayState);

     streamTimer.start();

}

function soundIoError(evt:IOErrorEvent):void {

     streamChannel.stop();

     streamSound.close();

     streamSound = null;

     streamChannel = null;

     removeListeners();

     play_state.text = "IO Error";

}

function checkPlayState(evt:TimerEvent):void {

     if (streamSound.isBuffering == true) {

          play_state.text = "Buffering...";

     }

     else {

          play_state.text = "Playing...";

     }

}

function addListeners() {

     streamSound.addEventListener(IOErrorEvent.IO_ERROR, soundIoError);

}

function removeListeners() {

     streamSound.removeEventListener(IOErrorEvent.IO_ERROR, soundIoError);

     streamTimer.removeEventListener(TimerEvent.TIMER, checkPlayState);

}

=========================================================

Its very sad that adobe has created something fully buggy and works only on IDE but not on actual device. More sad part is adobe is not even cared to have a look into the issue.

This topic has been closed for replies.

23 replies

M_S_HAuthor
Inspiring
September 14, 2011

Changing the subject to match the issue description

Adobe Employee
May 3, 2011

MSH,

I am not familiar with your stream URL.

I tried with

http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3

and there is no problem with playing on Android.

You said you get it work with "Test"? If you do, could you mail that file to me and I could check it out.

-ted
M_S_HAuthor
Inspiring
May 3, 2011

Hi Chris / tzeng,

Let me put it in much cleaner way :

What I am trying to achieve?

- Listen / play internet radio (IR) stations.

- Links are taken from : http://wiki.secondlife.com/wiki/Music_streams & few from Shoutcast

What are all the available formats for IR station URL?

1. http://server_name:NNNN/ where NNNN is port number

     - http://stream.radiosai.net:8004

     - http://wjab.streamguys.net:80/

     - http://radio2.trancemission.fm:80/

2. http://server_ip_address:NNNN

     - http://65.60.19.44:80/

     - http://213.246.51.97:8024/

3. http://server_name_OR_ip/stream/xyz

     - http://scfire-ntc-aa03.stream.aol.com:80/stream/1025

     - http://208.80.52.246/ESPNRADIOCMP3

4. http://server_name_OR_ip:NNNN/xyz.mp3

     - http://stream.transmissionfm.com:8000/techno-high.mp3

     - http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3

Please share if anybody came across different format than these.....

What is working on device and what is not working?

Any URL of format 3 & 4 is working on the device.

Any URL of format 1 & 2 is not working on the device.

What happens if the swf is opened in flash player like debugger version (flashplayer_10_sa_debug)?

Tried with 4 URL each of different format. Debugger player is able to play all the stations.

What happens if the swf is opened in IE browser with Flash plugin?

Only URL of format 3 & 4 works.

What happens if 'Test Movie' is used in IDE?

Only URL of format 3 & 4 works.

Now question is why URL with format 1 & 2 fails? Why same links work on debugger version or VLC or windows media player?

I have captured the packets sent(received) from(at) device (HTC Desire HD) using WireShark (on Windows 7). I dont see any option to attach the files. Will try to send as private message.

After a deep search I found that this issue is already faced : http://forums.adobe.com/message/3027799

Thanks and Regards,

MSH

Adobe Employee
May 3, 2011

MSH,

Let me ask this question ( I am in a rush today. Could not read through your message carefully.)

Is there any situation where the app. works on desktop, but fails to work on Android devices?

Thanks,

-ted

Participant
April 29, 2011

I Have the same problem no audio stream over device Galaxy s I9000, AIR Runtime 2.6 Flash Player 10.2

I Compiled with AIR for Android in Flash CS5, in IDE Stream Work Good!!! Compiled .apk not work on Device!

Permission INTERNET is Set!

Any Idea?

Thank's

M_S_HAuthor
Inspiring
April 27, 2011

Just to make sure I tried to trace the output of 'soundObj.isURLInaccessible' and 'soundObj.Url' when checking for 'isBuffering' and got the result as 'false' and 'http://stream.radiosa.net:8004/" which is same as the one used to load. With that its pretty clear that some issue in the Air-Android runtime itself.

Is anybody faced similar problem?

Regards,

MSH

chris.campbell
Legend
April 27, 2011

Hi MSH,

I'm sorry you're running into problems getting this to work on your device.  Thanks for the detailed report, including the source code.  I just tried this out using Flash Builder 4.5 (Burrito).  I had to change the stream URL, as the one you posted appeared to be offline.  Using the default permissions, I found that while the stream played fine on the desktop, it failed to play on my device.  However, if I enabled "android.permission.INTERNET" in my application descriptor, audio played fine on my device (T-Moble G2.)

<android>         <manifestAdditions><![CDATA[                <manifest android:installLocation="auto">                    <uses-permission android:name="android.permission.INTERNET"/>                </manifest>                           ]]></manifestAdditions>     </android> </application>

Can you verify that this permission is set?

Thanks,

Chris

M_S_HAuthor
Inspiring
May 1, 2011

Hi Chris,

I am using Air for Android in flash CS5. In the app_name-app.xml android.permissions.INTERNET is enabled.

<android>
     <manifestAdditions>
     <![CDATA[
     <manifest>
     <uses-permission android:name="android.permission.INTERNET"/>
     </manifest>
     ]]>
     </manifestAdditions>
</android>

I tried several stations but had no luck in playing them on device

Is there any difference in using 'Burrito' and 'Air for Android' extn in flash CS5 for building the apps (I mean w.r.t to .apk generated)?

As far as I think IDE shouldn't matter since the runtime player remains the same...

Could you please share the station URL you have used ?

Thanks and Regards,
MSH