anyplayer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/{Readme.markdown → README.md} +5 -2
- data/bin/anyplayer +2 -41
- data/lib/anyplayer.rb +1 -2
- data/lib/anyplayer/command_line.rb +53 -0
- data/lib/anyplayer/players/itunes_mac.rb +8 -0
- data/lib/anyplayer/players/spotify_mac.rb +61 -0
- data/lib/anyplayer/selector.rb +2 -0
- data/lib/anyplayer/version.rb +1 -1
- data/test/anyplayer_test.rb +1 -8
- metadata +7 -5
data/Gemfile.lock
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
Anyplayer
|
2
2
|
=========
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/anyplayer.png)](http://badge.fury.io/rb/anyplayer)
|
5
|
+
[![Build Status](https://travis-ci.org/sunny/anyplayer.png)](https://travis-ci.org/sunny/anyplayer)
|
6
|
+
|
7
|
+
Interacts with the currently running music player. Supports iTunes Mac, iTunes Windows, MPD,
|
8
|
+
Rythmbox, Spotify Mac and XMMS2.
|
6
9
|
|
7
10
|
Install
|
8
11
|
-------
|
data/bin/anyplayer
CHANGED
@@ -1,44 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "anyplayer/command_line"
|
4
4
|
|
5
|
-
|
6
|
-
selector = Anyplayer::Selector.new
|
7
|
-
if ARGV.first == "-v"
|
8
|
-
selector.verbose = true
|
9
|
-
ARGV.pop
|
10
|
-
end
|
11
|
-
|
12
|
-
# Find the current player
|
13
|
-
player = selector.player
|
14
|
-
abort "Error: no player connected.\n" + selector.errors.join("\n") if !player
|
15
|
-
|
16
|
-
# Call it
|
17
|
-
case ARGV.first
|
18
|
-
when "playpause" then player.playpause
|
19
|
-
when "play" then player.play
|
20
|
-
when "pause" then palyer.pause
|
21
|
-
when "next" then player.next
|
22
|
-
when "prev" then player.next
|
23
|
-
when "voldown" then player.voldown
|
24
|
-
when "volup" then player.volup
|
25
|
-
when "volume" then puts player.volume
|
26
|
-
when "track" then puts player.track
|
27
|
-
when "artist" then puts player.artist
|
28
|
-
when "album" then puts player.album
|
29
|
-
when "vote" then player.vote
|
30
|
-
when "name" then puts player.name
|
31
|
-
when "launched" then exit(player.launched? ? 0 : 1)
|
32
|
-
when "playing" then exit(player.playing? ? 0 : 1)
|
33
|
-
when "paused" then exit(player.playing? ? 0 : 1)
|
34
|
-
else
|
35
|
-
puts <<USAGE
|
36
|
-
Usage: #{$0} [-v] [command]
|
37
|
-
|
38
|
-
Where command is one of: playpause, play, pause, next, prev, voldown, volup,
|
39
|
-
volume, track, artist, album, vote, name, launched.
|
40
|
-
|
41
|
-
Player connected: #{player.name}.
|
42
|
-
USAGE
|
43
|
-
exit(1)
|
44
|
-
end
|
5
|
+
Anyplayer::CommandLine.parse(ARGV)
|
data/lib/anyplayer.rb
CHANGED
@@ -12,12 +12,11 @@ module Anyplayer
|
|
12
12
|
)
|
13
13
|
|
14
14
|
def self.launched
|
15
|
-
$stderr.puts "Anyplayer.launched is deprecated: please initialize a new Selector and call player"
|
16
15
|
Selector.new.player
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
19
|
require "anyplayer/player"
|
21
20
|
require "anyplayer/selector"
|
22
|
-
|
21
|
+
require "anyplayer/version"
|
23
22
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
require "anyplayer"
|
3
|
+
|
4
|
+
module Anyplayer::CommandLine
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def parse(argv)
|
8
|
+
# Create a selector
|
9
|
+
selector = Anyplayer::Selector.new
|
10
|
+
if argv.first == "-v"
|
11
|
+
selector.verbose = true
|
12
|
+
argv.pop
|
13
|
+
|
14
|
+
$stderr.puts "anyplayer v#{Anyplayer::VERSION}"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Find the current player
|
18
|
+
player = selector.player
|
19
|
+
abort "Error: no player connected.\n" + selector.errors.join("\n") if !player
|
20
|
+
|
21
|
+
# Call it
|
22
|
+
case argv.first
|
23
|
+
when "playpause" then player.playpause
|
24
|
+
when "play" then player.play
|
25
|
+
when "pause" then player.pause
|
26
|
+
when "next" then player.next
|
27
|
+
when "prev" then player.next
|
28
|
+
when "voldown" then player.voldown
|
29
|
+
when "volup" then player.volup
|
30
|
+
when "volume" then puts player.volume
|
31
|
+
when "track" then puts player.track
|
32
|
+
when "artist" then puts player.artist
|
33
|
+
when "album" then puts player.album
|
34
|
+
when "vote" then player.vote
|
35
|
+
when "name" then puts player.name
|
36
|
+
when "launched" then exit(player.launched? ? 0 : 1)
|
37
|
+
when "playing" then exit(player.playing? ? 0 : 1)
|
38
|
+
when "paused" then exit(player.playing? ? 0 : 1)
|
39
|
+
else
|
40
|
+
puts <<USAGE
|
41
|
+
Usage: anyplayer [-v] [command]
|
42
|
+
|
43
|
+
Where command is one of: playpause, play, pause, next, prev, voldown, volup,
|
44
|
+
volume, track, artist, album, vote, name, launched.
|
45
|
+
|
46
|
+
Player connected: #{player.name}.
|
47
|
+
USAGE
|
48
|
+
exit(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Anyplayer::SpotifyMac < Anyplayer::Player
|
2
|
+
def play
|
3
|
+
spotify 'play'
|
4
|
+
end
|
5
|
+
|
6
|
+
def pause
|
7
|
+
spotify 'pause'
|
8
|
+
end
|
9
|
+
|
10
|
+
def playpause
|
11
|
+
spotify 'playpause'
|
12
|
+
end
|
13
|
+
|
14
|
+
def prev
|
15
|
+
spotify 'previous track'
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def next
|
20
|
+
spotify 'next track'
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def voldown
|
25
|
+
spotify 'set sound volume to sound volume - 10'
|
26
|
+
end
|
27
|
+
|
28
|
+
def volup
|
29
|
+
spotify 'set sound volume to sound volume + 10'
|
30
|
+
end
|
31
|
+
|
32
|
+
def volume
|
33
|
+
spotify 'return sound volume'
|
34
|
+
end
|
35
|
+
|
36
|
+
def track
|
37
|
+
spotify 'return name of current track'
|
38
|
+
end
|
39
|
+
|
40
|
+
def artist
|
41
|
+
spotify 'return artist of current track'
|
42
|
+
end
|
43
|
+
|
44
|
+
def album
|
45
|
+
spotify 'return album of current track'
|
46
|
+
end
|
47
|
+
|
48
|
+
def launched?
|
49
|
+
nb = %x(osascript -e 'tell app "System Events" to count (every process whose name is "Spotify")' 2>/dev/null).rstrip
|
50
|
+
nb.match(/^\d+/) and nb.to_i > 0 ? true : false
|
51
|
+
end
|
52
|
+
|
53
|
+
def name
|
54
|
+
"Spotify Mac"
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def spotify(command)
|
59
|
+
%x(osascript -e 'tell app "spotify" to #{command}').rstrip
|
60
|
+
end
|
61
|
+
end
|
data/lib/anyplayer/selector.rb
CHANGED
data/lib/anyplayer/version.rb
CHANGED
data/test/anyplayer_test.rb
CHANGED
@@ -1,14 +1,7 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
class AnyplayerTest < MiniTest::Unit::TestCase
|
4
|
-
def
|
5
|
-
assert_output nil, "Anyplayer.launched is deprecated: please initialize a new Selector and call player\n" do
|
6
|
-
deprecated_player = Anyplayer::launched
|
7
|
-
assert_kind_of Player, deprecated_player
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# def test_loading_all_players
|
4
|
+
# def test_loading_all_players_does_not_explode
|
12
5
|
# PLAYERS.each do |player|
|
13
6
|
# require "anyplayer/players/#{player}"
|
14
7
|
# end
|
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: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
@@ -57,11 +57,12 @@ files:
|
|
57
57
|
- .travis.yml
|
58
58
|
- Gemfile
|
59
59
|
- Gemfile.lock
|
60
|
+
- README.md
|
60
61
|
- Rakefile
|
61
|
-
- Readme.markdown
|
62
62
|
- anyplayer.gemspec
|
63
63
|
- bin/anyplayer
|
64
64
|
- lib/anyplayer.rb
|
65
|
+
- lib/anyplayer/command_line.rb
|
65
66
|
- lib/anyplayer/player.rb
|
66
67
|
- lib/anyplayer/players/amarok.rb
|
67
68
|
- lib/anyplayer/players/itunes_mac.rb
|
@@ -69,6 +70,7 @@ files:
|
|
69
70
|
- lib/anyplayer/players/mpd.rb
|
70
71
|
- lib/anyplayer/players/noplayer.rb
|
71
72
|
- lib/anyplayer/players/rhythmbox.rb
|
73
|
+
- lib/anyplayer/players/spotify_mac.rb
|
72
74
|
- lib/anyplayer/players/xmms2.rb
|
73
75
|
- lib/anyplayer/selector.rb
|
74
76
|
- lib/anyplayer/version.rb
|
@@ -90,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
92
|
version: '0'
|
91
93
|
segments:
|
92
94
|
- 0
|
93
|
-
hash:
|
95
|
+
hash: 1339688103094380844
|
94
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
97
|
none: false
|
96
98
|
requirements:
|
@@ -99,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
101
|
version: '0'
|
100
102
|
segments:
|
101
103
|
- 0
|
102
|
-
hash:
|
104
|
+
hash: 1339688103094380844
|
103
105
|
requirements: []
|
104
106
|
rubyforge_project:
|
105
107
|
rubygems_version: 1.8.23
|