class MMPlayer::Player::Invoker
Invoke MPlayer
Attributes
player[R]
thread[R]
Public Class Methods
new(options = {})
click to toggle source
@param [Hash] options @option options [String] :flags MPlayer command-line flags to use on startup
# File lib/mmplayer/player/invoker.rb, line 12 def initialize(options = {}) @flags = "-fixed-vo -idle" @flags += " #{options[:flags]}" unless options[:flags].nil? @player.nil? @thread = nil end
Public Instance Methods
destroy()
click to toggle source
# File lib/mmplayer/player/invoker.rb, line 19 def destroy @thread.kill unless @thread.nil? end
ensure_invoked(file, state)
click to toggle source
Ensure that the MPlayer process is invoked @param [String] file The media file to invoke MPlayer with @param [MMplayer::Player::State] state @return [MPlayer::Slave]
# File lib/mmplayer/player/invoker.rb, line 27 def ensure_invoked(file, state) if @player.nil? && @thread.nil? @thread = ::MMPlayer::Thread.new(:timeout => false) do @player = MPlayer::Slave.new(file, :options => @flags) state.handle_start end end @player end