·您当前的位置:首页 > 技术教程 > 播放器教程 >

[AS代码]FMS播放FLV视频

时间:2011-08-08 10:18CuPlayer.com
[AS代码]FMS播放FLV视频,FMS播放,rtmp协议

//连接并播放
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)
}

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器