Flex的VideoDisplay控件无法打开流

时间:2022-01-25 18:59:22

I'm trying to make VideoDisplay playing media with FlashDevelop. Here's the source of my application:

我正在尝试使用FlashDevelop制作VideoDisplay播放媒体。这是我的应用程序的来源:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
    <![CDATA[
        import mx.events.VideoEvent;

        private function pause():void 
        {
            if (moo_player.state == VideoEvent.PLAYING)
                moo_player.pause(); else
            if (moo_player.state == VideoEvent.PAUSED)
                moo_player.play();
        }
    ]]>
    </mx:Script>

    <mx:Panel>
        <mx:VideoDisplay 
            source="bar.flv"
            width="640"
            height="480"
            maintainAspectRatio="true"
            id="moo_player"
            autoPlay="true"
            doubleClick="pause();" 
            doubleClickEnabled="true"
        />
    </mx:Panel>
</mx:Application>

The problem is when i build application and run it (unfortunately, got no idea how to run it without KMPlayer or Mozilla - Flash Player is a plugin afaik) i got no video. The movie file is in the same directory as application's "Application.flv" one. But if i reload application (within player or browser) a few times, video starts.

问题是当我构建应用程序并运行它(不幸的是,不知道如何在没有KMPlayer或Mozilla的情况下运行它 - Flash Player是一个插件afaik)我没有视频。电影文件与应用程序的“Application.flv”目录位于同一目录中。但如果我重新加载应用程序(在播放器或浏览器中)几次,视频就会启动。

So, here are my questions:

所以,这是我的问题:

  • what's wrong with VideoDisplay component and how to fix this 'non-playing'?

    VideoDisplay组件有什么问题以及如何修复这种“不玩”?

  • what's the better way to execute application than running it within movie player or browser?

    执行应用程序比在电影播放器​​或浏览器中运行更好的方法是什么?

P.S.: please, do not get mad of my knowledge lacks - i began to use Flex nearly 30 minutes ago.

P.S。:请不要因为我的知识缺乏而生气 - 我差不多30分钟就开始使用Flex了。

3 个解决方案

#1


1  

You should be using Spark components, not MX components. Try this:

您应该使用Spark组件,而不是MX组件。尝试这个:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:VideoPlayer source="bar.flv" width="640" height="480" />

</s:Application>

#2


0  

There's some issues with video display internally in the component. One of the only flex components that's kind of poorly done in some ways. Please don't let it discourage you from exploring Flex.

组件内部的视频显示存在一些问题。在某些方面做得不好的唯一灵活组件之一。请不要让它阻止你去探索Flex。

Create a custom component that extends it, create a file named CustomVideoDisplay.as with this code:

创建一个扩展它的自定义组件,使用以下代码创建名为CustomVideoDisplay.as的文件:

package
{
    import mx.controls.VideoDisplay;

public class CustomVideoDisplay extends VideoDisplay
{      
    [Bindable]
    override public function get source():String
    {
        return super.source;
    }

    override public function set source(value:String):void
    {
        super.source = value;

        play();
    }

    public function CustomVideoDisplay()
    {
        super();
    }
}

}

}

Then add this into your root <application> tag :

然后将其添加到root 标记中:

 xmlns:local="*"

And for your video component, refer to it as:

对于您的视频组件,请将其称为:

<local:CustomVideoDisplay 
        source="bar.flv"
        width="640"
        height="480"
        maintainAspectRatio="true"
        id="moo_player"
        autoPlay="true"
        doubleClick="pause();" 
        doubleClickEnabled="true"
    />

Let me know if this doesn't do the trick for you!

如果这不适合你,请告诉我!

#3


0  

Well, i thought: my player will be ran at client-side of web project, and in FireFox that code runs successfully each of seven runs. I think this would be enough for testing and implementation.

好吧,我想:我的播放器将在Web项目的客户端运行,而在FireFox中,代码运行成功运行七次。我认为这对于测试和实施来说已经足够了。

Thanks everyone for the trouble-taking!

谢谢大家的麻烦!

#1


1  

You should be using Spark components, not MX components. Try this:

您应该使用Spark组件,而不是MX组件。尝试这个:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <s:VideoPlayer source="bar.flv" width="640" height="480" />

</s:Application>

#2


0  

There's some issues with video display internally in the component. One of the only flex components that's kind of poorly done in some ways. Please don't let it discourage you from exploring Flex.

组件内部的视频显示存在一些问题。在某些方面做得不好的唯一灵活组件之一。请不要让它阻止你去探索Flex。

Create a custom component that extends it, create a file named CustomVideoDisplay.as with this code:

创建一个扩展它的自定义组件,使用以下代码创建名为CustomVideoDisplay.as的文件:

package
{
    import mx.controls.VideoDisplay;

public class CustomVideoDisplay extends VideoDisplay
{      
    [Bindable]
    override public function get source():String
    {
        return super.source;
    }

    override public function set source(value:String):void
    {
        super.source = value;

        play();
    }

    public function CustomVideoDisplay()
    {
        super();
    }
}

}

}

Then add this into your root <application> tag :

然后将其添加到root 标记中:

 xmlns:local="*"

And for your video component, refer to it as:

对于您的视频组件,请将其称为:

<local:CustomVideoDisplay 
        source="bar.flv"
        width="640"
        height="480"
        maintainAspectRatio="true"
        id="moo_player"
        autoPlay="true"
        doubleClick="pause();" 
        doubleClickEnabled="true"
    />

Let me know if this doesn't do the trick for you!

如果这不适合你,请告诉我!

#3


0  

Well, i thought: my player will be ran at client-side of web project, and in FireFox that code runs successfully each of seven runs. I think this would be enough for testing and implementation.

好吧,我想:我的播放器将在Web项目的客户端运行,而在FireFox中,代码运行成功运行七次。我认为这对于测试和实施来说已经足够了。

Thanks everyone for the trouble-taking!

谢谢大家的麻烦!