您好:这是一个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中时,它就会起作用。
有什么想法吗?
发布于 2015-01-09 21:14:04
如果它可以在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;如果没有成功,请验证您的流是否可用
发布于 2018-01-04 12:47:44
我知道这是一个非常老的帖子,但以防有人有同样的问题,黑屏播放这个Flex Bug解决方案可能会解决他们的问题。
OSMFSettings.enableStageVideo = false
https://stackoverflow.com/questions/27860041
复制相似问题