Class: MPlayer::Slave
- Inherits:
-
Object
- Object
- MPlayer::Slave
- Includes:
- SlaveCommands, SlaveSubCommands, SlaveTvCommands, 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
-
#command(cmd, match = //) ⇒ Object
commands command to mplayer stdin and retrieves stdout.
-
#initialize(file = "", options = {}) ⇒ Slave
constructor
Initializes a new instance of MPlayer.
Methods included from SlaveSubCommands
#forced_subs_only, #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
Methods included from SlaveTvCommands
#next_channel, #prev_channel, #tv_last_channel, #tv_set_brightness, #tv_set_channel, #tv_set_contrast, #tv_set_freq, #tv_set_hue, #tv_set_norm, #tv_set_saturation, #tv_start_scan, #tv_step_chanlist, #tv_step_channel, #tv_step_freq, #tv_step_norm
Methods included from SlaveVideoCommands
#audio_delay, #brightness, #change_rectangle, #contrast, #dvdnav, #frame_drop, #gamma, #get_property, #get_sub_visibility, #get_vofullscreen, #hue, #osd, #osd_show_property_text, #osd_show_text, #panscan, #saturation, #screenshot, #seek_chapter, #set_property, #step_property, #switch_angle, #switch_audio, #switch_ratio, #switch_title, #switch_vsync, #vo_border, #vo_fullscreen, #vo_ontop, #vo_rootwin
Methods included from SlaveCommands
#alt_src_step, #back, #balance, #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 = {}) ⇒ Slave
Initializes a new instance of MPlayer. set :path to point to the location of mplayer defaults to ‘/usr/bin/mplayer’
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mplayer-ruby/slave.rb', line 14 def initialize(file = "", ={}) unless File.exists?(file) || URI::regexp.match(file) raise ArgumentError,"Invalid File" end [:path] ||= 'mplayer' @file = file mplayer = invocation() @pid,@stdin,@stdout,@stderr = Open4.popen4(mplayer) until @stdout.gets.inspect =~ /playback/ do end #fast forward past mplayer's initial 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
#command(cmd, match = //) ⇒ Object
commands command to mplayer stdin and retrieves stdout. If match is provided, fast-forwards stdout to matching response.
30 31 32 33 34 35 36 37 |
# File 'lib/mplayer-ruby/slave.rb', line 30 def command(cmd,match = //) @stdin.puts(cmd) response = "" until response =~ match response = @stdout.gets end response.gsub("\e[A\r\e[K","") end |