//
判断用户按下的键盘键值,并作出相应处理
private
function Keyboard_down(evt:KeyboardEvent):
void
{
var keycode:String = String(evt.keyCode);
switch(
true)
{
//
按下"↑"键(放大音量)
case keycode == "38":
if (soundVolumeDisplayBG.parent ==
null)
{
interfaceinitialization.soundbg.addChild(soundVolumeDisplayBG);
}
if (InterfaceButton.soundbar.x < soundbarRange.x + soundbarRange.width - 1)
{
InterfaceButton.soundbar.x += 5;
soundbarFunc();
}
break;
//
按下"↓"键(减小音量)
case keycode == "40":
if (soundVolumeDisplayBG.parent ==
null)
{
interfaceinitialization.soundbg.addChild(soundVolumeDisplayBG);
}
if (InterfaceButton.soundbar.x > soundbarRange.x)
{
InterfaceButton.soundbar.x -= 5;
soundbarFunc();
}
break;
//
按下"←"键(快退)
case keycode == "37":
video.Rewind();
break;
//
按下"→"键(快进)
case keycode == "39":
video.FastForward();
break;
}
}
//
判断用户抬起的键盘键值,并作出相应处理
private
function Keyboard_up(evt:KeyboardEvent):
void
{
var keycode:String = String(evt.keyCode);
switch(
true)
{
//
按下空格键(暂停播放或恢复播放)
case keycode == "32":
if (ButtonFOControl.btnboo)
{
video.pausevideo();
ButtonFOControl.btnboo =
false;
InterfaceButton.puasebtn.removeEventListener(MouseEvent.CLICK, pause_click);
if (InterfaceButton.playbtn.hasEventListener(MouseEvent.CLICK) ==
false)
{
InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
}
}
else
{
video.resumevideo();
ButtonFOControl.btnboo =
true;
InterfaceButton.playbtn.removeEventListener(MouseEvent.CLICK, play_click);
InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
}
break;
//
按下"↑"键(放大音量)
case keycode == "38":
if (soundVolumeDisplayBG.parent !=
null)
{
interfaceinitialization.soundbg.removeChild(soundVolumeDisplayBG);
}
break;
//
按下"↓"键(减小音量)
case keycode == "40":
if (soundVolumeDisplayBG.parent !=
null)
{
interfaceinitialization.soundbg.removeChild(soundVolumeDisplayBG);
}
break;
//
按下Ctrl+Enter键(全屏)
case evt.ctrlKey ==
true && keycode == "13":
if (stage.displayState == "normal")
{
stage.displayState = "fullScreen";
}
break;
}
}
private
function ResizeHalder(evt:Event):
void
{
CalculateVideoSize.setvideosize(video, PlayerVideo.video_width, PlayerVideo.video_height);
interfaceinitialization.ResetPosition(
this.stage.stageWidth,
this.stage.stageHeight);
}
private
function play_click(evt:MouseEvent):
void
{
if (ButtonFOControl.stopboo)
{
if (video.videoprocess !=
null)
{
this.stage.removeChild(video.videoprocess);
video.videoprocess =
null;
}
this.removeChild(video);
video =
new PlayerVideo();
this.addChildAt(video, 0);
video.playvideo(SaveConnection.url);
ButtonFOControl.stopboo =
false;
ButtonFOControl.btnboo =
true;
this.stage.addEventListener(Event.ENTER_FRAME, EnterFrameHalder);
InterfaceButton.stopbtn.addEventListener(MouseEvent.CLICK, stop_click);
}
else
{
video.resumevideo();
InterfaceButton.playbtn.removeEventListener(MouseEvent.CLICK, play_click);
InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
}
}
private
function pause_click(evt:MouseEvent):
void
{
if (ButtonFOControl.btnboo)
{
video.pausevideo();
InterfaceButton.puasebtn.removeEventListener(MouseEvent.CLICK, pause_click);
if (InterfaceButton.playbtn.hasEventListener(MouseEvent.CLICK) ==
false)
{
InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
}
}
}
private
function stop_click(evt:MouseEvent):
void
{
video.stopvideo();
if (ButtonFOControl.processboo && video.videoprocess !=
null)
{
this.stage.removeChild(video.videoprocess);
video.videoprocess =
null;
}
InterfaceButton.stopbtn.removeEventListener(MouseEvent.CLICK, stop_click);
this.stage.removeEventListener(Event.ENTER_FRAME, EnterFrameHalder);
InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
updateplayer();
}
//
逐帧函数
private
function EnterFrameHalder(evt:Event):
void
{
updatevideoinfo();
}
private
function updatevideoinfo():
void
{
//
获取加载百分比
loadnum = video.loadprogress();
//
获取播放百分比
playnum = video.playprogress();
//
判断是否需要更新加载条
if (InterfaceButton.loadprogress.width!=InterfaceButton.loadbg.width)
{
Draws.drawroundrectsNotreturnvalue(InterfaceButton.loadprogress, loadnum * InterfaceButton.loadbg.width, 6, 4, 0, 0, 0x696969);
}
//
判断是否能更新播放进度条以及滑块
if (PlayerVideo.VideoTime != 0 && InterfaceButton.puasebtn.visible)
{
if (InterfaceButton.videobarbtn.visible ==
false)
{
InterfaceButton.videobarbtn.visible =
true;
}
Draws.drawroundrectsNotreturnvalue(InterfaceButton.playprogress, playnum * InterfaceButton.loadbg.width, 6, 4, 0, 0, colors);
if (videoBarEventHalder)
{
InterfaceButton.videobarbtn.x = InterfaceButton.playprogress.x + InterfaceButton.playprogress.width - (InterfaceButton.videobarbtn.width / 2);
}
}
//
更新播放时间
InterfaceButton.playtimestring = video.PlayComputTime();
InterfaceButton.TimeText.text = InterfaceButton.playtimestring + "/" + InterfaceButton.conttimestring;
InterfaceButton.TimeText.setTextFormat(InterfaceButton.textformat);
}
//
更新播放
private
function updateplayer():
void
{
//
更新按钮状态
InterfaceButton.puasebtn.visible =
false;
InterfaceButton.playbtn.visible =
true;
//
更新加载进度条
InterfaceButton.loadprogress.graphics.clear();
//
更新播放进度条
InterfaceButton.playprogress.graphics.clear();
//
更新播放进度滑块位置
InterfaceButton.videobarbtn.x = InterfaceButton.playprogress.x + InterfaceButton.playprogress.width - (InterfaceButton.videobarbtn.width / 2);
//
更新播放时间
InterfaceButton.TimeText.text = "00:00/00:00";
InterfaceButton.TimeText.setTextFormat(InterfaceButton.textformat);
}
//
视频快进
private
function FF_click(evt:MouseEvent):
void
{
video.FastForward();
}
//
视频快退
private
function RW_click(evt:MouseEvent):
void
{
if (ButtonFOControl.processboo && video.videoprocess !=
null)
{
this.stage.removeChild(video.videoprocess);
video.videoprocess =
null;
}
video.Rewind();
}
//
声音滑块鼠标按下
private
function soundbar_down(evt:MouseEvent):
void
{
InterfaceButton.soundbar.startDrag(
false, soundbarRange);
//
添加逐帧事件
InterfaceButton.soundvaluebg.addEventListener(Event.ENTER_FRAME, soundbarhalder);
interfaceinitialization.soundbg.addChild(soundVolumeDisplayBG);
}
private
function soundbarhalder(evt:Event):
void
{
soundbarFunc();
}
private
function soundbarFunc():
void
{
//
计算需绘制的宽度
countwidth = InterfaceButton.soundbar.x - InterfaceButton.soundvaluebg.x + 4;
//
重新绘制声音显示条
Draws.drawroundrectsNotreturnvalue(InterfaceButton.soundvalue, countwidth, 6, 3, 0, 0, colors);
displayNum = video.DragBarSetSoundVolume(countwidth, soundbarwidth);
soundVolumeDisplayBG.x = InterfaceButton.soundbar.x - 12;
soundVolumeDisplayBG.y = InterfaceButton.soundbar.y - 21;
displayNum = Math.round(displayNum * 100);
SVText.text = String(displayNum);
SVText.x = (soundVolumeDisplayBG.width - SVText.textWidth)/2 -3;
}
//
声音滑块鼠标抬起
private
function soundbar_up(evt:MouseEvent):
void
{
//
停止拖动
InterfaceButton.soundbar.stopDrag();
//
移除逐帧事件
InterfaceButton.soundvaluebg.removeEventListener(Event.ENTER_FRAME, soundbarhalder);
if (soundVolumeDisplayBG.parent !=
null)
{
interfaceinitialization.soundbg.removeChild(soundVolumeDisplayBG);
}
if (videoBarEventHalder ==
false)
{
video.resumevideo();
videoBarEventHalder =
true;
}
}
//
点击喇叭静音或恢复原来音量
private
function horn_click(evt:MouseEvent):
void
{
video.Mute(soundbarwidth);
}
//
点击工具按钮事件响应方法
private
function tools_click(evt:MouseEvent):
void
{
}
//
点击皮肤按钮事件响应方法
private
function skin_click(evt:MouseEvent):
void
{
if (skinbg.visible ==
false)
{
skinbg.visible =
true;
TweenLite.to(skinbg, 1, { alpha:1, ease:Back.easeInOut } );
}
else
{
TweenLite.to(skinbg, 1, { alpha:0, ease:Back.easeOut } );
skinbg.visible =
false;
}
}
//
点击全屏按钮事件响应方法
private
function Full_click(evt:MouseEvent):
void
{
switch (stage.displayState)
{
case "normal" :
stage.displayState = "fullScreen";
break;
case "fullScreen" :
default :
stage.displayState = "normal";
break;
}
}
private
function videobar_down(evt:MouseEvent):
void
{
//
video.pausevideo();
videoBarEventHalder =
false;
InterfaceButton.videobarbtn.startDrag(
false, videoBarRange);
//
添加音量滑块逐帧事件
InterfaceButton.videobarbtn.addEventListener(Event.ENTER_FRAME, videoBarHalder);
}
private
function videoBarHalder(evt:Event):
void
{
Draws.drawroundrectsNotreturnvalue(InterfaceButton.playprogress, InterfaceButton.videobarbtn.x - InterfaceButton.loadbg.x + InterfaceButton.videobarbtn.width/2, 6, 4, 0, 0, colors);
}
private
function videobar_up(evt:MouseEvent):
void
{
//
移除音量滑块逐帧事件
InterfaceButton.videobarbtn.removeEventListener(Event.ENTER_FRAME, videoBarHalder);
InterfaceButton.videobarbtn.stopDrag();
//
计算当前视频滑块按钮所在位置时间点
timenum = PlayerVideo.VideoTime / InterfaceButton.loadbg.width * (InterfaceButton.videobarbtn.x - InterfaceButton.loadbg.x + InterfaceButton.videobarbtn.width / 2);
video.JumpVideo(timenum);
//
video.resumevideo();
videoBarEventHalder =
true;
}
private
function ProgressBar_click(evt:MouseEvent):
void
{
if (video.videoprocess !=
null)
{
this.stage.removeChild(video.videoprocess);
video.videoprocess =
null;
}
var point:Point =
new Point(InterfaceButton.loadbg.x, InterfaceButton.loadbg.y);
var loadbgpoint:Point = InterfaceButton.loadbg.localToGlobal(point);
timenum = PlayerVideo.VideoTime / InterfaceButton.loadbg.width * (
this.mouseX - loadbgpoint.x);
if (ButtonFOControl.btnboo ==
false)
{
video.resumevideo();
}
video.JumpVideo(timenum);
}
//
视频点击事件
/*
private function stage_click(evt:MouseEvent):void
{
var stageRange:Rectangle = new Rectangle(this.stage.x, this.stage.y, this.stage.stageWidth, this.stage.stageHeight - InterfaceButton.ListHeight);
if (this.mouseX >= stageRange.x && this.mouseX <= stageRange.x + stageRange.width)
{
if (this.mouseY >= stageRange.y && this.mouseY <= stageRange.y + stageRange.height)
{
if (ButtonFOControl.btnboo)
{
video.pausevideo();
InterfaceButton.puasebtn.removeEventListener(MouseEvent.CLICK, pause_click);
if (InterfaceButton.playbtn.hasEventListener(MouseEvent.CLICK) == false)
{
InterfaceButton.playbtn.addEventListener(MouseEvent.CLICK, play_click);
}
}
else
{
video.resumevideo();
InterfaceButton.playbtn.removeEventListener(MouseEvent.CLICK, play_click);
InterfaceButton.puasebtn.addEventListener(MouseEvent.CLICK, pause_click);
}
}
}
}
*/
//
更换界面皮肤
private
function skins_click(evt:MouseEvent):
void
{
var url:String = evt.target.getChildAt(0).text;
var skinEnglishName:String;
for (
var i:
int = 0; i < SkinsManager.skinnum; i++ )
{
if (xml.child("Folder").child("skin")[i].@Alias == url)
{
skinEnglishName = xml.child("Folder").child("skin")[i].@name;
SkinsManager.getandsetcolors = xml.child("Folder").child("skin")[i].@playprocolor;
}
}
if (skinEnglishName == skinsname)
{
TweenLite.to(skinbg, 1, { alpha:0, ease:Back.easeOut } );
skinbg.visible =
false;
return;
}
skinsname = skinEnglishName;
colors = SkinsManager.getandsetcolors;
video.colors = colors;
var sb:Sprite = Draws.drawroundrects(6, 10, 6, 0, 0, colors, 0.6);
InterfaceButton.soundbar.addChild(sb);
countwidth = InterfaceButton.soundbar.x - InterfaceButton.soundvaluebg.x + 4;
Draws.drawroundrectsNotreturnvalue(InterfaceButton.soundvalue, countwidth, 6, 3, 0, 0, colors);
displayNum = video.DragBarSetSoundVolume(countwidth, soundbarwidth);
SkinsManager.changeskins(skinEnglishName);
//
取消显示皮肤选择菜单
TweenLite.to(skinbg, 1, { alpha:0, ease:Back.easeOut } );
skinbg.visible =
false;
interfaceinitialization.skinbg.removeChild(skinbg);
//
重新显示皮肤选择菜单
skinbg = Draws.DrawsPromptBox(colors, 0.4, 1, 0xFFFFFF, 0.7, 60, 20 * SkinsManager.skinnum, 6, 6);
skinbg.addChild(skincont);
interfaceinitialization.skinbg.addChild(skinbg);
skinbg.x = - 20;
skinbg.y = - 84;
skinbg.alpha = 0;
skinbg.visible =
false;
//
更新声音大小显示背景
soundVolumeDisplayBG = Draws.DrawsPromptBox(colors, 0.6, 1, 0xFFFFFF, 0.6, 30, 15, 6, 6);
soundVolumeDisplayBG.addChild(SVText);
//
更新显示时间背景以及时间对象
interfaceinitialization.munebackground.removeChild(interfaceinitialization.timetextbg);
interfaceinitialization.timetextbg = Draws.drawroundrects(84, InterfaceButton.playbtn.height, 3, 0,0, colors,0.7 ,
true);
interfaceinitialization.munebackground.addChild(interfaceinitialization.timetextbg);
interfaceinitialization.timetextbg.x = InterfaceButton.stopbtn.x + InterfaceButton.stopbtn.width + 2;
interfaceinitialization.timetextbg.y = InterfaceButton.stopbtn.y;
interfaceinitialization.timetextbg.addChild(InterfaceButton.TimeText);
}
}
}