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



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

def alt_src_step(value); send("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
76
# File 'lib/mplayer-ruby/slave_commands.rb', line 73

def back(value,force = :no_force)
  v = "-" + value.to_s.gsub("-","")
  pt_step v, force
end

#edl_markObject

Write the current position into the EDL file.



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

def edl_mark; send("edl_mark"); end

#frame_stepObject

Play one frame, then pause again.



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

def frame_step; send("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



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

def get(value)
  match = case value.to_s
  when "time_pos" then "ANS_TIME_POSITION"
  when "time_length" then "ANS_LENGTH"
  when "file_name" then "ANS_FILENAME"
  else "ANS_#{value.to_s.upcase}"
  end
  resp = send "get_#{value}",/#{match}/
  resp.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

Raises:

  • (ArgumentError)


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

def load_file(file,append = :no_append)
  raise ArgumentError,"Invalid File" unless File.exists? file
  switch = (append == :append ? 1 : 0)
  send "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

Raises:

  • (ArgumentError)


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

def load_list(file,append = :no_append)
  raise ArgumentError,"Invalid File" unless File.exists? file
  switch = (append == :append ? 1 : 0)
  send "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)
  send 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).


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

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.



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

def pause; send("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)
  send(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.



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

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

#quitObject

Quits MPlayer



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

def quit
  send('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 = send 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.



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

def speed_incr(value)
  speed_setting :speed_incr, value
end

#speed_mult(value) ⇒ Object

Multiply the current speed by <value>.



155
156
157
# File 'lib/mplayer-ruby/slave_commands.rb', line 155

def speed_mult(value)
  speed_setting :speed_mult, value
end

#speed_set(value) ⇒ Object

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



161
162
163
# File 'lib/mplayer-ruby/slave_commands.rb', line 161

def speed_set(value)
  speed_setting :speed_set, value
end

#use_masterObject

Switch volume control between master and PCM.



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

def use_master; send("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 = send cmd, /Volume/
  resp.gsub("Volume: ","").gsub(" %\n","")
end