开发者

Flex (AIR) android Shoutcast app issues

I'm attempting to build an android AIR app based off of the Codebass player (http://codebass.net/2010/09/01/codebass-streaming-radio-player/)

It's not meant for android and the actionscript works fine when running it on the desktop (and in the flashbuilder emulator) however on the device it doesn't play sound. It seems to initialize the sound because you can adjust media volume, however the stream refuses to play.

I'm not sure if it's the loading of the stream or the playing that it has issues with.

Stream Loading function:

public function load(source:String, restarting:Boolean = false):void {
        this.source = source;

        if (sound) {
            sound.close();
            sound = null;
        }
        songLoaded = false;
        dispatchEvent(new Event("updateDuration"));
        stop();

        if(sound) {
            sound.removeEventListener(Event.OPEN, onSoundLoaded);
            sound.removeEventListener(Event.OPEN, onRestartSoundLoaded);
            sound.removeEventListener(IOErrorEvent.IO_ERROR, onSoundLoadedError);
        }
        sound = new Sound();

        if (!restarting) {
            sound.addEventListener(Event.OPEN, onSoundLoaded, false, 0, true);
            streamRestartCount = 0;
        } else {
            sound.addEventListener(Event.OPEN, onRestartSoundLoaded, false, 0, true);
        }

        sound.addEventListener(IOErrorEvent.IO_ERROR, onSoundLoadedError, false, 0, true);

        var ur:URLRequest = new URLRequest(source);
        sound.load(ur);
    }

Stream Playing function:

public开发者_如何学C function play():void {
        if (stopped) {
            SoundMixer.stopAll()
            soundChannel = sound.play(0);
        } else {
            SoundMixer.stopAll()
            soundChannel = sound.play(lastPosition);    
        }
        stopped = false;
        // if we've previously set a volume, use the transform again
        if (volumeTransform) {
            trace("set vol: " + volumeTransform.volume);
            soundChannel.soundTransform = volumeTransform;
        }
        heartBeat.start();
    }

Is there something simple I'm missing? Or is it hopeless to not write the code from scratch for the air for android skd?


I have exactly the same trouble and I found an Adobe employee checked and determined it's a bug in AIR. It's NOT caused by manifest because eclipse (emulator) is also emulate manifest part as well.

http://forums.adobe.com/thread/841997


That code should work. In all probability, you're missing the required permissions in the manifest for Android. When you install the application, it should ask you if you want to install and give you a list of things the application does. It should say 'connect to the internet'. If that's not there, you won't get far.

For this to work, open the manifest file and include this in it:

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

This will give you access to the internet. If you're still having trouble, you should try to debug the application as mentioned in my blog post.


since the first release of the air2 for android, this manifestAddition tag has changed a bit.
so you should write it in a form of

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://ns.adobe.com/air/application/2.5">
    <id>...</id>
    <filename>...</filename>
    <name>...</name>
    <versionNumber>v...</versionNumber>
    <initialWindow>
        <content></content>
        <visible>true</visible>
        <fullScreen>...</fullScreen>
        <autoOrients>true</autoOrients>
        <width>480</width>
        <height>800</height>
    </initialWindow>
    <!--choose the appropriates separated by space-->
    <supportedProfiles>mobileDevice desktop</supportedProfiles>
    <android>
        <manifestAdditions>
            <![CDATA[
                <manifest android:installLocation='auto'>
                    <uses-permission android:name="android.permission.INTERNET" />
                    <!--for playing sounds you don't need special permissions-->
                    <supports-screens android:normalScreens="true"/>
                    <uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/>
                    <application android:enabled="true">
                        <activity>...</activity>
                    </application>
                </manifest>
           ]]>
        </manifestAdditions>
    </android>

    <icon>
        <image48x48>icon48x48.png</image48x48>
        <image72x72>icon72x72.png</image72x72>
    </icon>
</application>

you can read more about it in corlan's blog: About AIR Applications and Android Permissions
find out more about the current 2.6 air release at the official site: Adobe AIR

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