Module: MPlayer::SlaveCommands

Included in:
Slave
Defined in:
lib/mplayer-ruby/slave_commands.rb

Instance Method Summary collapse

Instance Method Details

#alt_src_step(value) ⇒ Object

When more than one source is available it selects the next/previous one. ASX Playlist ONLY



150
# File 'lib/mplayer-ruby/slave_commands.rb', line 150

def alt_src_step(value); command("alt_src_step #{value}"); end

#back(value, force = :no_force) ⇒ Object

goes to the previous entry in the playlist denoted by value. No action will occur unless :force is specified



73
74
75
# File 'lib/mplayer-ruby/slave_commands.rb', line 73

def back(value,force = :no_force)
  pt_step -value.abs, force
end

#balance(value) ⇒ Object

set balance to <value>



169
170
171
# File 'lib/mplayer-ruby/slave_commands.rb', line 169

def balance(value)
  command("balance #{value}")
end

#edl_markObject

Write the current position into the EDL file.



177
# File 'lib/mplayer-ruby/slave_commands.rb', line 177

def edl_mark; command("edl_mark"); end

#frame_stepObject

Play one frame, then pause again.



174
# File 'lib/mplayer-ruby/slave_commands.rb', line 174

def frame_step; command("frame_step"); end

#get(value) ⇒ Object

returns information on file available values are: time_pos time_length file_name video_codec video_bitrate video_resolution audio_codec audio_bitrate audio_samples meta_title meta_artist meta_album meta_year meta_comment meta_track meta_genre



98
99
100
101
102
103
104
105
106
107
# File 'lib/mplayer-ruby/slave_commands.rb', line 98

