Class: Anyplayer::Mpd

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

Constant Summary

Constants inherited from Player

Player::DEFAULT_VOTES_TO_SKIP

Instance Method Summary collapse

Methods inherited from Player

#name, #paused?, #platforms, #vote, #votes

Constructor Details

#initializeMpd

Returns a new instance of Mpd.



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

def initialize
  @mpc = false
  super
end

Instance Method Details

#albumObject



60
61
62
# File 'lib/anyplayer/players/mpd.rb', line 60

def album
  mpc.current_song && mpc.current_song.album
end

#artistObject



56
57
58
# File 'lib/anyplayer/players/mpd.rb', line 56

def artist
  mpc.current_song && mpc.current_song.artist
end

#hostObject



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

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

#launched?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/anyplayer/players/mpd.rb', line 64

def launched?
  !!(@mpc && @mpc.connected? || connect)
end

#nextObject



35
36
37
38
# File 'lib/anyplayer/players/mpd.rb', line 35

def next
  mpc.next
  super
end

#pauseObject



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

def pause
  # ruby-mpd tries to send an additional argument to the MPD server
  # which at least doesn't work with Mopidy.
  mpc.send_command :pause
end

#playObject



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

def play
  mpc.play
end

#playpauseObject



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

def playpause
  mpc.paused? &&
    mpc.send_command(:play) ||
    mpc.send_command(:pause)
end

#prevObject



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

def prev
  mpc.previous
  super
end

#trackObject



52
53
54
# File 'lib/anyplayer/players/mpd.rb', line 52

def track
  mpc.current_song && mpc.current_song.title
end

#voldownObject



40
41
42
# File 'lib/anyplayer/players/mpd.rb', line 40

def voldown
  mpc.volume -= 10
end

#volumeObject



48
49
50
# File 'lib/anyplayer/players/mpd.rb', line 48

def volume
  mpc.volume
end

#volupObject



44
45
46
# File 'lib/anyplayer/players/mpd.rb', line 44

def volup
  mpc.volume += 10
end