class Rabbit::VideoWindow::VideoWidget

Public Class Methods

new(file) click to toggle source
Calls superclass method
# File lib/rabbit/video-window.rb, line 77
def initialize(file)
  super()

  @playbin = Gst::ElementFactory.make('playbin2')

  @video = Gst::ElementFactory.make('xvimagesink')
  @video.force_aspect_ratio = true

  @playbin.video_sink = @video
  @playbin.audio_sink = Gst::ElementFactory.make('autoaudiosink')
  @playbin.signal_connect('notify') do
    @playbin.video_sink.xwindow_id = self.window.xid if self.window
    @playbin.video_sink.expose
  end
  @playbin.uri = "file://#{File.absolute_path(file)}"
  @playbin.ready
end

Public Instance Methods

pause() click to toggle source
# File lib/rabbit/video-window.rb, line 100
def pause
  @playbin.pause
  @playing = false
end
play() click to toggle source
# File lib/rabbit/video-window.rb, line 95
def play
  @playbin.play
  @playing = true
end
seek(time) click to toggle source
# File lib/rabbit/video-window.rb, line 110
def seek(time)
  @playbin.seek(1.0, Gst::Format::TIME,
    Gst::Seek::FLAG_FLUSH | Gst::Seek::FLAG_KEY_UNIT,
    Gst::Seek::TYPE_CUR, time * Gst::SECOND,
    Gst::Seek::TYPE_NONE, -1);
end
stop() click to toggle source
# File lib/rabbit/video-window.rb, line 105
def stop
  @playbin.stop
  @playing = false
end
toggle() click to toggle source
# File lib/rabbit/video-window.rb, line 117
def toggle
  @playing ? pause : play
end