|
|
TopPage > swftoolsを使ってみる > swftoolsを使ってみる[04] |
swftoolsを使った自作flash動画プレイヤーを作ってみる(3) Loader付き |
.flash filename="njaFlsPlayer02a.swf" fps=25 bbox=300x291 background=black version=6 .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" #### .font Sans "DejaVuLGCSans.swf" #### ## exsample for check position and size ## .edittext fnum_text text="[0 frame]" font=Sans readonly ## variable="cur_frame_text" size=14% width=146 height=14 border color=navy .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 variable="cur_loop_text" size=14% width=40 height=14 align=center color=green #### ## Loaderが白いのでLoad後、画面を黒くするのに画面サイズのBoxを配置 ## 1行目のbackground=blackでは、黒くならなかったので。 .box back_box 300 291 color=black fill=black .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 ## movie file ## ################ .swf movie1 "sample_movie02.swf" ## put menu bar and indicator ## ################################ .put back_box pin=center x=150 y=145 .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 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(); /////////////////// 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=150 y=111 scalex=280 scaley=210 .action: movie1.Stop(); .end ######## .frame 2 .action: movie1.Stop(); .end .end |
[hoge]$ ffmpeg -i sample_movie02.avi -r 25 -b 256k sample_movie02.swf .... |
file name | file size |
sample_movie02.avi | 9.4 Mbyte |
sample_movie02.swf | 3.2 Mbyte |
.flash filename="njaLoader02a.swf" fps=25 bbox=300x291 background=white version=6 .font Sans "DejaVuLGCSans.swf" .edittext load_info text="0%" color=red size=100% width=80 height=20 align=center border=none noselect variable=LoadInfo .edittext load_bar text="■□□□□" color=red size=100% width=80 height=20 align=center border=none noselect variable=LoadBar .text Loading_text font=Sans text="Now Loading" color=red size=50% .box bfull 299 290 color=red fill=white ################ .frame 1 .put bfull pin=center x=150 y=145 .put Loading_text pin=center x=150 y=120 .put load_info pin=center x=220 y=200 .put load_bar pin=center x=100 y=200 #### .action: var count = 0; .end ################ .frame 2 ################ .frame 10 .action: _root.getBytesTotal(); LoadInfo = (String (int ((_root.getBytesLoaded() * 100) / _root.getBytesTotal())) + "%" ); count = count + 1; switch(count) { case 1: LoadBar = "□■□□□"; break; case 2: LoadBar = "□□■□□"; break; case 3: LoadBar = "□□□■□"; break; case 4: LoadBar = "□□□□■"; break; case 5: LoadBar = "■□□□□"; count = 0; break; default : count = 1; } ###### if (((_root.getBytesLoaded() * 100) / _root.getBytesTotal()) < 100) { gotoAndPlay (2); } .end ################ .frame 11 .sprite movie # player replaced by swfcombine .end .put movie .stop .end |
[hoge]$ swfc njaLoader02a.sc |
[hoge]$ swfcombine --merge -o njaFlsPlayer02l.swf njaLoader02a.swf -x 0 -y 0 movie=njaFlsPlayer02a.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="njaFlsPlayer02l.swf"> <param name="loop" value="false"> <param name="bgcolor" value="#000000"> <embed src="njaFlsPlayer02l.swf" width="300" height="291" type="application/x-shockwave-flash" bgcolor="#000000" loop="false"> </embed> </object> |
TopPage > swftoolsを使ってみる > swftoolsを使ってみる[04] |