anyplayer 1.1.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -1
- data/.ruby-version +1 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +82 -0
- data/CONTRIBUTING.md +22 -0
- data/Gemfile +0 -2
- data/README.md +17 -16
- data/Rakefile +10 -0
- data/anyplayer.gemspec +3 -1
- data/bin/rake +29 -0
- data/lib/anyplayer.rb +8 -2
- data/lib/anyplayer/command_line.rb +56 -26
- data/lib/anyplayer/player.rb +15 -7
- data/lib/anyplayer/players/amarok.rb +25 -19
- data/lib/anyplayer/players/itunes_mac.rb +22 -17
- data/lib/anyplayer/players/itunes_windows.rb +9 -6
- data/lib/anyplayer/players/mpd.rb +14 -8
- data/lib/anyplayer/players/noplayer.rb +2 -2
- data/lib/anyplayer/players/rdio_mac.rb +22 -18
- data/lib/anyplayer/players/rhythmbox.rb +15 -15
- data/lib/anyplayer/players/spotify_mac.rb +21 -17
- data/lib/anyplayer/players/xmms2.rb +34 -24
- data/lib/anyplayer/selector.rb +63 -32
- data/lib/anyplayer/version.rb +1 -1
- data/test/anyplayer_test.rb +12 -6
- data/test/command_line_test.rb +150 -0
- data/test/player_test.rb +44 -7
- data/test/players/mpd_test.rb +2 -4
- data/test/selector_test.rb +2 -2
- data/test/test_helper.rb +1 -2
- metadata +35 -32
- data/.envrc +0 -1
- data/Gemfile.lock +0 -22
@@ -1,66 +1,71 @@
|
|
1
1
|
class Anyplayer::ItunesMac < Anyplayer::Player
|
2
2
|
def play
|
3
|
-
itunes
|
3
|
+
itunes "play"
|
4
4
|
end
|
5
5
|
|
6
6
|
def pause
|
7
|
-
itunes
|
7
|
+
itunes "pause"
|
8
8
|
end
|
9
9
|
|
10
10
|
def playpause
|
11
|
-
itunes
|
11
|
+
itunes "playpause"
|
12
12
|
end
|
13
13
|
|
14
14
|
def prev
|
15
|
-
itunes
|
15
|
+
itunes "previous track"
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
19
|
def next
|
20
|
-
itunes
|
20
|
+
itunes "next track"
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
itunes
|
25
|
+
itunes "set sound volume to sound volume - 10"
|
26
26
|
end
|
27
27
|
|
28
28
|
def volup
|
29
|
-
itunes
|
29
|
+
itunes "set sound volume to sound volume + 10"
|
30
30
|
end
|
31
31
|
|
32
32
|
def volume
|
33
|
-
itunes
|
33
|
+
itunes "return sound volume"
|
34
34
|
end
|
35
35
|
|
36
36
|
def track
|
37
|
-
itunes
|
37
|
+
itunes "return name of current track"
|
38
38
|
end
|
39
39
|
|
40
40
|
def artist
|
41
|
-
itunes
|
41
|
+
itunes "return artist of current track"
|
42
42
|
end
|
43
43
|
|
44
44
|
def album
|
45
|
-
itunes
|
45
|
+
itunes "return album of current track"
|
46
46
|
end
|
47
47
|
|
48
48
|
def playing?
|
49
|
-
playing = itunes
|
49
|
+
playing = itunes "return player state is playing"
|
50
50
|
playing == "true"
|
51
51
|
end
|
52
52
|
|
53
53
|
def launched?
|
54
|
-
|
55
|
-
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
54
|
+
%x(osascript -e 'app "iTunes" is running').rstrip == "true"
|
56
55
|
end
|
57
56
|
|
58
57
|
def name
|
59
58
|
"iTunes Mac"
|
60
59
|
end
|
61
60
|
|
61
|
+
def platforms
|
62
|
+
[:mac]
|
63
|
+
end
|
64
|
+
|
65
|
+
|
62
66
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
67
|
+
|
68
|
+
def itunes(command)
|
69
|
+
%x(osascript -e 'tell app "iTunes" to #{command}').rstrip
|
70
|
+
end
|
66
71
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "win32ole"
|
3
3
|
rescue LoadError => e
|
4
|
-
raise LoadError.new("#{e.message}
|
4
|
+
raise LoadError.new("#{e.message} - You probably aren't on Windows")
|
5
5
|
end
|
6
6
|
|
7
7
|
class Anyplayer::ItunesWindows < Anyplayer::Player
|
@@ -59,10 +59,13 @@ class Anyplayer::ItunesWindows < Anyplayer::Player
|
|
59
59
|
"iTunes Windows"
|
60
60
|
end
|
61
61
|
|
62
|
+
def platforms
|
63
|
+
[:windows]
|
64
|
+
end
|
65
|
+
|
62
66
|
private
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
def itunes
|
69
|
+
itunes ||= WIN32OLE.new("iTunes.Application")
|
70
|
+
end
|
67
71
|
end
|
68
|
-
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
begin
|
3
|
-
require
|
3
|
+
require "ruby-mpd"
|
4
4
|
rescue LoadError => e
|
5
|
-
raise LoadError.new "#{e.message} —
|
5
|
+
raise LoadError.new "#{e.message} — Please install the ruby-mpd gem"
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
8
|
class Anyplayer::Mpd < Anyplayer::Player
|
10
9
|
def initialize
|
11
10
|
@mpc = false
|
@@ -51,15 +50,18 @@ class Anyplayer::Mpd < Anyplayer::Player
|
|
51
50
|
end
|
52
51
|
|
53
52
|
def track
|
54
|
-
|
53
|
+
song = current_song
|
54
|
+
return unless song
|
55
|
+
|
56
|
+
song.title || File.basename(song.file)
|
55
57
|
end
|
56
58
|
|
57
59
|
def artist
|
58
|
-
|
60
|
+
current_song&.artist
|
59
61
|
end
|
60
62
|
|
61
63
|
def album
|
62
|
-
|
64
|
+
current_song&.album
|
63
65
|
end
|
64
66
|
|
65
67
|
def launched?
|
@@ -67,10 +69,15 @@ class Anyplayer::Mpd < Anyplayer::Player
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def host
|
70
|
-
ENV[
|
72
|
+
ENV["MPD_HOST"] || super
|
71
73
|
end
|
72
74
|
|
73
75
|
private
|
76
|
+
|
77
|
+
def current_song
|
78
|
+
mpc.current_song
|
79
|
+
end
|
80
|
+
|
74
81
|
def connect
|
75
82
|
@mpc ||= MPD.new
|
76
83
|
@mpc.connect
|
@@ -83,4 +90,3 @@ class Anyplayer::Mpd < Anyplayer::Player
|
|
83
90
|
@mpc
|
84
91
|
end
|
85
92
|
end
|
86
|
-
|
@@ -1,66 +1,70 @@
|
|
1
1
|
class Anyplayer::RdioMac < Anyplayer::Player
|
2
2
|
def play
|
3
|
-
rdio
|
3
|
+
rdio "play"
|
4
4
|
end
|
5
5
|
|
6
6
|
def pause
|
7
|
-
rdio
|
7
|
+
rdio "pause"
|
8
8
|
end
|
9
9
|
|
10
10
|
def playpause
|
11
|
-
rdio
|
11
|
+
rdio "playpause"
|
12
12
|
end
|
13
13
|
|
14
14
|
def prev
|
15
|
-
rdio
|
15
|
+
rdio "previous track"
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
19
|
def next
|
20
|
-
rdio
|
20
|
+
rdio "next track"
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
rdio
|
25
|
+
rdio "set sound volume to sound volume - 10"
|
26
26
|
end
|
27
27
|
|
28
28
|
def volup
|
29
|
-
rdio
|
29
|
+
rdio "set sound volume to sound volume + 10"
|
30
30
|
end
|
31
31
|
|
32
32
|
def volume
|
33
|
-
rdio
|
33
|
+
rdio "return sound volume"
|
34
34
|
end
|
35
35
|
|
36
36
|
def track
|
37
|
-
rdio
|
37
|
+
rdio "return name of current track"
|
38
38
|
end
|
39
39
|
|
40
40
|
def artist
|
41
|
-
rdio
|
41
|
+
rdio "return artist of current track"
|
42
42
|
end
|
43
43
|
|
44
44
|
def album
|
45
|
-
rdio
|
45
|
+
rdio "return album of current track"
|
46
46
|
end
|
47
47
|
|
48
48
|
def playing?
|
49
|
-
playing = rdio
|
49
|
+
playing = rdio "return player state is playing"
|
50
50
|
playing == "true"
|
51
51
|
end
|
52
52
|
|
53
53
|
def launched?
|
54
|
-
|
55
|
-
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
54
|
+
%x(osascript -e 'app "rdio" is running').rstrip == "true"
|
56
55
|
end
|
57
56
|
|
58
57
|
def name
|
59
58
|
"Rdio Mac"
|
60
59
|
end
|
61
60
|
|
61
|
+
def platforms
|
62
|
+
[:mac]
|
63
|
+
end
|
64
|
+
|
62
65
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
66
|
+
|
67
|
+
def rdio(command)
|
68
|
+
%x(osascript -e 'tell app "rdio" to #{command}').rstrip
|
69
|
+
end
|
70
|
+
end
|
@@ -1,48 +1,48 @@
|
|
1
1
|
class Anyplayer::Rhythmbox < Anyplayer::Player
|
2
2
|
def playpause
|
3
|
-
rhythmbox
|
3
|
+
rhythmbox "play-pause"
|
4
4
|
end
|
5
5
|
|
6
6
|
def play
|
7
|
-
rhythmbox
|
7
|
+
rhythmbox "play"
|
8
8
|
end
|
9
9
|
|
10
10
|
def pause
|
11
|
-
rhythmbox
|
11
|
+
rhythmbox "pause"
|
12
12
|
end
|
13
13
|
|
14
14
|
def prev
|
15
|
-
rhythmbox
|
15
|
+
rhythmbox "previous"
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
19
|
def next
|
20
|
-
rhythmbox
|
20
|
+
rhythmbox "next"
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
rhythmbox
|
25
|
+
rhythmbox "volume-down"
|
26
26
|
end
|
27
27
|
|
28
28
|
def volup
|
29
|
-
rhythmbox
|
29
|
+
rhythmbox "volume-up"
|
30
30
|
end
|
31
31
|
|
32
32
|
def volume
|
33
|
-
rhythmbox
|
33
|
+
rhythmbox "print-volume"
|
34
34
|
end
|
35
35
|
|
36
36
|
def track
|
37
|
-
rhythmbox
|
37
|
+
rhythmbox "print-playing-format=%tt"
|
38
38
|
end
|
39
39
|
|
40
40
|
def artist
|
41
|
-
rhythmbox
|
41
|
+
rhythmbox "print-playing-format=%ta"
|
42
42
|
end
|
43
43
|
|
44
44
|
def album
|
45
|
-
rhythmbox
|
45
|
+
rhythmbox "print-playing-format=%at"
|
46
46
|
end
|
47
47
|
|
48
48
|
def launched?
|
@@ -50,8 +50,8 @@ class Anyplayer::Rhythmbox < Anyplayer::Player
|
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
53
|
-
def rhythmbox(command)
|
54
|
-
%x(rhythmbox-client --no-start --#{command}).rstrip
|
55
|
-
end
|
56
|
-
end
|
57
53
|
|
54
|
+
def rhythmbox(command)
|
55
|
+
%x(rhythmbox-client --no-start --#{command}).rstrip
|
56
|
+
end
|
57
|
+
end
|
@@ -1,66 +1,70 @@
|
|
1
1
|
class Anyplayer::SpotifyMac < Anyplayer::Player
|
2
2
|
def play
|
3
|
-
spotify
|
3
|
+
spotify "play"
|
4
4
|
end
|
5
5
|
|
6
6
|
def pause
|
7
|
-
spotify
|
7
|
+
spotify "pause"
|
8
8
|
end
|
9
9
|
|
10
10
|
def playpause
|
11
|
-
spotify
|
11
|
+
spotify "playpause"
|
12
12
|
end
|
13
13
|
|
14
14
|
def prev
|
15
|
-
spotify
|
15
|
+
spotify "previous track"
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
19
|
def next
|
20
|
-
spotify
|
20
|
+
spotify "next track"
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
spotify
|
25
|
+
spotify "set sound volume to sound volume - 10"
|
26
26
|
end
|
27
27
|
|
28
28
|
def volup
|
29
|
-
spotify
|
29
|
+
spotify "set sound volume to sound volume + 10"
|
30
30
|
end
|
31
31
|
|
32
32
|
def volume
|
33
|
-
spotify
|
33
|
+
spotify "return sound volume"
|
34
34
|
end
|
35
35
|
|
36
36
|
def track
|
37
|
-
spotify
|
37
|
+
spotify "return name of current track"
|
38
38
|
end
|
39
39
|
|
40
40
|
def artist
|
41
|
-
spotify
|
41
|
+
spotify "return artist of current track"
|
42
42
|
end
|
43
43
|
|
44
44
|
def album
|
45
|
-
spotify
|
45
|
+
spotify "return album of current track"
|
46
46
|
end
|
47
47
|
|
48
48
|
def playing?
|
49
|
-
playing = spotify
|
49
|
+
playing = spotify "return player state is playing"
|
50
50
|
playing == "true"
|
51
51
|
end
|
52
52
|
|
53
53
|
def launched?
|
54
|
-
|
55
|
-
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
54
|
+
%x(osascript -e 'app "Spotify" is running').rstrip == "true"
|
56
55
|
end
|
57
56
|
|
58
57
|
def name
|
59
58
|
"Spotify Mac"
|
60
59
|
end
|
61
60
|
|
61
|
+
def platforms
|
62
|
+
[:mac]
|
63
|
+
end
|
64
|
+
|
62
65
|
private
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
+
|
67
|
+
def spotify(command)
|
68
|
+
%x(osascript -e 'tell app "Spotify" to #{command}').rstrip
|
69
|
+
end
|
66
70
|
end
|
@@ -1,77 +1,87 @@
|
|
1
1
|
class Anyplayer::Xmms2 < Anyplayer::Player
|
2
2
|
def playpause
|
3
|
-
xmms2
|
3
|
+
xmms2 "toggle"
|
4
4
|
end
|
5
5
|
|
6
6
|
def play
|
7
|
-
xmms2
|
7
|
+
xmms2 "play"
|
8
8
|
end
|
9
9
|
|
10
10
|
def pause
|
11
|
-
xmms2
|
11
|
+
xmms2 "pause"
|
12
12
|
end
|
13
13
|
|
14
14
|
def prev
|
15
|
-
xmms2
|
15
|
+
xmms2 "prev"
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
19
|
def next
|
20
|
-
xmms2
|
20
|
+
xmms2 "next"
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
|
26
|
-
new_volume = (current < 11 ? 0 : current - 10)
|
27
|
-
xmms2 "server volume #{new_volume}"
|
25
|
+
set_volume volume - 10
|
28
26
|
end
|
29
27
|
|
30
28
|
def volup
|
31
|
-
|
32
|
-
new_volume = (current > 89 ? 100 : current + 10)
|
33
|
-
xmms2 "server volume #{new_volume}"
|
29
|
+
set_volume volume + 10
|
34
30
|
end
|
35
31
|
|
36
32
|
def volume
|
37
33
|
# currently just the first (left?) channel
|
38
|
-
xmms2(
|
39
|
-
$1
|
34
|
+
xmms2("server volume").split("\n").first.sub(/([^0-9]*)/, "").to_i
|
40
35
|
end
|
41
36
|
|
42
37
|
def track
|
43
|
-
xmms2 "
|
38
|
+
xmms2 "current -f '${title}'"
|
44
39
|
end
|
45
40
|
|
46
41
|
def artist
|
47
|
-
xmms2 "
|
42
|
+
xmms2 "current -f '${artist}'"
|
48
43
|
end
|
49
44
|
|
50
45
|
def album
|
51
|
-
xmms2 "
|
46
|
+
xmms2 "current -f '${album}'"
|
52
47
|
end
|
53
48
|
|
54
49
|
def playing?
|
55
|
-
xmms2("
|
50
|
+
xmms2("current -f '${playback_status}'") == "Playing"
|
56
51
|
end
|
57
52
|
|
58
53
|
def paused?
|
59
|
-
xmms2("
|
54
|
+
xmms2("current -f '${playback_status}'") == "Paused"
|
60
55
|
end
|
61
56
|
|
62
57
|
def launched?
|
63
58
|
# xmms2 autolaunches the daemon, so this should always be true
|
64
|
-
%x(xmms2
|
59
|
+
%x(xmms2 current 2> /dev/null)
|
65
60
|
$? == 0
|
66
61
|
end
|
67
62
|
|
68
63
|
def host
|
69
|
-
ENV[
|
64
|
+
ENV["XMMS_PATH"] || super
|
65
|
+
end
|
66
|
+
|
67
|
+
def platforms
|
68
|
+
[:unix, :linux]
|
70
69
|
end
|
71
70
|
|
72
71
|
private
|
73
|
-
def xmms2(command)
|
74
|
-
%x(xmms2 #{command}).split("\n").first.strip
|
75
|
-
end
|
76
|
-
end
|
77
72
|
|
73
|
+
def xmms2(command)
|
74
|
+
ret = %x(xmms2 #{command}).split("\n").first
|
75
|
+
ret ? ret.strip : ""
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_volume(num)
|
79
|
+
num = if num < 0
|
80
|
+
0
|
81
|
+
elsif num > 100
|
82
|
+
100
|
83
|
+
end
|
84
|
+
|
85
|
+
xmms2 "server volume #{num}"
|
86
|
+
end
|
87
|
+
end
|