Flash Lite 3.0播放FLV和现场直播
五梭发表于2008年4月5日都已经3G了,我们就来点猛的。
ptm.fi测试了在Windows平台使用Flash Media Server 3向手机传输流媒体的功能。一种是用手机播放服务器上的FLV文件,一种是播放服务器上摄像头即时拍摄的视频。Linux平台的在这里。
从Flash Media Server 3播放FLV视频的方法:
- 安装Flash Media Server 3(在这里下载);
- 安装自带了一些FLV实例文件,你可以用它们来测试;
- 在Flash里创建新的Flash Lite 3文件;
- 新建一个视频元件到库里;
- 把这个视频元件拖到舞台,命名;
- 在时间轴输入以下程序:
- 去到发布设置;
- 本地回放安全性设定为“只访问网络”;
- 发布你的SWF文件;
- 传输SWF到你的手机中,应该就能播放服务器的视频了。
// make a new video-object
var video:Video;
// make a new NetConnection-object
var nc:NetConnection = new NetConnection();
// check connection status from server
nc.onStatus = function(info:Object):Void {
status_txt.text=info.code;
if (info.code == "NetConnection.Connect.Success") {
startStreaming();
}
}
// start streaming video to phone
function startStreaming() {
ns = new NetStream(nc);
ns.setBufferTime(5);
video.attachVideo(ns);
// play sample.flv from server
ns.play("sample",0);
}
// show info to user
status_txt.text = "Connecting server...";
// connect FMS 3 video on demand service (default port 1935)
nc.connect("rtmp://你服务器的IP:1935/vod");
播放摄像头实时视频:
- 安装Flash Media Server 3;
- 安装Flash Media Encoder 2(在这里下载);
- 你会看到你摄像头捕获的视频图像;
- 按开始键,它就开始向Flash Media Server传输视频;
- 和上面一样创建Flash文件,当然还有视频元件;
- 插入以下编码:
- 发布和测试。
// in startStreaming()-function
// Flash Media Encoder 2 publish stream name is "livestream"
ns.play("livestream",-1,-1,true);
// start connection to Flash Media Server 3
// Flash Media Encoder 2 publishes Flash Media Server's default
// live publishing point, so connect it
nc.connect("rtmp://你的服务器IP:1935/live");
Popularity: 79% [?]

