[AS代码]FMS播放FLV视频
2012-02-06 12:08:47 来源:本站整理//连接并播放
var my_nc:NetConnection = new NetConnection();
my_nc.connect("rtmp://192.168.1.86/pyp");
var my_ns:NetStream = new NetStream(my_nc);
my_video.attachVideo(my_ns);
my_video.smoothing = true;
my_ns.play("flv/test");
//控制函数
function play_flv() {
btn._btn.label = "暂停";
my_ns.pause(false);
}
function pause_flv() {
btn._btn.label = "播放";
my_ns.pause(true);
}
function stop_flv() {
btn._btn.label = "播放";
my_ns.seek(0);
my_ns.pause(true);
}
this.click = function() {
if (btn._btn.label == "暂停") {
pause_flv();
} else if (btn._btn.label == "播放") {
play_flv();
}
};
btn._btn.addEventListener("click", this);
var stop_Obj:Object = new Object();
stop_Obj.click = function() {
stop_flv();
};
btn.stop_btn.addEventListener("click", stop_Obj);
//音量控制
var my_sound:Sound = new Sound();
my_sound.setVolume(50)
my_sound.attachSound(my_video);
function setSound() {
my_sound.setVolume(btn.Sound_txt.selectedItem.label);
}
var sound_obj:Object = new Object();
sound_obj.change = function() {
setSound();
};
btn.Sound_txt.addEventListener("change", sound_obj);
//时间显示
var flv_time:Number;
my_ns.onMetaData = function(info) {
flv_time = info.duration;
};
//实时处理部分
onEnterFrame = function () {
btn.time_txt.text = Math.floor(my_ns.time/60)+":"+Math.floor(my_ns.time%60)+"/"+Math.floor(flv_time/60)+":"+Math.floor(flv_time%60);
load2_mc._x=load1_mc._width*(my_ns.time/flv_time)
if(_xmou**>5 && _*mouse<395 && _ymouse>270 && _ymouse<292){
btn._visible=true
}else{
btn._visible=false
}
};
//播放完毕
my_ns.onStatus = function(info) {
if (info.code == "NetStream.Play.Stop") {
my_ns.seek(0);
}
};
//全屏设置
var full_obj:Object = new Object();
full_obj.click = function() {
if (btn.full.label == "全屏") {
btn.full.label = "还原";
Stage["displayState"] = "fullScreen";
} else if (btn.full.label == "还原") {
btn.full.label = "全屏";
Stage["displayState"] = "normal";
}
};
btn.full.addEventListener("click", full_obj);
//检测键盘
var key_obj:Object = new Object();
key_obj.onKeyDown = function() {
if (Key.isDown(Key.ESCAPE)) {
btn.full.label = "全屏";
Stage["displayState"] = "normal";
}
};
Key.addListener(key_obj);
//播放进度与定点播放
load1_mc.onPress=function(){
load2_mc._x=_xmouse
my_ns.seek(load2_mc._x/load1_mc._width*flv_time)
}
- ››asp.net页面弄成伪静态页面
- ››Asp.net 中将汉字转换成拼音的方法
- ››ASP.NET及JS中的cookie基本用法
- ››ASP.NET获取MS SQL Server安装实例
- ››asp.net实现调用百度pai 在线翻译英文转中文
- ››ASP.NET页面选项进行提示判断
- ››Asp.net定时执行程序
- ››ASP.NET中利用DataList实现图片无缝滚动
- ››ASP.NET验证控件RequiredFieldValidator
- ››ASP.NET中使用System.Net.Mail发邮件
- ››ASP.NET中获取用户控件中控件的ID
- ››ASP.NET中FileBytes写成文件并存档
更多精彩
赞助商链接