ruby-mpris 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS +5 -0
- data/Rakefile +1 -1
- data/examples/capabilities_test.rb +1 -1
- data/examples/identify.rb +1 -1
- data/examples/metadata.rb +1 -1
- data/examples/play_track.rb +1 -1
- data/examples/playerkeys.rb +1 -1
- data/examples/status_test.rb +4 -4
- data/examples/tracklist.rb +1 -1
- data/examples/volume_test.rb +1 -1
- data/lib/mpris.rb +5 -5
- data/lib/mpris/player.rb +6 -6
- data/lib/mpris/tracklist.rb +15 -6
- metadata +2 -2
data/NEWS
CHANGED
data/Rakefile
CHANGED
data/examples/identify.rb
CHANGED
data/examples/metadata.rb
CHANGED
data/examples/play_track.rb
CHANGED
data/examples/playerkeys.rb
CHANGED
data/examples/status_test.rb
CHANGED
@@ -12,7 +12,7 @@ $:.unshift File.dirname(__FILE__)+'/../lib'
|
|
12
12
|
require 'mpris'
|
13
13
|
|
14
14
|
|
15
|
-
mpris =
|
15
|
+
mpris = MPRIS.new
|
16
16
|
|
17
17
|
|
18
18
|
puts "Enabling looping."
|
@@ -42,16 +42,16 @@ puts " Looping status: #{mpris.player.repeat}"
|
|
42
42
|
|
43
43
|
puts "Stopping playback..."
|
44
44
|
mpris.player.stop
|
45
|
-
puts "
|
45
|
+
puts " MPRIS::Player::STOPPED: #{MPRIS::Player::STOPPED}"
|
46
46
|
puts " Playback status: #{mpris.player.status}"
|
47
47
|
|
48
48
|
puts "Starting playback..."
|
49
49
|
mpris.player.play
|
50
|
-
puts "
|
50
|
+
puts " MPRIS::Player::PLAYING: #{MPRIS::Player::PLAYING}"
|
51
51
|
puts " Playback status: #{mpris.player.status}"
|
52
52
|
|
53
53
|
# Current crashes VLC:
|
54
54
|
#puts "Pausing playback..."
|
55
55
|
#mpris.player.pause
|
56
|
-
#puts "
|
56
|
+
#puts " MPRIS::Player::PAUSED: #{MPRIS::Player::PAUSED}"
|
57
57
|
#puts " Playback status: #{mpris.player.status}"
|
data/examples/tracklist.rb
CHANGED
data/examples/volume_test.rb
CHANGED
data/lib/mpris.rb
CHANGED
@@ -14,14 +14,14 @@ require 'mpris/tracklist'
|
|
14
14
|
|
15
15
|
# This is the base MPRIS class. It creates the #Player and #Tracklist objects
|
16
16
|
# automatically, which are accessible via the attribute readers.
|
17
|
-
class
|
17
|
+
class MPRIS
|
18
18
|
attr_reader :player
|
19
19
|
attr_reader :tracklist
|
20
20
|
|
21
21
|
MPRIS_SERVICE_PREFIX = 'org.mpris'
|
22
22
|
MPRIS_INTERFACE = 'org.freedesktop.MediaPlayer'
|
23
23
|
|
24
|
-
# Create a new
|
24
|
+
# Create a new MPRIS instance.
|
25
25
|
# By default it will return the first MPRIS enabled player found
|
26
26
|
# on the Session Bus.
|
27
27
|
#
|
@@ -71,10 +71,10 @@ class Mpris
|
|
71
71
|
@interface = root_object[MPRIS_INTERFACE]
|
72
72
|
|
73
73
|
# Create the player object
|
74
|
-
@player =
|
74
|
+
@player = MPRIS::Player.new(@service, self)
|
75
75
|
|
76
76
|
# Create a tracklist object
|
77
|
-
@tracklist =
|
77
|
+
@tracklist = MPRIS::TrackList.new(@service, self)
|
78
78
|
end
|
79
79
|
|
80
80
|
# Identify the "media player" as in "VLC 0.9.0", "bmpx 0.34.9", "Audacious 1.4.0" ...
|
@@ -95,7 +95,7 @@ class Mpris
|
|
95
95
|
end
|
96
96
|
|
97
97
|
|
98
|
-
# Exception raised if no
|
98
|
+
# Exception raised if no MPRIS service is found on the D-Bus.
|
99
99
|
class ServiceNotFoundException < Exception
|
100
100
|
end
|
101
101
|
|
data/lib/mpris/player.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
8
|
#
|
9
9
|
|
10
|
-
class
|
10
|
+
class MPRIS
|
11
11
|
|
12
12
|
# This class represents the player itself.
|
13
13
|
class Player
|
@@ -16,7 +16,7 @@ class Mpris
|
|
16
16
|
PAUSED = 1
|
17
17
|
STOPPED = 2
|
18
18
|
|
19
|
-
# A player object should only be created directly by its parent
|
19
|
+
# A player object should only be created directly by its parent MPRIS
|
20
20
|
def initialize( service, parent ) #:nodoc:
|
21
21
|
@service = service
|
22
22
|
@parent = parent
|
@@ -24,11 +24,11 @@ class Mpris
|
|
24
24
|
# Check the service implements the MediaPlayer interface
|
25
25
|
object = @service.object("/Player")
|
26
26
|
object.introspect
|
27
|
-
unless object.has_iface?
|
28
|
-
raise(
|
27
|
+
unless object.has_iface? MPRIS::MPRIS_INTERFACE
|
28
|
+
raise(MPRIS::InterfaceNotImplementedException,
|
29
29
|
"#{service_name} does not implement the MediaPlayer interface on /.")
|
30
30
|
end
|
31
|
-
@interface = object[
|
31
|
+
@interface = object[MPRIS::MPRIS_INTERFACE]
|
32
32
|
end
|
33
33
|
|
34
34
|
|
@@ -79,7 +79,7 @@ class Mpris
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# Return the playing status of "Media Player".
|
82
|
-
#
|
82
|
+
# MPRIS::Player::PLAYING / MPRIS::Player::PAUSED / MPRIS::Player::STOPPED
|
83
83
|
def status
|
84
84
|
return @interface.GetStatus.first[0]
|
85
85
|
end
|
data/lib/mpris/tracklist.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
8
|
#
|
9
9
|
|
10
|
-
class
|
10
|
+
class MPRIS
|
11
11
|
|
12
12
|
# This class represents the Media Player's tracklist.
|
13
13
|
#
|
@@ -18,7 +18,7 @@ class Mpris
|
|
18
18
|
#
|
19
19
|
class TrackList
|
20
20
|
|
21
|
-
# A tracklist object should only be created directly by its parent
|
21
|
+
# A tracklist object should only be created directly by its parent MPRIS
|
22
22
|
def initialize( service, parent ) #:nodoc:
|
23
23
|
@service = service
|
24
24
|
@parent = parent
|
@@ -26,11 +26,11 @@ class Mpris
|
|
26
26
|
# Check the service implements the MediaPlayer interface
|
27
27
|
object = @service.object("/TrackList")
|
28
28
|
object.introspect
|
29
|
-
unless object.has_iface?
|
30
|
-
raise(
|
29
|
+
unless object.has_iface? MPRIS::MPRIS_INTERFACE
|
30
|
+
raise(MPRIS::InterfaceNotImplementedException,
|
31
31
|
"#{service_name} does not implement the MediaPlayer interface on /.")
|
32
32
|
end
|
33
|
-
@interface = object[
|
33
|
+
@interface = object[MPRIS::MPRIS_INTERFACE]
|
34
34
|
end
|
35
35
|
|
36
36
|
# Gives all metadata available for item at given position in the TrackList, counting from 0.
|
@@ -65,7 +65,16 @@ class Mpris
|
|
65
65
|
#
|
66
66
|
# pos is the position in the tracklist of the item to remove.
|
67
67
|
def delete_track(pos)
|
68
|
-
@interface.
|
68
|
+
@interface.DelTrack(pos)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Removes all tracks from the TrackList.
|
72
|
+
def delete_all
|
73
|
+
len = length
|
74
|
+
while(len) do
|
75
|
+
delete_track(0)
|
76
|
+
len -= 1
|
77
|
+
end
|
69
78
|
end
|
70
79
|
|
71
80
|
# Set the tracklist looping status. true to loop, false to stop looping.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-mpris
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas J Humfrey
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
requirements: []
|
70
70
|
|
71
71
|
rubyforge_project: mpris
|
72
|
-
rubygems_version:
|
72
|
+
rubygems_version: 0.9.5
|
73
73
|
signing_key:
|
74
74
|
specification_version: 2
|
75
75
|
summary: A library to control MPRIS based Media Players
|