如何使用flex在运行时为RTMP播放器设置流名称?

问题描述 投票:0回答:2

您好:这是RTMP播放器的代码

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2009/12/14/playing-a-video-from-an-rtmp-server-using-the-spark-videoplayer-control-in-flex-4/ -->
<s:Application name="Spark_VideoPlayer_DynamicStreamingVideoSource_test"
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark">

    <s:VideoPlayer id="vidPlyr"
            loop="true"
            muted="true"
            left="100" right="100"
            top="100" bottom="100"
            horizontalCenter="0" verticalCenter="0">
        <s:source>
            <s:DynamicStreamingVideoSource id="source" host="rtmp://fmsexamples.adobe.com/vod/" streamType="recorded">
                <s:DynamicStreamingVideoItem is="item1" streamName="mp4:_cs4promo_1000.f4v" />
            </s:DynamicStreamingVideoSource>
        </s:source>
    </s:VideoPlayer>

</s:Application>

如何使用as3代码在运行时设置streamName?

我测试过:

source.host="myRTMP";
Item1.streamName="myflv";

但这没用!

但是,当参数嵌入到mxml中时,它可以工作

任何的想法 ?

actionscript-3 flex actionscript red5
2个回答
0
投票

如果它适用于mxml,这应该适用于as3。解决方案1:在创建完成事件或任何其他事件触发时设置视频播放器参数:

    protected function application1_creationCompleteHandler(event:FlexEvent):void
    {
        source.host=myRTMP;
        Item1.streamName=myflv;

    }

解决方案2:将videoplayer参数绑定到变量:

在MXML中:

<s:VideoPlayer id="vidPlyr"
            loop="true"
            muted="true"
            left="100" right="100"
            top="100" bottom="100"
            horizontalCenter="0" verticalCenter="0">
        <s:source>
            <s:DynamicStreamingVideoSource id="source" host="{myRTMP}"    
                streamType="recorded">
                <s:DynamicStreamingVideoItem is="item1" streamName="{myflv}" />
            </s:DynamicStreamingVideoSource>
        </s:source>
    </s:VideoPlayer>

在ActionScript中:

[Bindable] public var myRTMP:String;
[Bindable] public var myflv:String;

如果这不成功,请验证您的流是否可用


0
投票

我知道这是一个非常古老的帖子,但万一有人遇到同样的问题,Black Screen在播放这个Flex Bug解决方法可能会解决他们的问题。

OSMFSettings.enableStageVideo = false

https://issues.apache.org/jira/browse/FLEX-33856

© www.soinside.com 2019 - 2024. All rights reserved.