anyplayer 1.1.1 → 1.2.0
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 +76 -0
- data/CONTRIBUTING.md +22 -0
- data/Gemfile +0 -2
- data/MIT-LICENSE +20 -0
- data/README.md +20 -14
- data/Rakefile +10 -0
- data/anyplayer.gemspec +3 -0
- 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 +39 -26
- data/Gemfile.lock +0 -22
@@ -1,61 +1,67 @@
|
|
1
1
|
class Anyplayer::Amarok < Anyplayer::Player
|
2
2
|
def playpause
|
3
|
-
amarok
|
3
|
+
amarok "PlayPause"
|
4
4
|
end
|
5
5
|
|
6
6
|
def play
|
7
|
-
amarok
|
7
|
+
amarok "Play"
|
8
8
|
end
|
9
9
|
|
10
10
|
def pause
|
11
|
-
amarok
|
11
|
+
amarok "Pause"
|
12
12
|
end
|
13
13
|
|
14
14
|
def prev
|
15
|
-
amarok
|
15
|
+
amarok "Prev"
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
19
|
def next
|
20
|
-
amarok
|
20
|
+
amarok "Next"
|
21
21
|
super
|
22
22
|
end
|
23
23
|
|
24
24
|
def voldown
|
25
|
-
amarok
|
25
|
+
amarok "VolumeDown 5"
|
26
26
|
end
|
27
27
|
|
28
28
|
def volup
|
29
|
-
amarok
|
29
|
+
amarok "VolumeUp 5"
|
30
30
|
end
|
31
31
|
|
32
32
|
def volume
|
33
|
-
amarok
|
33
|
+
amarok "VolumeGet"
|
34
34
|
end
|
35
35
|
|
36
36
|
def track
|
37
|
-
amarok_get_meta
|
37
|
+
amarok_get_meta "title"
|
38
38
|
end
|
39
39
|
|
40
40
|
def artist
|
41
|
-
amarok_get_meta
|
41
|
+
amarok_get_meta "artist"
|
42
42
|
end
|
43
43
|
|
44
44
|
def album
|
45
|
-
amarok_get_meta
|
45
|
+
amarok_get_meta "album"
|
46
46
|
end
|
47
47
|
|
48
48
|
def launched?
|
49
|
-
not %x(qdbus org.kde.amarok 2>&1).match(
|
49
|
+
not %x(qdbus org.kde.amarok 2>&1).match(
|
50
|
+
/does not exist|not found|cannot find the path specified/
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
def platforms
|
55
|
+
[:unix, :linux]
|
50
56
|
end
|
51
57
|
|
52
58
|
private
|
53
|
-
def amarok(command)
|
54
|
-
%x(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.#{command}).rstrip
|
55
|
-
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
60
|
+
def amarok(command)
|
61
|
+
%x(qdbus org.kde.amarok /Player org.freedesktop.MediaPlayer.#{command}).rstrip
|
62
|
+
end
|
61
63
|
|
64
|
+
def amarok_get_meta(name)
|
65
|
+
amarok("GetMetadata").match(/#{name}: (\S.*)/)[1] rescue nil
|
66
|
+
end
|
67
|
+
end
|
@@ -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
|