웹페이지에서 플래시(flash)를 제어하는 자바스크립트(javascript) 소스 코드입니다. 동영상 캡쳐 프로그램 같은 것으로 캡쳐해서 만든 플래시 처럼 별다른 액션 없이 프래임(frames)만 순차적으로 재생되는 플래시일 경우 재생 및 정지 버튼을 붙이고 싶을 때가 있습니다. 자바스크립트로 재생, 정지, 되감기, 줌 버튼등을 구현하였으며 현재 재생중인 프래임 번호도 표시해줍니다. 시간이 허락하는 분은 민밋한 버튼을 이미지나 플래시로 구현해서 재생할 플래시 위해 표시하는 프로그램으로 업그레이드 해보면 좋을 듯 합니다. 지금 재생되고 있는 동영상은 나름 재미있는 추천 디펜스 게임 VR디펜더Y3K 게임 실행 화면 입니다.
[플래시 제어 자바스크립트 소스 HTML]
<html>
<head>
<title>자바스크립트로 플래시 제어</title>
<script language="javascript">
var swf_timer_id, flash_obj, flash_frame_total, flash_frame_pos;
function swf_is_playing(){
return flash_obj.IsPlaying();
}
function swf_stop(){
flash_obj.StopPlay();
}
function swf_play(){
flash_obj.Play();
}
function swf_rewind(){
flash_obj.Rewind();
}
function swf_zoom(percent){
flash_obj.Zoom(percent);
}
function swf_is_loaded(){
return flash_obj.PercentLoaded();
}
function swf_timer(){
var obj = document.getElementById('flash_play_bt_id');
if (swf_is_playing()) {
obj.value='stop';
obj.onclick = swf_stop;
} else {
obj.value='play';
obj.onclick = swf_play;
}
var obj = document.getElementById('flash_status_bt_id');
obj.value = flash_obj.TCurrentFrame('/');
}
function swf_init(){
flash_obj = document.getElementById('flash_swf_id');
//flash_frame_total = flash_obj.TotalFrames();
setInterval(swf_timer,30);
}
</script>
</head>
<body LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 onload="javscript:swf_init();">
<table cellspacing=0 cellpadding=0 border=0 bgcolor=#efefef>
<tr>
<td>
<embed id=flash_swf_id src="flash_movie.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="558" height="446" allowScriptAccess="always" wmode="transparent" autoplay="0" loop="0"></embed>
</div>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td><input id=flash_play_bt_id type="button" value="stop"></td>
<td><input type="button" value="rewind" onclick="javascript:swf_rewind();"></td>
<td><input type="button" value="90%" onclick="javascript:swf_zoom(50);"></td>
<td><input type="button" value="100%" onclick="javascript:swf_zoom(0);"></td>
<td><input id=flash_status_bt_id type="button" value="0"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
웹프로그래머의 홈페이지정보 블로그 http://hompy.info


댓글을 달아 주세요
관리자만 볼 수 있는 댓글입니다.