anyplayer 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -1
- data/.ruby-version +1 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +29 -1
- data/README.md +13 -4
- data/Rakefile +1 -0
- data/anyplayer.gemspec +1 -0
- data/bin/rake +29 -0
- data/lib/anyplayer.rb +0 -1
- data/lib/anyplayer/command_line.rb +0 -1
- data/lib/anyplayer/player.rb +1 -4
- data/lib/anyplayer/players/amarok.rb +12 -14
- data/lib/anyplayer/players/itunes_mac.rb +12 -12
- data/lib/anyplayer/players/itunes_windows.rb +1 -3
- data/lib/anyplayer/players/mpd.rb +12 -7
- data/lib/anyplayer/players/noplayer.rb +0 -1
- data/lib/anyplayer/players/rdio_mac.rb +12 -13
- data/lib/anyplayer/players/rhythmbox.rb +11 -13
- data/lib/anyplayer/players/spotify_mac.rb +12 -13
- data/lib/anyplayer/players/xmms2.rb +11 -13
- data/lib/anyplayer/selector.rb +9 -11
- data/lib/anyplayer/version.rb +1 -1
- data/test/command_line_test.rb +9 -10
- data/test/player_test.rb +2 -9
- data/test/players/mpd_test.rb +1 -3
- data/test/test_helper.rb +1 -1
- metadata +18 -18
- data/.envrc +0 -1
- data/Gemfile.lock +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1a9384589559bf8cb5d5296227003b72bbb33ca5970577a35d947cc6edbf7f9c
|
4
|
+
data.tar.gz: 2efd1d446b28792bace849ff9860a64150d20884b2e4624f7cc66aa74da8bfc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42d4c7c05065c140bc28d77c45e30efb07868f7292d78e676b651314ddefe00204c0f0d9e2c7cc828d06408a3c0d7a1da57fbb3ba89b90c961420d7a7ea8064a
|
7
|
+
data.tar.gz: 4eafc888d550338ce4bad1792a1b0b83368463640c4cc28de49e5491a99a374d080c757420128d7647c8aa351b9ec84538323e48f96f91a3d9dd93b27f2bb5b4
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,12 +3,24 @@ Changelog
|
|
3
3
|
|
4
4
|
Anyplayer tries its best to follow Semantic Versioning.
|
5
5
|
|
6
|
+
## Unreleased
|
7
|
+
|
8
|
+
## v1.2.0 (2020-10-08)
|
9
|
+
|
10
|
+
Features:
|
11
|
+
|
12
|
+
- When using mpd, fallback to the file name if there is no track name.
|
13
|
+
|
14
|
+
Dependencies:
|
15
|
+
|
16
|
+
- Drop Ruby 1.9.3 and 2.0.0 support.
|
17
|
+
|
6
18
|
## v1.1.5 (2014-07-07)
|
7
19
|
|
8
20
|
Bugfixes:
|
9
21
|
|
10
22
|
- Better platform detection by letting players list the platforms
|
11
|
-
they are intended to work on
|
23
|
+
they are intended to work on (thanks @inspire22)
|
12
24
|
|
13
25
|
## v1.1.4 (2014-07-07)
|
14
26
|
|
@@ -46,3 +58,19 @@ Features:
|
|
46
58
|
## v1.0.0 (2013-07-26)
|
47
59
|
|
48
60
|
First major release.
|
61
|
+
|
62
|
+
## v0.0.4
|
63
|
+
|
64
|
+
Unstable version.
|
65
|
+
|
66
|
+
## v0.0.3
|
67
|
+
|
68
|
+
Unstable version.
|
69
|
+
|
70
|
+
## v0.0.2
|
71
|
+
|
72
|
+
Unstable version.
|
73
|
+
|
74
|
+
## v0.0.1
|
75
|
+
|
76
|
+
Unstable version.
|
data/README.md
CHANGED
@@ -43,8 +43,17 @@ a player is running
|
|
43
43
|
Or in Ruby
|
44
44
|
----------
|
45
45
|
|
46
|
+
In your Gemfile:
|
47
|
+
|
48
|
+
```rb
|
49
|
+
# Interact with the current music player
|
50
|
+
gem "anyplayer"
|
51
|
+
```
|
52
|
+
|
53
|
+
In your code:
|
54
|
+
|
46
55
|
```ruby
|
47
|
-
require
|
56
|
+
require "anyplayer"
|
48
57
|
player = Anyplayer::Selector.new.player
|
49
58
|
|
50
59
|
player.launched? # => true
|
@@ -71,9 +80,9 @@ Here a few useful commands while developping:
|
|
71
80
|
|
72
81
|
```sh
|
73
82
|
$ ruby -Ilib bin/anyplayer # Use the anyplayer command-line from source
|
74
|
-
$
|
75
|
-
$
|
76
|
-
$
|
83
|
+
$ bin/rake test # Launch tests
|
84
|
+
$ bin/rake install # Install from source
|
85
|
+
$ bin/rake console # Launch console
|
77
86
|
```
|
78
87
|
|
79
88
|
|
data/Rakefile
CHANGED
data/anyplayer.gemspec
CHANGED
data/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rake", "rake")
|
data/lib/anyplayer.rb
CHANGED
data/lib/anyplayer/player.rb
CHANGED
@@ -31,7 +31,7 @@ class Anyplayer::Player
|
|
31
31
|
# Example:
|
32
32
|
# player.name # => iTunes
|
33
33
|
def name
|
34
|
-
self.class.to_s.gsub(/^.*::/,
|
34
|
+
self.class.to_s.gsub(/^.*::/, "")
|
35
35
|
end
|
36
36
|
|
37
37
|
# Default paused is not playing
|
@@ -75,12 +75,9 @@ class Anyplayer::Player
|
|
75
75
|
[:mac, :windows, :linux, :unix]
|
76
76
|
end
|
77
77
|
|
78
|
-
|
79
78
|
private
|
80
79
|
|
81
80
|
def reset_votes
|
82
81
|
@votes = 0
|
83
82
|
end
|
84
|
-
|
85
83
|
end
|
86
|
-
|
@@ -1,48 +1,48 @@
|
|
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?
|
@@ -55,7 +55,6 @@ class Anyplayer::Amarok < Anyplayer::Player
|
|
55
55
|
[:unix, :linux]
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
58
|
private
|
60
59
|
|
61
60
|
def amarok(command)
|
@@ -63,7 +62,6 @@ class Anyplayer::Amarok < Anyplayer::Player
|
|
63
62
|
end
|
64
63
|
|
65
64
|
def amarok_get_meta(name)
|
66
|
-
amarok(
|
65
|
+
amarok("GetMetadata").match(/#{name}: (\S.*)/)[1] rescue nil
|
67
66
|
end
|
68
67
|
end
|
69
|
-
|
@@ -1,52 +1,52 @@
|
|
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
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
begin
|
2
|
-
require
|
2
|
+
require "win32ole"
|
3
3
|
rescue LoadError => e
|
4
4
|
raise LoadError.new("#{e.message} - You probably aren't on Windows")
|
5
5
|
end
|
@@ -63,11 +63,9 @@ class Anyplayer::ItunesWindows < Anyplayer::Player
|
|
63
63
|
[:windows]
|
64
64
|
end
|
65
65
|
|
66
|
-
|
67
66
|
private
|
68
67
|
|
69
68
|
def itunes
|
70
69
|
itunes ||= WIN32OLE.new("iTunes.Application")
|
71
70
|
end
|
72
71
|
end
|
73
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
begin
|
3
|
-
require
|
3
|
+
require "ruby-mpd"
|
4
4
|
rescue LoadError => e
|
5
5
|
raise LoadError.new "#{e.message} — Please install the ruby-mpd gem"
|
6
6
|
end
|
@@ -50,15 +50,18 @@ class Anyplayer::Mpd < Anyplayer::Player
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def track
|
53
|
-
|
53
|
+
song = current_song
|
54
|
+
return unless song
|
55
|
+
|
56
|
+
song.title || File.basename(song.file)
|
54
57
|
end
|
55
58
|
|
56
59
|
def artist
|
57
|
-
|
60
|
+
current_song&.artist
|
58
61
|
end
|
59
62
|
|
60
63
|
def album
|
61
|
-
|
64
|
+
current_song&.album
|
62
65
|
end
|
63
66
|
|
64
67
|
def launched?
|
@@ -66,12 +69,15 @@ class Anyplayer::Mpd < Anyplayer::Player
|
|
66
69
|
end
|
67
70
|
|
68
71
|
def host
|
69
|
-
ENV[
|
72
|
+
ENV["MPD_HOST"] || super
|
70
73
|
end
|
71
74
|
|
72
|
-
|
73
75
|
private
|
74
76
|
|
77
|
+
def current_song
|
78
|
+
mpc.current_song
|
79
|
+
end
|
80
|
+
|
75
81
|
def connect
|
76
82
|
@mpc ||= MPD.new
|
77
83
|
@mpc.connect
|
@@ -84,4 +90,3 @@ class Anyplayer::Mpd < Anyplayer::Player
|
|
84
90
|
@mpc
|
85
91
|
end
|
86
92
|
end
|
87
|
-
|
@@ -1,52 +1,52 @@
|
|
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
|
|
@@ -62,7 +62,6 @@ class Anyplayer::RdioMac < Anyplayer::Player
|
|
62
62
|
[:mac]
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
65
|
private
|
67
66
|
|
68
67
|
def rdio(command)
|
@@ -1,59 +1,57 @@
|
|
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?
|
49
49
|
%x(rhythmbox-client --no-start --print-playing 2>/dev/null).rstrip != ""
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
52
|
private
|
54
53
|
|
55
54
|
def rhythmbox(command)
|
56
55
|
%x(rhythmbox-client --no-start --#{command}).rstrip
|
57
56
|
end
|
58
57
|
end
|
59
|
-
|
@@ -1,52 +1,52 @@
|
|
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
|
|
@@ -62,7 +62,6 @@ class Anyplayer::SpotifyMac < Anyplayer::Player
|
|
62
62
|
[:mac]
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
65
|
private
|
67
66
|
|
68
67
|
def spotify(command)
|
@@ -1,23 +1,23 @@
|
|
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
|
|
@@ -31,7 +31,7 @@ class Anyplayer::Xmms2 < Anyplayer::Player
|
|
31
31
|
|
32
32
|
def volume
|
33
33
|
# currently just the first (left?) channel
|
34
|
-
xmms2(
|
34
|
+
xmms2("server volume").split("\n").first.sub(/([^0-9]*)/, "").to_i
|
35
35
|
end
|
36
36
|
|
37
37
|
def track
|
@@ -61,14 +61,13 @@ class Anyplayer::Xmms2 < Anyplayer::Player
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def host
|
64
|
-
ENV[
|
64
|
+
ENV["XMMS_PATH"] || super
|
65
65
|
end
|
66
66
|
|
67
67
|
def platforms
|
68
68
|
[:unix, :linux]
|
69
69
|
end
|
70
70
|
|
71
|
-
|
72
71
|
private
|
73
72
|
|
74
73
|
def xmms2(command)
|
@@ -78,12 +77,11 @@ class Anyplayer::Xmms2 < Anyplayer::Player
|
|
78
77
|
|
79
78
|
def set_volume(num)
|
80
79
|
num = if num < 0
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
0
|
81
|
+
elsif num > 100
|
82
|
+
100
|
83
|
+
end
|
85
84
|
|
86
85
|
xmms2 "server volume #{num}"
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
data/lib/anyplayer/selector.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "rbconfig"
|
2
2
|
|
3
|
-
# The Selector is the tool that will find you the currently running player
|
3
|
+
# The Selector is the tool that will find you the currently running player
|
4
|
+
# on your platform.
|
4
5
|
#
|
5
6
|
# Example:
|
6
7
|
#
|
@@ -22,19 +23,16 @@ module Anyplayer
|
|
22
23
|
# Returns an instance of the first music player that's launched
|
23
24
|
def player
|
24
25
|
PLAYERS.each do |player|
|
25
|
-
player_load(player)
|
26
|
+
player_load(player) || next
|
26
27
|
|
27
28
|
instance = player_class(player).new
|
28
|
-
player_on_platform?(instance)
|
29
|
+
player_on_platform?(instance) || next
|
29
30
|
|
30
|
-
if player_launched?(instance)
|
31
|
-
return instance
|
32
|
-
end
|
31
|
+
return instance if player_launched?(instance)
|
33
32
|
end
|
34
33
|
nil
|
35
34
|
end
|
36
35
|
|
37
|
-
|
38
36
|
private
|
39
37
|
|
40
38
|
def platform
|
@@ -71,19 +69,19 @@ module Anyplayer
|
|
71
69
|
|
72
70
|
def player_on_platform?(player)
|
73
71
|
result = player.platforms.include?(platform)
|
74
|
-
log " not on platform"
|
72
|
+
log " not on platform" unless result
|
75
73
|
result
|
76
74
|
end
|
77
75
|
|
78
76
|
def player_class(player)
|
79
|
-
camelized = player.to_s.split(/_/).map
|
80
|
-
Anyplayer
|
77
|
+
camelized = player.to_s.split(/_/).map(&:capitalize).join
|
78
|
+
Anyplayer.const_get(camelized)
|
81
79
|
end
|
82
80
|
|
83
81
|
def player_launched?(player)
|
84
82
|
seconds = 5
|
85
83
|
begin
|
86
|
-
Timeout
|
84
|
+
Timeout.timeout(seconds) do
|
87
85
|
launched = player.launched?
|
88
86
|
log launched ? " launched" : " not launched"
|
89
87
|
launched
|
data/lib/anyplayer/version.rb
CHANGED
data/test/command_line_test.rb
CHANGED
@@ -2,8 +2,6 @@ require "test_helper"
|
|
2
2
|
require "anyplayer/command_line"
|
3
3
|
|
4
4
|
class CommandLineTest < Minitest::Test
|
5
|
-
include FlexMock::TestCase
|
6
|
-
|
7
5
|
USAGE = "Usage: anyplayer [-v] [command]
|
8
6
|
|
9
7
|
Where command is one of: playpause, play, pause, next, prev, voldown, volup, volume, track, artist, album, vote, name, launched, paused, playing.
|
@@ -40,7 +38,6 @@ Player connected: Fake Player.
|
|
40
38
|
Anyplayer::CommandLine.parse(%w(-v play))
|
41
39
|
end
|
42
40
|
|
43
|
-
|
44
41
|
# Actions
|
45
42
|
|
46
43
|
def test_playpause
|
@@ -113,38 +110,40 @@ Player connected: Fake Player.
|
|
113
110
|
Anyplayer::CommandLine.parse(%w(name))
|
114
111
|
end
|
115
112
|
|
116
|
-
|
117
113
|
# Booleans
|
118
114
|
|
119
115
|
def test_launched_true
|
120
|
-
flexmock(Anyplayer::CommandLine).should_receive(:exit)
|
116
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit) # .with(1)
|
121
117
|
flexmock(@player).should_receive(:launched?).once.and_return(true)
|
122
118
|
Anyplayer::CommandLine.parse(%w(launched))
|
123
119
|
end
|
120
|
+
|
124
121
|
def test_launched_false
|
125
|
-
flexmock(Anyplayer::CommandLine).should_receive(:exit)
|
122
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit) # .with(0)
|
126
123
|
flexmock(@player).should_receive(:launched?).once.and_return(false)
|
127
124
|
Anyplayer::CommandLine.parse(%w(launched))
|
128
125
|
end
|
129
126
|
|
130
127
|
def test_playing_true
|
131
|
-
flexmock(Anyplayer::CommandLine).should_receive(:exit).once
|
128
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once # .with(1)
|
132
129
|
flexmock(@player).should_receive(:playing?).once.and_return(true)
|
133
130
|
Anyplayer::CommandLine.parse(%w(playing))
|
134
131
|
end
|
132
|
+
|
135
133
|
def test_playing_false
|
136
|
-
flexmock(Anyplayer::CommandLine).should_receive(:exit).once
|
134
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once # .with(0)
|
137
135
|
flexmock(@player).should_receive(:playing?).once.and_return(false)
|
138
136
|
Anyplayer::CommandLine.parse(%w(playing))
|
139
137
|
end
|
140
138
|
|
141
139
|
def test_paused_true
|
142
|
-
flexmock(Anyplayer::CommandLine).should_receive(:exit).once
|
140
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once # .with(1)
|
143
141
|
flexmock(@player).should_receive(:paused?).once.and_return(true)
|
144
142
|
Anyplayer::CommandLine.parse(%w(paused))
|
145
143
|
end
|
144
|
+
|
146
145
|
def test_paused_false
|
147
|
-
flexmock(Anyplayer::CommandLine).should_receive(:exit).once
|
146
|
+
flexmock(Anyplayer::CommandLine).should_receive(:exit).once # .with(0)
|
148
147
|
flexmock(@player).should_receive(:paused?).once.and_return(false)
|
149
148
|
Anyplayer::CommandLine.parse(%w(paused))
|
150
149
|
end
|
data/test/player_test.rb
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
class PlayerTest < Minitest::Test
|
4
|
-
include FlexMock::TestCase
|
5
|
-
|
6
4
|
def setup
|
7
5
|
@player = Noplayer.new
|
8
6
|
end
|
9
7
|
|
10
|
-
|
11
8
|
# Default name
|
12
9
|
|
13
10
|
def test_default_name
|
@@ -19,7 +16,6 @@ class PlayerTest < Minitest::Test
|
|
19
16
|
assert_equal "Bar", @player.name
|
20
17
|
end
|
21
18
|
|
22
|
-
|
23
19
|
# Default paused?
|
24
20
|
|
25
21
|
def test_paused_is_false_if_not_playing
|
@@ -32,7 +28,6 @@ class PlayerTest < Minitest::Test
|
|
32
28
|
assert !@player.paused?
|
33
29
|
end
|
34
30
|
|
35
|
-
|
36
31
|
# Default playpause
|
37
32
|
|
38
33
|
def test_playpause_toggles_play
|
@@ -49,7 +44,6 @@ class PlayerTest < Minitest::Test
|
|
49
44
|
@player.playpause
|
50
45
|
end
|
51
46
|
|
52
|
-
|
53
47
|
# Votes
|
54
48
|
|
55
49
|
def test_votes
|
@@ -61,7 +55,7 @@ class PlayerTest < Minitest::Test
|
|
61
55
|
assert_equal @player.votes, 0
|
62
56
|
else
|
63
57
|
assert_equal @player.votes, i + 1
|
64
|
-
|
58
|
+
end
|
65
59
|
end
|
66
60
|
end
|
67
61
|
|
@@ -90,8 +84,7 @@ class PlayerTest < Minitest::Test
|
|
90
84
|
assert_equal @player.votes, 0
|
91
85
|
else
|
92
86
|
assert_equal @player.votes, i + 1
|
93
|
-
|
87
|
+
end
|
94
88
|
end
|
95
89
|
end
|
96
|
-
|
97
90
|
end
|
data/test/players/mpd_test.rb
CHANGED
@@ -3,11 +3,9 @@ require "ruby-mpd"
|
|
3
3
|
require "anyplayer/players/mpd"
|
4
4
|
|
5
5
|
class MpdTest < Minitest::Test
|
6
|
-
include FlexMock::TestCase
|
7
|
-
|
8
6
|
def setup
|
9
7
|
@mpd_instance_mock = flexmock("mpd")
|
10
|
-
flexmock(MPD, "MPD", :
|
8
|
+
flexmock(MPD, "MPD", new: @mpd_instance_mock)
|
11
9
|
end
|
12
10
|
|
13
11
|
def test_uses_ruby_mpd_gem
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anyplayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sunny Ripert
|
@@ -9,62 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby-mpd
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 0.3.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.3.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: minitest
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: flexmock
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description: Play/pause/skip songs in iTunes Mac, iTunes Windows, Spotify Mac, Rdio
|
@@ -74,21 +74,22 @@ email:
|
|
74
74
|
- gordon@gordondiggs.com
|
75
75
|
executables:
|
76
76
|
- anyplayer
|
77
|
+
- rake
|
77
78
|
extensions: []
|
78
79
|
extra_rdoc_files: []
|
79
80
|
files:
|
80
|
-
- .
|
81
|
-
- .
|
82
|
-
- .travis.yml
|
81
|
+
- ".gitignore"
|
82
|
+
- ".ruby-version"
|
83
|
+
- ".travis.yml"
|
83
84
|
- CHANGELOG.md
|
84
85
|
- CONTRIBUTING.md
|
85
86
|
- Gemfile
|
86
|
-
- Gemfile.lock
|
87
87
|
- MIT-LICENSE
|
88
88
|
- README.md
|
89
89
|
- Rakefile
|
90
90
|
- anyplayer.gemspec
|
91
91
|
- bin/anyplayer
|
92
|
+
- bin/rake
|
92
93
|
- lib/anyplayer.rb
|
93
94
|
- lib/anyplayer/command_line.rb
|
94
95
|
- lib/anyplayer/player.rb
|
@@ -119,17 +120,16 @@ require_paths:
|
|
119
120
|
- lib
|
120
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
122
|
requirements:
|
122
|
-
- -
|
123
|
+
- - ">="
|
123
124
|
- !ruby/object:Gem::Version
|
124
125
|
version: '0'
|
125
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
127
|
requirements:
|
127
|
-
- -
|
128
|
+
- - ">="
|
128
129
|
- !ruby/object:Gem::Version
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
|
-
|
132
|
-
rubygems_version: 2.4.5
|
132
|
+
rubygems_version: 3.1.2
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Interact with the running music player
|
data/.envrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export PATH=bin:$PATH
|
data/Gemfile.lock
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
anyplayer (1.1.5)
|
5
|
-
ruby-mpd (~> 0.3.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: http://rubygems.org/
|
9
|
-
specs:
|
10
|
-
flexmock (1.3.3)
|
11
|
-
minitest (5.4.1)
|
12
|
-
rake (10.3.2)
|
13
|
-
ruby-mpd (0.3.2)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
ruby
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
anyplayer!
|
20
|
-
flexmock
|
21
|
-
minitest
|
22
|
-
rake
|