def get(value)
  field = value.to_s
  match = case field
  when "time_pos" then "ANS_TIME_POSITION"
  when "time_length" then "ANS_LENGTH"
  when "file_name" then "ANS_FILENAME"
  else "ANS_#{field.upcase}"
  end
  command("get_#{value}",/#{match}/).gsub("#{match}=","").gsub("'","")
end

#load_file(file, append = :no_append) ⇒ Object

Loads the file into MPlayer :append loads the file and appends it to the current playlist :no_append will stop playback and play new loaded file



129
130
131
132
133
134
135
# File 'lib/mplayer-ruby/slave_commands.rb', line 129

def load_file(file,append = :no_append)
  unless File.exists?(file) || URI::regexp.match(file)
    raise ArgumentError,"Invalid File"
  end
  switch = (append == :append ? 1 : 0)
  command "loadfile \"#{file}\" #{switch}"
end

#load_list(file, append = :no_append) ⇒ Object

Loads the playlist into MPlayer :append loads the playlist and appends it to the current playlist :no_append will stop playback and play new loaded playlist



140
141
142
143
144
145
146
# File 'lib/mplayer-ruby/slave_commands.rb', line 140

def load_list(file,append = :no_append)
  unless File.exists?(file) || URI::regexp.match(file)
    raise ArgumentError,"Invalid File"
  end
  switch = (append == :append ? 1 : 0)
  command "loadlist \"#{file}\" #{switch}"
end

#loop(action = :forever, value = 1) ⇒ Object

Adjust/set how many times the movie should be looped. :none means no loop :forever means loop forever.(default) :set sets the amount of times to loop. defaults to one loop.



49
50
51
52
53
54
55
# File 'lib/mplayer-ruby/slave_commands.rb', line 49

def loop(action = :forever,value = 1)
  command case action
  when :none then "loop -1"
  when :set then "loop #{value}"
  else "loop 0"
  end
end

#mute(value = nil) ⇒ Object

Toggle sound output muting or set it to [value] when [value] >= 0

(1 == on, 0 == off).


88
89
90
91
# File 'lib/mplayer-ruby/slave_commands.rb', line 88

def mute(value = nil)
  resp = toggle :mute, value, /Mute/
  resp.gsub("Mute: ","")
end

#next(value, force = :no_force) ⇒ Object

goes to the next entry in the playlist denoted by value. No action will occur unless :force is specified



67
68
69
# File 'lib/mplayer-ruby/slave_commands.rb', line 67

def next(value,force = :no_force)
  pt_step value.abs, force
end

#pauseObject

Pauses/Unpauses the file.



180
# File 'lib/mplayer-ruby/slave_commands.rb', line 180

def pause; command("pause") ; end

#pt_step(value, force = :no_force) ⇒ Object

Go to the next/previous entry in the playtree. T he sign of <value> tells the direction. If no entry is available in the given direction it will do nothing unless :force



61
62
63
# File 'lib/mplayer-ruby/slave_commands.rb', line 61

def pt_step(value,force = :no_force)
  command(force == :force ? "pt_step #{value} 1" : "pt_step #{value} 0")
end

#pt_up_step(value, force = :no_force) ⇒ Object

Similar to pt_step but jumps to the next/previous entry in the parent list. Useful to break out of the inner loop in the playtree.



79
80
81
# File 'lib/mplayer-ruby/slave_commands.rb', line 79

def pt_up_step(value,force = :no_force)
  command(force == :force ? "pt_up_step #{value} 1" : "pt_up_step #{value} 0")
end

#quitObject

Quits MPlayer



183
184
185
186
# File 'lib/mplayer-ruby/slave_commands.rb', line 183

def quit
  command('quit')
  @stdin.close
end

#seek(value, type = :relative) ⇒ Object

Seek to some place in the file :relative is a relative seek of +/- <value> seconds (default). :perecent is a seek to <value> % in the file. :absolute is a seek to an absolute position of <value> seconds.



23
24
25
26
27
28
29
30
31
# File 'lib/mplayer-ruby/slave_commands.rb', line 23

def seek(value,type = :relative)
  command = case type
  when :percent then "seek #{value} 1"
  when :absolute then "seek #{value} 2"
  else "seek #{value} 0"
  end
  resp = command command, /Position/
  resp.gsub("Position: ","").gsub(" %\n","")
end

#speed(value, type = :set) ⇒ Object

Adjusts the current playback speed :increment adds <value> to the current speed :multiply multiplies the current speed by <value> :set sets the current speed to <value>.(default)



37
38
39
40
41
42
43
# File 'lib/mplayer-ruby/slave_commands.rb', line 37

def speed(value,type = :set)
  case type
  when :increment then speed_incr(value)
  when :multiply then speed_mult(value)
  else speed_set(value)
  end
end

#speed_incr(value) ⇒ Object

Add <value> to the current playback speed.



153
154
155
# File 'lib/mplayer-ruby/slave_commands.rb', line 153

def speed_incr(value)
  speed_setting :speed_incr, value
end

#speed_mult(value) ⇒ Object

Multiply the current speed by <value>.



158
159
160
# File 'lib/mplayer-ruby/slave_commands.rb', line 158

def speed_mult(value)
  speed_setting :speed_mult, value
end

#speed_set(value) ⇒ Object

Set the speed to <value>. cannot be greater than 5



164
165
166
# File 'lib/mplayer-ruby/slave_commands.rb', line 164

def speed_set(value)
  speed_setting :speed_set, value
end

#use_masterObject

Switch volume control between master and PCM.



84
# File 'lib/mplayer-ruby/slave_commands.rb', line 84

def use_master; command("use_master"); end

#volume(action, value = 30) ⇒ Object

Increase/decrease volume :up increase volume :down decreases volume :set sets the volume at <value>



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mplayer-ruby/slave_commands.rb', line 7

def volume(action,value=30)
  cmd =
  case action
  when :up then "volume 1"
  when :down then "volume 0"
  when :set then "volume #{value} 1"
  else return false
  end
  resp = command cmd, /Volume/
  resp.gsub("Volume: ","").gsub(" %\n","")
end