[AS代码]FMS播放FLV视频
//连接并播放
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)
}
热门文章推荐
- 纯HLS(m3u8)跨平台技术(HLSPlayer,m3u8Player跨平台多终端)
- DiscuzX3.2酷播视频插件(dz论坛自定义视频插件带广告
- [微信视频]实现网站中的视频在微信平台上正常播放(超多组图)
- [rtsp]海康威视监控摄像头实现web端无插件监控实拍效果
- 很酷,酷播wordpress视频插件(支持PC/安卓/苹果跨平台播放)
- [组图]微信视频技术:支持微信视频直播和视频点播
- [AS3]as3.0的rtmp流媒体播放器写法源代码示例
- 一步一步教你制作FLV网页视频播放器