Class: MPlayer::Slave
- Inherits:
-
Object
- Object
- MPlayer::Slave
- Includes:
- SlaveCommands, SlaveVideoCommands
- Defined in:
- lib/mplayer-ruby/slave.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(file = "", options = {:path => '/usr/bin/mplayer'}) ⇒ Slave
constructor
Initializes a new instance of MPlayer.
-
#send(cmd, match = //) ⇒ Object
sends command to mplayer stdin and retrieves stdout.
Methods included from SlaveVideoCommands
#audio_delay, #brightness, #contrast, #frame_drop, #gamma, #hue, #osd, #osd_show_property_text, #osd_show_text, #saturation, #sub_alignment, #sub_delay, #sub_demux, #sub_file, #sub_load, #sub_pos, #sub_remove, #sub_scale, #sub_select, #sub_source, #sub_step, #sub_visibility, #sub_vob, #switch_angle, #switch_audio, #switch_ratio, #switch_title, #switch_vsync
Methods included from SlaveCommands
#alt_src_step, #back, #edl_mark, #frame_step, #get, #load_file, #load_list, #loop, #mute, #next, #pause, #pt_step, #pt_up_step, #quit, #seek, #speed, #speed_incr, #speed_mult, #speed_set, #use_master, #volume
Constructor Details
#initialize(file = "", options = {:path => '/usr/bin/mplayer'}) ⇒ Slave
Initializes a new instance of MPlayer. set :path to point to the location of mplayer defaults to ‘/usr/bin/mplayer’
12 13 14 15 16 17 18 19 |
# File 'lib/mplayer-ruby/slave.rb', line 12 def initialize(file = "", ={:path => '/usr/bin/mplayer'}) raise ArgumentError,"Invalid File" unless File.exists?(file) @file = file mplayer = "#{[:path]} -slave -quiet #{@file}" @pid,@stdin,@stdout,@stderr = Open4.popen4(mplayer) until @stdout.gets.inspect =~ /playback/ do end #fast forward to the desired output end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/mplayer-ruby/slave.rb', line 4 def file @file end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
4 5 6 |
# File 'lib/mplayer-ruby/slave.rb', line 4 def pid @pid end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
4 5 6 |
# File 'lib/mplayer-ruby/slave.rb', line 4 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
3 4 5 |
# File 'lib/mplayer-ruby/slave.rb', line 3 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
4 5 6 |
# File 'lib/mplayer-ruby/slave.rb', line 4 def stdout @stdout end |
Instance Method Details
#send(cmd, match = //) ⇒ Object
sends command to mplayer stdin and retrieves stdout. If match is provided, fast-forwards stdout to matching response.
23 24 25 26 27 28 29 30 |
# File 'lib/mplayer-ruby/slave.rb', line 23 def send(cmd,match = //) @stdin.puts(cmd) response = @stdout.gets until response =~ match response = @stdout.gets end response.gsub("\e[A\r\e[K","") end |