弗莱克斯' VideoDisplay 控件未打开流

发布于 2024-11-19 01:23:17 字数 1326 浏览 2 评论 0原文

我正在尝试使用 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>

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

所以,这是我的问题:

  • VideoDisplay 有什么问题吗? 组件以及如何解决这个问题 ‘不玩’?

  • 有什么更好的方法吗 执行应用程序而不是运行 它在电影播放器​​或浏览器中?

PS:请不要因为我的知识匮乏而生气 - 我大约 30 分钟前开始使用 Flex。

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

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

So, here are my questions:

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

  • 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

找回味觉 2024-11-26 01:23:17

您应该使用 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>

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

<?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>
迟到的我 2024-11-26 01:23:17

组件内部的视频显示存在一些问题。唯一在某些方面做得很差的柔性组件之一。请不要让它阻止您探索 Flex。

创建一个扩展它的自定义组件,使用以下代码创建一个名为 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();
    }
}

}

然后将其添加到您的根 标记中:

 xmlns:local="*"

对于您的视频组件,将其引用为:

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

如果这对您不起作用,请告诉我!

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.

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

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 :

 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!

愿与i 2024-11-26 01:23:17

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

谢谢大家不辞辛苦!

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.

Thanks everyone for the trouble-taking!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文