Skip navigation
Currently Being Moderated

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

Apr 25, 2011 8:32 PM

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.

 
Replies
  • Chris Campbell
    8,778 posts
    May 4, 2010
    Currently Being Moderated
    Apr 27, 2011 2:35 PM   in reply to M.S.H

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 29, 2011 4:12 AM   in reply to M.S.H

    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

     
    |
    Mark as:
  • Chris Campbell
    8,778 posts
    May 4, 2010
    Currently Being Moderated
    May 2, 2011 5:40 PM   in reply to M.S.H

    Are you using the labs release of the AIR publishing component of Flash CS5?  I used Flash Builder 5.5 in my test.  For the stream URL I used http://208.80.52.246/ESPNRADIOCMP3

     

    I've asked the team responsible for Android development to take a look at this thread so hopefully we'll get more feedback soon.

     

    Thanks,

    Chris

     
    |
    Mark as:
  • Currently Being Moderated
    May 2, 2011 11:45 PM   in reply to M.S.H

    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
     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2011 8:51 AM   in reply to M.S.H

    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

     
    |
    Mark as:
  • Currently Being Moderated
    May 3, 2011 9:28 AM   in reply to M.S.H

    Could you send me the project file?

    My email address is zeng@adobe.com

     

    Thanks,

     

    -ted

     
    |
    Mark as:
  • Currently Being Moderated
    May 4, 2011 9:17 AM   in reply to M.S.H

    You probably sent the mail to Chris. Chris forwarded the file to me.

    We will take a look at this and get back to you.  -ted

     
    |
    Mark as:
  • Chris Campbell
    8,778 posts
    May 4, 2010
    Currently Being Moderated
    May 4, 2011 4:02 PM   in reply to tzeng

    Hi MSH,

    Thank you for the sample code and your investigation!  Would you mind adding a new bug for this at http://bugbase.adobe.com?  Please include the latest details, instructions and attach your sample code/project.  It would be great if you could then post a link to the bug here so others effected can add their votes and comments.  I'll make sure to note your bug number in our "hot topics" page which is already tracking this issue.

     

    Thanks,

    Chris

     
    |
    Mark as:
  • Chris Campbell
    8,778 posts
    May 4, 2010
    Currently Being Moderated
    May 23, 2011 11:32 AM   in reply to M.S.H

    Hi MSH,

    I'm looking into it.  The bug is still viewable internally (currently set to open/to test) but I'm seeing the same message when viewing it externally.  I'll let you know what I find out.

     

    Chris

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 13, 2011 12:12 PM   in reply to Chris Campbell

    Has this bug been found yet?  Because I am having the same problem with a player I wrote to stream a radio station, and the issue of setting the INTERNET permission is set (double checked).

     
    |
    Mark as:
  • Chris Campbell
    8,778 posts
    May 4, 2010
    Currently Being Moderated
    Sep 13, 2011 6:23 PM   in reply to zombee

    This bug was deferred for the upcoming AIR release.  I'd highly recommend visiting the bug (using the URL above) and adding your vote and comments.

     

    Thanks,
    Chris

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 13, 2011 6:40 PM   in reply to Chris Campbell

    Thanks, i'll do that. In the mean time I think I have an idea of a work around if any one is interested.

     

    embed a html 5 page in your flex app with an audio tag that plays the stream, use javascript functions to control the audio, and call the javascript functions from flex using the external command.

     

    This is only theory at the moment, haven't had time to test it.

     

    Thanks again, good night.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points