Class: Mireru::Widget::Video
- Inherits:
-
ClutterGtk::Embed
- Object
- ClutterGtk::Embed
- Mireru::Widget::Video
- Defined in:
- lib/mireru/widget/video.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ Video
constructor
A new instance of Video.
- #pause_or_play ⇒ Object
Constructor Details
#initialize(file) ⇒ Video
Returns a new instance of Video.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mireru/widget/video.rb', line 23 def initialize(file) super() stage.background_color = Clutter::Color.new(:black) @video_texture = ClutterGst::VideoTexture.new stage.add_child(@video_texture) @video_texture.signal_connect("eos") do |_video_texture| _video_texture.progress = 0.0 _video_texture. = true end @video_texture.filename = file @video_texture. = true signal_connect("destroy") do next if @video_texture.destroyed? @video_texture. = false end @video_texture.signal_connect_after("size-change") do |texture, base_width, base_height| stage_width, stage_height = stage.size frame_width, frame_height = texture.size new_height = (frame_height * stage_width) / frame_width if new_height <= stage_height new_width = stage_width new_x = 0 new_y = (stage_height - new_height) / 2 else new_width = (frame_width * stage_height) / frame_height new_height = stage_height new_x = (stage_width - new_width) / 2 new_y = 0 end texture.set_position(new_x, new_y) texture.set_size(new_width, new_height) end end |
Instance Method Details
#pause_or_play ⇒ Object
59 60 61 62 |
# File 'lib/mireru/widget/video.rb', line 59 def pause_or_play state = @video_texture. @video_texture. = state ? false : true end |