Class: Anyplayer::Mpd
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
#initialize ⇒ Mpd
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
#album ⇒ Object
63
64
65
|
# File 'lib/anyplayer/players/mpd.rb', line 63
def album
current_song&.album
end
|
#artist ⇒ Object
59
60
61
|
# File 'lib/anyplayer/players/mpd.rb', line 59
def artist
current_song&.artist
end
|
#host ⇒ Object
71
72
73
|
# File 'lib/anyplayer/players/mpd.rb', line 71
def host
ENV["MPD_HOST"] || super
end
|
#launched? ⇒ Boolean
67
68
69
|
# File 'lib/anyplayer/players/mpd.rb', line 67
def launched?
!!(@mpc && @mpc.connected? || connect)
end
|
#next ⇒ Object
35
36
37
38
|
# File 'lib/anyplayer/players/mpd.rb', line 35
def next
mpc.next
super
end
|
#pause ⇒ Object
24
25
26
27
28
|
# File 'lib/anyplayer/players/mpd.rb', line 24
def pause
mpc.send_command :pause
end
|
#play ⇒ Object
20
21
22
|
# File 'lib/anyplayer/players/mpd.rb', line 20
def play
mpc.play
end
|
#playpause ⇒ Object
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
|
#prev ⇒ Object
30
31
32
33
|
# File 'lib/anyplayer/players/mpd.rb', line 30
def prev
mpc.previous
super
end
|
#track ⇒ Object
52
53
54
55
56
57
|
# File 'lib/anyplayer/players/mpd.rb', line 52
def track
song = current_song
return unless song
song.title || File.basename(song.file)
end
|
#voldown ⇒ Object
40
41
42
|
# File 'lib/anyplayer/players/mpd.rb', line 40
def voldown
mpc.volume -= 10
end
|
#volume ⇒ Object
48
49
50
|
# File 'lib/anyplayer/players/mpd.rb', line 48
def volume
mpc.volume
end
|
#volup ⇒ Object
44
45
46
|
# File 'lib/anyplayer/players/mpd.rb', line 44
def volup
mpc.volume += 10
end
|