Class: Miyako::Movie
- Extended by:
- Forwardable
- Includes:
- Animation, Layout, SpriteBase
- Defined in:
- lib/Miyako/API/movie.rb
Overview
動画管理クラス
動画ファイル(MPEGファイル限定)をロード・再生するクラス
Constant Summary collapse
- @@movie_list =
[]
Instance Attribute Summary collapse
-
#visible ⇒ Object
レンダリングの可否(true->描画 false->非描画).
Instance Method Summary collapse
-
#current ⇒ Object
再生中の動画の再生位置を返す 位置は秒単位で返す 返却値:: 再生位置.
-
#dispose ⇒ Object
動画データを解放する.
-
#initialize(fname, loops = true) ⇒ Movie
constructor
動画のインスタンスを作成する (但し、現在の所、loopパラメータは利用できない) fname:: 動画ファイル名 loops:: ループ再生の可否。ループ再生させるときは true を渡す 返却値:: 生成したインスタンス.
-
#initialize_copy(obj) ⇒ Object
:nodoc:.
-
#length ⇒ Object
動画の長さを返す 長さは、秒単位で返す。 返却値:: 動画の長さ.
-
#pause(pause_by_input) ⇒ Object
動画の再生を一時停止する 再生を裁可するには、 Miyako::Movie#rewind メソッドを呼び出す必要がある pause_by_input:: ダミー.
-
#playing? ⇒ Boolean
動画再生中かを返す 返却値:: 再生中のときは true を返す.
-
#region(rect) ⇒ Object
再生領域の範囲を設定する 元動画のうち、表示させたい箇所を Rect クラスのインスタンスか4要素の配列で指定する rect:: 再生領域。.
-
#render ⇒ Object
画面に描画を指示する 現在表示できる選択肢を、現在の状態で描画するよう指示する visibleメソッドの値がfalseのときは描画されない。 返却値:: 自分自身を返す.
-
#set_volume(v) ⇒ Object
動画再生時の音量を指定する v:: 指定する音量。(0~100までの整数).
-
#start(vol = nil) ⇒ Object
動画を再生させる 動画の先頭から再生する。ブロックを渡したときは、ブロックを評価している間動画を再生する vol:: 動画再生時の音量。0~100の整数.
-
#stop ⇒ Object
動画再生を停止する.
-
#update_layout_position ⇒ Object
:nodoc:.
Methods included from Layout
#add_snap_child, #bottom, #bottom!, #broad_rect, #center, #center!, #centering, #centering!, #copy_layout, #delete_snap_child, #get_snap_children, #get_snap_sprite, #h, #include_snap_child?, #init_layout, #layout_dispose, #left, #left!, #middle, #middle!, #move, #move!, #move_to, #move_to!, #on_move, #outside_bottom, #outside_bottom!, #outside_left, #outside_left!, #outside_right, #outside_right!, #outside_top, #outside_top!, #pos, #rect, #relative_move_to, #relative_move_to!, #reset_snap, #right, #right!, #segment, #set_layout_size, #set_snap_children, #set_snap_sprite, #size, #snap, #top, #top!, #update_layout, #w, #x, #y
Methods included from Animation
[], []=, anim_hash, reset, #reset, start, stop, update, update_animation, #update_animation
Methods included from SpriteBase
#bitmap, #hide, #image_rect, #image_size, #oh, #ow, #ox, #oy, #part_rect, #rect, #render_to, #render_xy, #render_xy_to, #show, #to_sprite, #to_unit, #update
Constructor Details
#initialize(fname, loops = true) ⇒ Movie
動画のインスタンスを作成する
(但し、現在の所、loopパラメータは利用できない)
- fname
-
動画ファイル名
- loops
-
ループ再生の可否。ループ再生させるときは true を渡す
- 返却値
-
生成したインスタンス
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/Miyako/API/movie.rb', line 41 def initialize(fname, loops = true) init_layout @x = 0 @y = 0 raise MiyakoIOError.no_file(fname) unless File.exist?(fname) @movie = SDL::MPEG.load(fname) @size = Size.new(@movie.info.width, @movie.info.height) set_layout_size(*(@size.to_a)) @visible = true @sprite = Sprite.new({:size=>@size , :type=>:movie}) @sprite.snap(self) @movie.enable_audio(true) unless $not_use_audio @movie.enable_video(true) @movie.set_loop(loops) @movie.set_display(@sprite.bitmap) @movie.scale(1.0) @@movie_list.push(self) end |
Instance Attribute Details
#visible ⇒ Object
レンダリングの可否(true->描画 false->非描画)
34 35 36 |
# File 'lib/Miyako/API/movie.rb', line 34 def visible @visible end |
Instance Method Details
#current ⇒ Object
再生中の動画の再生位置を返す
位置は秒単位で返す
- 返却値
-
再生位置
137 138 139 |
# File 'lib/Miyako/API/movie.rb', line 137 def current return @movie.info.current_time end |
#dispose ⇒ Object
動画データを解放する
92 93 94 95 96 97 98 |
# File 'lib/Miyako/API/movie.rb', line 92 def dispose @movie.stop if @sprite.dispose layout_dispose @@movie_list.delete(self) @movie = nil end |
#initialize_copy(obj) ⇒ Object
:nodoc:
71 72 73 74 75 |
# File 'lib/Miyako/API/movie.rb', line 71 def initialize_copy(obj) #:nodoc: @sprite = @sprite.dup @size = @size.dup copy_layout end |
#length ⇒ Object
動画の長さを返す
長さは、秒単位で返す。
- 返却値
-
動画の長さ
144 145 146 |
# File 'lib/Miyako/API/movie.rb', line 144 def length return @movie.info.total_time end |
#pause(pause_by_input) ⇒ Object
動画の再生を一時停止する
再生を裁可するには、 Miyako::Movie#rewind メソッドを呼び出す必要がある
- pause_by_input
-
ダミー
110 111 112 |
# File 'lib/Miyako/API/movie.rb', line 110 def pause(pause_by_input) @movie.pause end |
#playing? ⇒ Boolean
動画再生中かを返す
- 返却値
-
再生中のときは true を返す
87 88 89 |
# File 'lib/Miyako/API/movie.rb', line 87 def return @movie.status == SDL::MPEG::PLAYING end |
#region(rect) ⇒ Object
再生領域の範囲を設定する
元動画のうち、表示させたい箇所を Rect クラスのインスタンスか4要素の配列で指定する
- rect
-
再生領域。
103 104 105 |
# File 'lib/Miyako/API/movie.rb', line 103 def region(rect) @movie.set_display_region(*(rect.to_a)) end |
#render ⇒ Object
画面に描画を指示する
現在表示できる選択肢を、現在の状態で描画するよう指示する visibleメソッドの値がfalseのときは描画されない。
- 返却値
-
自分自身を返す
152 153 154 155 156 |
# File 'lib/Miyako/API/movie.rb', line 152 def render return self unless @visible @sprite.render return self end |
#set_volume(v) ⇒ Object
動画再生時の音量を指定する
- v
-
指定する音量。(0~100までの整数)
79 80 81 82 83 |
# File 'lib/Miyako/API/movie.rb', line 79 def set_volume(v) return $not_use_audio raise MiyakoValueError.over_range(v, 0, 100) unless (0..100).cover?(v) @movie.set_volume(v) end |
#start(vol = nil) ⇒ Object
動画を再生させる
動画の先頭から再生する。ブロックを渡したときは、ブロックを評価している間動画を再生する
- vol
-
動画再生時の音量。0~100の整数
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/Miyako/API/movie.rb', line 117 def start(vol = nil) if vol raise MiyakoValueError.over_range(vol, 0, 100) unless (0..100).cover?(vol) set_volume(vol) if vol end @movie.play if block_given? yield self @movie.stop end end |
#stop ⇒ Object
動画再生を停止する
130 131 132 |
# File 'lib/Miyako/API/movie.rb', line 130 def stop @movie.stop end |
#update_layout_position ⇒ Object
:nodoc:
65 66 67 68 69 |
# File 'lib/Miyako/API/movie.rb', line 65 def update_layout_position #:nodoc: @x = @layout.pos[0] @y = @layout.pos[1] @sprite.move_to!(*@layout.pos) end |