控制FLVPlayback的NetConnection
来源:互联网 发布:周杰伦的才华 知乎 编辑:程序博客网 时间:2024/05/22 03:07
很不幸,我把原文的地址给忘掉了。这是国外一个论坛上的帖子,希望对大家有帮助。 Accessing the NetConnection Object in FLVPlayback Posted At : August 14, 2009 9:13 AM | Posted By : Stefan Richter | Related Categories: Components , FMS , Videos & Players
There are situations where it is necessary to call a server side method on FMS. Some CDNs, for example Limelight, used to or maybe still do require you to call the FCSubscribe method in order to request a live stream. This send a signals to the Edge server to pull the live stream from the Origin server if it is not already being delivered to that Edge. While this delivery method and stream setup routine is being phased out across most CDNs I thought it may be useful to post a (slightly hackish) workaround to make this setup work with the FLVPlayback component.
The problem with the FLVPlayback component is that there is no obvious, simple way to obtain a reference to the NetConnection Object it uses under the hood. Sure, the ncMgr.getNetConnection let's you grab it but only once the connection is established, and while you can implement a custom NCManager class, this is not trivial and after all a NetConnection is being maintained already by the component, so why reinvent the wheel? The following code is clearly not something I am proud of, but it worked at the time when I needed it. It was used to get a live stream working with the FLVPlayback component streaming from Limelight about a year or two ago. 代码: // listen to player events and kill manual connection once we're streaming Hopefully this is helpful to someone.
player.addEventListener("playing", playListener);
player.addEventListener("stateChange", stateListener);
player.addEventListener("ready", readyListener);
/* this is the hack: check once every frame if the NC has been defined inside the FLVPlayback component */
this.onEnterFrame = function()
{
if (player.ncMgr.getNetConnection() != undefined)
{
this.onEnterFrame = null;
delete this.onEnterFrame;
trace("got NC");
//subscribe(streamName); }
}
var nc:NetConnection;
var serverName:String = "server.llnwd.net";
var appName:String = "account_name/_definst_";
var streamName:String = "live";
var source_Str = "rtmp://" + serverName + "/" + appName + "/" + streamName;
// start up by setting the contentPath (now called source in newer versions of the component)
player.contentPath = source_Str;
function subscribe(name:String)
{
nc = player.ncMgr.getNetConnection();
nc.onFCSubscribe = function(info:Object)
{
trace("onFCSubscribe: " + info.code);
clearInterval(int_id);
if (info.code == "NetStream.Play.StreamNotFound")
{
// handle error, retry after a few secs or similar }
else if (info.code == "NetStream.Play.Start")
{
// we're successfully subscribed }
else
{
// handle error }
};
// not used right now
nc.onFCUnsubscribe = function(info:Object)
{
}
trace("subscribing to " + name);
nc.call("FCSubscribe",null,name);
}
// can be used to unsubscribe from stream
function unsubscribe(name:String)
{
nc.call("FCUnsubscribe",null,name);
}
- 控制FLVPlayback的NetConnection
- FLVplayback组件
- AS PHP的NETCONNECTION连接注意
- 关于Red5 NetConnection.Connect.Rejected的问题
- Flvplayback放大以后清晰
- NetConnection.Call.BadVersion 解决方案
- NetConnection 工具类
- rtmp NetConnection 状态
- NetConnection通信结构(基于对极客学院的代码的改进,直接使用对象进行通信)
- FMS客户端 ActionScript NetConnection类
- fms3 NetConnection.Connect.Rejected 问题
- RED5 NetConnection.Connect.InvalidApp 解决办法
- Introduction to Flash NetConnection/NetStream
- FMS 解决NetConnection.Connecti.Failed
- RTMPdump源码分析: NetConnection(5)
- as3 netconnection 例子
- 用FLVPlayback组件给.swf视频加上播放进度条
- flash中NetConnection与NetStream知识整理
- Drupal 6 用户信息字段扩展。
- Flex IOC框架概览
- Ext.state.Manager.setProvider()用法
- asp.net Ajax sys未定义
- 例句和句型:9.05
- 控制FLVPlayback的NetConnection
- 解决安装VC++6.0过程中Error Lauching acmeboot.exe问题
- 网站设计高手进阶十篇--1.2
- javascript Tree code
- 装饰模式(c++)
- 黄帝内经五行理论
- linux上重新安装sap NW7.0时需手动删除一些东西
- [需求挖掘]当当网引发的思考
- C++垃圾回收 之 智能指针增强方案 (一)