easy_mplayer 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/easy_mplayer.gemspec +3 -3
- data/lib/easy_mplayer/helpers.rb +5 -0
- data/lib/easy_mplayer/main.rb +36 -7
- data/lib/easy_mplayer/worker.rb +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ begin
|
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "easy_mplayer"
|
8
8
|
gem.summary = "Wrapper to launch and control MPlayer"
|
9
|
-
gem.description = "A wrapper to manage mplayer, that supports callbacks to
|
9
|
+
gem.description = "A wrapper to manage mplayer, that supports callbacks to easily support event-driven GUIs"
|
10
10
|
gem.email = "gem-mplayer@thoughtnoise.net"
|
11
11
|
gem.homepage = "http://github.com/pdkl95/easy_mplayer"
|
12
12
|
gem.authors = ["Brent Sanders"]
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.1.0
|
data/easy_mplayer.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{easy_mplayer}
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brent Sanders"]
|
12
|
-
s.date = %q{2010-01-
|
13
|
-
s.description = %q{A wrapper to manage mplayer, that supports callbacks to
|
12
|
+
s.date = %q{2010-01-09}
|
13
|
+
s.description = %q{A wrapper to manage mplayer, that supports callbacks to easily support event-driven GUIs}
|
14
14
|
s.email = %q{gem-mplayer@thoughtnoise.net}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
data/lib/easy_mplayer/helpers.rb
CHANGED
@@ -9,6 +9,7 @@ class MPlayer
|
|
9
9
|
# spawn the mplayer process, which also starts the media playing. It
|
10
10
|
# is requires that #opts[:path] point to a valid media file
|
11
11
|
def play
|
12
|
+
must_be_ready!
|
12
13
|
stop if running?
|
13
14
|
|
14
15
|
info "PLAY: #{opts[:path]}"
|
@@ -24,6 +25,7 @@ class MPlayer
|
|
24
25
|
|
25
26
|
# pause playback if we are running
|
26
27
|
def pause
|
28
|
+
return unless running?
|
27
29
|
return if paused?
|
28
30
|
info "PAUSE!"
|
29
31
|
send_command :pause
|
@@ -33,6 +35,7 @@ class MPlayer
|
|
33
35
|
|
34
36
|
# opposite of #pause
|
35
37
|
def unpause
|
38
|
+
return unless running?
|
36
39
|
return unless paused?
|
37
40
|
info "UNPAUSE!"
|
38
41
|
send_command :pause
|
@@ -60,6 +63,7 @@ class MPlayer
|
|
60
63
|
# seek to an absolute position in a file, by seconds. requires a
|
61
64
|
# float between 0.0 and the length (in seconds) of the file being played.
|
62
65
|
def seek_to_time(seconds)
|
66
|
+
return unless running?
|
63
67
|
info "SEEK TO: #{seconds} seconds"
|
64
68
|
send_command :seek, seconds, 1
|
65
69
|
end
|
@@ -67,6 +71,7 @@ class MPlayer
|
|
67
71
|
# seek by a relative amount, in seconds. requires a float. Negative
|
68
72
|
# values rewind to a previous point.
|
69
73
|
def seek_by(amount)
|
74
|
+
return unless running?
|
70
75
|
info "SEEK BY: #{amount}"
|
71
76
|
send_command :seek, amount, 0
|
72
77
|
end
|
data/lib/easy_mplayer/main.rb
CHANGED
@@ -49,9 +49,21 @@ class MPlayer
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
# create a new object
|
53
|
-
# :
|
54
|
-
#
|
52
|
+
# create a new object, with the named options
|
53
|
+
# valid options:
|
54
|
+
# :program Path to the mplayer binary itself
|
55
|
+
# (default: /usr/bin/mplayer)
|
56
|
+
# :path Path to the media file to be played
|
57
|
+
# :message_style How verbose our debug messages should
|
58
|
+
# be (see #set_message_style)
|
59
|
+
# :seek_size Time, in seconds, to seek
|
60
|
+
# forwards/reverse by default (default:
|
61
|
+
# 10 seconds)
|
62
|
+
# :select_wait_time Time, in seconds, for blocking on
|
63
|
+
# IO.select in the worker threads (default: 1)
|
64
|
+
# :thread_safe_callbacks If we should buffer callbacks back to
|
65
|
+
# the main thread, so they are called off
|
66
|
+
# the #playing? polling-loop (default: true)
|
55
67
|
def initialize(new_opts=Hash.new)
|
56
68
|
@opts = DEFAULT_OPTS.merge(new_opts)
|
57
69
|
set_message_style opts[:message_style]
|
@@ -59,9 +71,6 @@ class MPlayer
|
|
59
71
|
unless File.executable?(@opts[:program])
|
60
72
|
raise NoPlayerFound.new(@opts[:program])
|
61
73
|
end
|
62
|
-
unless @opts[:path] and File.readable?(new_opts[:path])
|
63
|
-
raise NoTargetPath.new(@opts[:path])
|
64
|
-
end
|
65
74
|
|
66
75
|
@stats = Hash.new
|
67
76
|
@callbacks = Hash.new
|
@@ -100,6 +109,26 @@ class MPlayer
|
|
100
109
|
@worker = nil
|
101
110
|
callback! :stop
|
102
111
|
end
|
112
|
+
|
113
|
+
# true if we can call #play without an exception
|
114
|
+
def ready?
|
115
|
+
@opts[:path] and File.readable?(@opts[:path])
|
116
|
+
end
|
117
|
+
|
118
|
+
def must_be_ready! # :nodoc:
|
119
|
+
ready? or raise NoTargetPath.new(@opts[:path])
|
120
|
+
end
|
121
|
+
|
122
|
+
# returns the path we are currently playing
|
123
|
+
def path
|
124
|
+
@opts[:path]
|
125
|
+
end
|
126
|
+
|
127
|
+
# sets the path to #play - this does not interrupt a currently
|
128
|
+
# playing file. #stop and #play should be called again.
|
129
|
+
def path=(val)
|
130
|
+
@opts[:path] = val
|
131
|
+
end
|
103
132
|
|
104
133
|
# can be any of:
|
105
134
|
# :quiet Supperss all output!
|
@@ -172,7 +201,7 @@ class MPlayer
|
|
172
201
|
def update_stat(name, newval) # :nodoc:
|
173
202
|
name = name.to_sym
|
174
203
|
if @stats[name] != newval
|
175
|
-
debug "STATS[:#{name}] -> #{newval.inspect}"
|
204
|
+
debug "STATS[:#{name}] #{@stats[name].inspect} -> #{newval.inspect}"
|
176
205
|
@stats[name] = newval
|
177
206
|
callback! name, newval
|
178
207
|
end
|
data/lib/easy_mplayer/worker.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_mplayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Sanders
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-09 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.8.0
|
34
34
|
version:
|
35
|
-
description: A wrapper to manage mplayer, that supports callbacks to
|
35
|
+
description: A wrapper to manage mplayer, that supports callbacks to easily support event-driven GUIs
|
36
36
|
email: gem-mplayer@thoughtnoise.net
|
37
37
|
executables: []
|
38
38
|
|