Class: Ampv::MpvWidget
- Inherits:
-
Gtk::EventBox
- Object
- Gtk::EventBox
- Ampv::MpvWidget
- Defined in:
- lib/ampv/mpvwidget.rb
Instance Attribute Summary collapse
-
#is_paused ⇒ Object
readonly
Returns the value of attribute is_paused.
-
#is_stopped ⇒ Object
readonly
Returns the value of attribute is_stopped.
Instance Method Summary collapse
-
#initialize(args) ⇒ MpvWidget
constructor
A new instance of MpvWidget.
- #load_file(file, force_play = false) ⇒ Object
- #play_pause ⇒ Object
- #quit(watch_later) ⇒ Object
- #send(cmd) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(args) ⇒ MpvWidget
Returns a new instance of MpvWidget.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ampv/mpvwidget.rb', line 23 def initialize(args) if args.include?("--debug") args.delete("--debug") @debug = true end @mpv_options = args.join(" ") @mpv_fifo = "#{Dir.tmpdir}/mpv.fifo." + Process.pid.to_s @is_paused = true super() @widget = Gtk::DrawingArea.new @widget.modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse("#000")) @widget.signal_connect("realize") { start } add(@widget) end |
Instance Attribute Details
#is_paused ⇒ Object (readonly)
Returns the value of attribute is_paused.
21 22 23 |
# File 'lib/ampv/mpvwidget.rb', line 21 def is_paused @is_paused end |
#is_stopped ⇒ Object (readonly)
Returns the value of attribute is_stopped.
21 22 23 |
# File 'lib/ampv/mpvwidget.rb', line 21 def is_stopped @is_stopped end |
Instance Method Details
#load_file(file, force_play = false) ⇒ Object
47 48 49 50 |
# File 'lib/ampv/mpvwidget.rb', line 47 def load_file(file, force_play = false) send("loadfile \"#{file}\"") @force_play = force_play end |
#play_pause ⇒ Object
52 53 54 55 |
# File 'lib/ampv/mpvwidget.rb', line 52 def play_pause send("cycle pause") @is_paused = !@is_paused end |
#quit(watch_later) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/ampv/mpvwidget.rb', line 62 def quit(watch_later) send("quit" + (watch_later ? "_watch_later" : "")) @prog_thread.kill if @prog_thread @thread.join @fifo.close end |
#send(cmd) ⇒ Object
42 43 44 45 |
# File 'lib/ampv/mpvwidget.rb', line 42 def send(cmd) @fifo.puts(cmd) @fifo.flush end |
#stop ⇒ Object
57 58 59 60 |
# File 'lib/ampv/mpvwidget.rb', line 57 def stop send("stop") @is_stopped = @is_paused = true end |