【问题标题】:Flex (AIR) android Shoutcast app issuesFlex (AIR) android Shoutcast 应用程序问题
【发布时间】:2011-07-23 07:02:48
【问题描述】:

我正在尝试基于 Codebass 播放器 (http://codebass.net/2010/09/01/codebass-streaming-radio-player/) 构建一个 android AIR 应用程序

它不适用于 android,并且 actionscript 在桌面(和 flashbuilder 模拟器)上运行时运行良好,但在设备上它不播放声音。它似乎初始化了声音,因为您可以调整媒体音量,但是流拒绝播放。

我不确定是流的加载还是播放存在问题。

流加载功能:

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);
    }

流播放功能:

public 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();
    }

我缺少一些简单的东西吗?还是不为android skd从头开始编写代码是没有希望的?

【问题讨论】:

    标签: android apache-flex air flash-builder shoutcast


    【解决方案1】:

    该代码应该可以工作。很可能,您在 Android 清单中缺少所需的权限。当您安装应用程序时,它应该会询问您是否要安装并为您提供应用程序所做的事情的列表。它应该说“连接到互联网”。如果那不在那里,你就不会走得太远。

    为此,请打开清单文件并将其包含在其中:

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

    这将使您能够访问互联网。如果还是有问题,请尝试debug the application as mentioned in my blog post

    【讨论】:

    • manifest 权限在那里,我办公室没有wifi。今晚我会在家里尝试调试器。
    【解决方案2】:

    自从air2 for android 首次发布以来,这个manifestAddition 标签已经发生了一些变化。
    所以你应该把它写成

    <?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>
    

    您可以在 corlan 的博客中了解更多信息:About AIR Applications and Android Permissions
    在官网了解更多关于当前 2.6 air 发布的信息:Adobe AIR

    【讨论】:

      【解决方案3】:

      我遇到了完全相同的问题,我发现一位 Adob​​e 员工检查并确定这是 AIR 中的一个错误。 它不是由清单引起的,因为 eclipse(模拟器)也是模拟清单部分。

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

      【讨论】:

        猜你喜欢
        • 2012-09-22
        • 1970-01-01
        • 2011-06-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多