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, #vote, #votes

Constructor Details

#initialize ⇒ Mpd

Returns a new instance of Mpd.



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

def initialize
  @mpc = false
  super
end

Instance Method Details

#album ⇒ Object



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

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

#artist ⇒ Object



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

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

#host ⇒ Object



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

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

#launched? ⇒ Boolean

Returns:

  • (Boolean)


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

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

#next ⇒ Object



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

def next
  mpc.next
  super
end

#pause ⇒ Object



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

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

#play ⇒ Object



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

def play
  mpc.play
end

#playpause ⇒ Object



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

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

#prev ⇒ Object



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

def prev
  mpc.previous
  super
end

#track ⇒ Object



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

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

#voldown ⇒ Object



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

def voldown
  mpc.volume -= 10
end

#volume ⇒ Object



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

def volume
  mpc.volume
end

#volup ⇒ Object



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

def volup
  mpc.volume += 10
end