|
|
TopPage > swftoolsを使ってみる > swftoolsを使ってみる[03] |
swftoolsを使った自作flash動画プレイヤーを作ってみる(2) Loopボタン付き |
|
W:H = 300pic : 22pic |
|
W:H = 40pic : 18pic |
ループ選択ボタン | プレイボタン | ポーズボタン | ストップボタン |
|
|
|
|
btn_loop.png W:H = 40pic : 18pic |
btn_play01.png W:H = 40pic : 18pic |
btn_pause01.png W:H = 40pic : 18pic |
btn_stop01.png W:H = 40pic : 18pic |
.flash filename="njaFlsPlayer01a.swf" fps=25 bbox=300x291 .png menubar "menu_bar300x22.png" .png play_btn "btn_play01.png" .png pause_btn "btn_pause01.png" .png stop_btn "btn_stop01.png" .png loop_btn "btn_loop.png" ←Loopボタン画像を設定 #### .font Sans "DejaVuLGCSans.swf" #### .edittext state_text text="Stop" font=Sans readonly variable="cur_state_text" size=14% width=74 height=14 align=center color=green .edittext fnum_text text="[0 frame]" font=Sans readonly variable="cur_frame_text" size=14% width=100 height=14 color=green .edittext time_text text="[0 sec]" font=Sans readonly variable="cur_time_text" size=14% width=98 height=14 color=green .edittext loop_text text="loop off" font=Sans readonly ←LoopのON/OFFを示すテキスト variable="cur_loop_text" size=14% width=40 height=14 align=center color=green #### .box state_box 76 16 color=green fill=black .box fnum_box 102 16 color=green fill=black .box time_box 100 16 color=green fill=black .box loop_box 42 16 color=green fill=black LoopのON/OFF表示枠 ## movie file ## ################ .swf movie1 "sample_movie00.swf" ## put menu bar and indicator ## ################################ .put menubar pin=center x=150 y=280 #### .put state_box pin=center x=42 y=256 .put fnum_box pin=center x=136 y=256 .put time_box pin=center x=243 y=256 .put loop_box pin=center x=25 y=236 #### .put state_text pin=center scalex=74 scaley=16 x=42 y=256 .put fnum_text pin=center scalex=100 scaley=16 x=136 y=256 .put time_text pin=center scalex=98 scaley=16 x=243 y=256 .put loop_text pin=center scalex=36 scaley=16 x=25 y=236 #### ## play button add action ## .button pl_btn .show play_btn as=area .show play_btn as=idle .show play_btn as=hover .show play_btn as=pressed .on_press: PlayFunc(); .end .end .put pl_btn pin=center x=64 y=280 ## pause button add action## .button pa_btn .show pause_btn as=area .show pause_btn as=idle .show pause_btn as=hover .show pause_btn as=pressed .on_press: PauseFunc(); .end .end .put pa_btn pin=center x=106 y=280 ## stop button add action ## .button st_btn .show stop_btn as=area .show stop_btn as=idle .show stop_btn as=hover .show stop_btn as=pressed .on_press: StopFunc(); .end .end .put st_btn pin=center x=148 y=280 Loopボタンの配置 ## loop button add action ## .button lp_btn .show loop_btn as=area .show loop_btn as=idle .show loop_btn as=hover .show loop_btn as=pressed .on_press: Loop_flag(); .end .end .put lp_btn pin=center x=22 y=280 #### function in action script #### ################################### .action: var pause_state; var total_fnum; var cur_fnum; var frame_rate; var total_time; var cur_time; var loop_f; frame_rate = 25; loop_f = "off"; total_fnum = movie1._totalframes; total_time = total_fnum / frame_rate; /////////////////// function PlayFunc() { movie1.gotoAndplay(1); pause_state = "run"; cur_state_text = "Play"; idinterval = setInterval(UpdateCounter, 25); } /////////////////// function StopFunc() { movie1.gotoAndStop(1); cur_state_text = "Stop"; } /////////////////// function PauseFunc() { if ( pause_state == "run" ) { movie1.Stop(); pause_state = "pause"; cur_state_text = "Pause"; } else { movie1.Play(); pause_state = "run"; cur_state_text = "Play"; } } /////////////////// function UpdateCounter() { cur_fnum = movie1._currentframe; cur_time = int(cur_fnum / frame_rate); cur_frame_text = cur_fnum + "/" + total_fnum + " frame"; cur_time_text = cur_time + "/" + total_time + " sec"; if ( cur_fnum >= total_fnum ) { if ( loop_f == "off" ) { movie1.Stop(); } else { movie1.play(); } } } UpdateCounter(); Loopボタンのaction script /////////////////// function Loop_flag() { if ( loop_f == "on" ) { cur_loop_text = "Loop off"; loop_f = "off"; } else { cur_loop_text = "Loop on"; loop_f = "on"; } } .end ######## .frame 1 .put movie1 pin=center x=153 y=111 scalex=280 scaley=210 .action: movie1.Stop(); .end ######## .frame 2 .action: movie1.Stop(); .end .end |
[hoge]$ ffmpeg -i sample_movie00.avi -r 25 -b 256k sample_movie00.swf .... |
[hoge]$ swfc njaFlsPlayer01a.swf |
<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="300" height="291"> <param name="movie" value="njaFlsPlayer01a.swf"> <param name="loop" value="false"> <param name="bgcolor" value="#000000"> <embed src="njaFlsPlayer01a.swf" width="300" height="291" type="application/x-shockwave-flash" bgcolor="#000000" loop="false"> </embed> </object> |
TopPage > swftoolsを使ってみる > swftoolsを使ってみる[03] |