Class: Anyplayer::Xmms2

Inherits:
Player
  • Object
show all
Defined in:
lib/anyplayer/players/xmms2.rb

Constant Summary

Constants inherited from Player

Player::DEFAULT_VOTES_TO_SKIP

Instance Method Summary collapse

Methods inherited from Player

#initialize, #name, #vote, #votes

Constructor Details

This class inherits a constructor from Anyplayer::Player

Instance Method Details

#album ⇒ Object



50
51
52
# File 'lib/anyplayer/players/xmms2.rb', line 50

def album
  xmms2 "status -f '${album}'"
end

#artist ⇒ Object



46
47
48
# File 'lib/anyplayer/players/xmms2.rb', line 46

def artist
  xmms2 "status -f '${artist}'"
end

#host ⇒ Object



68
69
70
# File 'lib/anyplayer/players/xmms2.rb', line 68

def host
  ENV['XMMS_PATH'] || super
end

#launched? ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
# File 'lib/anyplayer/players/xmms2.rb', line 62

def launched?
  # xmms2 autolaunches the daemon, so this should always be true
  %x(xmms2 status 2> /dev/null)
  $? == 0
end

#next ⇒ Object



19
20
21
22
# File 'lib/anyplayer/players/xmms2.rb', line 19

def next
  xmms2 'next'
  super
end

#pause ⇒ Object



10
11
12
# File 'lib/anyplayer/players/xmms2.rb', line 10

def pause
  xmms2 'pause'
end

#paused? ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/anyplayer/players/xmms2.rb', line 58

def paused?
  xmms2("status -f '${playback_status}'") == "Paused"
end

#play ⇒ Object



6
7
8
# File 'lib/anyplayer/players/xmms2.rb', line 6

def play
  xmms2 'play'
end

#playing? ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/anyplayer/players/xmms2.rb', line 54

def playing?
  xmms2("status -f '${playback_status}'") == "Playing"
end

#playpause ⇒ Object



2
3
4
# File 'lib/anyplayer/players/xmms2.rb', line 2

def playpause
  xmms2 'toggle'
end

#prev ⇒ Object



14
15
16
17
# File 'lib/anyplayer/players/xmms2.rb', line 14

def prev
  xmms2 'prev'
  super
end

#track ⇒ Object



42
43
44
# File 'lib/anyplayer/players/xmms2.rb', line 42

def track
  xmms2 "status -f '${title}'"
end

#voldown ⇒ Object



24
25
26
27
28
# File 'lib/anyplayer/players/xmms2.rb', line 24

def voldown
  current = volume.to_i
  new_volume = (current < 11 ? 0 : current - 10)
  xmms2 "server volume #{new_volume}"
end

#volume ⇒ Object



36
37
38
39
40
# File 'lib/anyplayer/players/xmms2.rb', line 36

def volume
  # currently just the first (left?) channel
  xmms2('server volume').split("\n").first.sub(/([^0-9]*)/, '')
  $1
end

#volup ⇒ Object



30
31
32
33
34
# File 'lib/anyplayer/players/xmms2.rb', line 30

def volup
  current = volume.to_i
  new_volume = (current > 89 ? 100 : current + 10)
  xmms2 "server volume #{new_volume}"
end