mplayer-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +59 -0
- data/Rakefile +68 -0
- data/TODO +47 -0
- data/VERSION +1 -0
- data/examples/general_playback.rb +60 -0
- data/lib/mplayer-ruby.rb +6 -0
- data/lib/mplayer-ruby/slave.rb +63 -0
- data/lib/mplayer-ruby/slave_commands.rb +188 -0
- data/lib/mplayer-ruby/slave_video_commands.rb +228 -0
- data/mplayer-ruby.gemspec +75 -0
- data/test.watchr +45 -0
- data/test/mplayer-ruby_test.rb +2 -0
- data/test/slave_commands_test.rb +239 -0
- data/test/slave_test.rb +17 -0
- data/test/slave_video_commands_test.rb +333 -0
- data/test/test.mp3 +0 -0
- data/test/teststrap.rb +16 -0
- metadata +110 -0
@@ -0,0 +1,228 @@
|
|
1
|
+
module MPlayer
|
2
|
+
module SlaveVideoCommands
|
3
|
+
|
4
|
+
# Set/adjust the audio delay.
|
5
|
+
# If type is :relative adjust the delay by <value> seconds.
|
6
|
+
# If type is :absolute, set the delay to <value> seconds.
|
7
|
+
def audio_delay(value,type = :relative)
|
8
|
+
adjust_set :audio_delay, value, type
|
9
|
+
end
|
10
|
+
|
11
|
+
# Adjust the subtitle delay
|
12
|
+
# :relative is adjust by +/- <value> seconds.
|
13
|
+
# :absolute is set it to <value>. (default)
|
14
|
+
def sub_delay(value,type = :absolute)
|
15
|
+
adjust_set :sub_delay, value, type
|
16
|
+
end
|
17
|
+
|
18
|
+
# Step forward in the subtitle list by <value> steps
|
19
|
+
# step backwards if <value> is negative
|
20
|
+
# can also set type to :backward or :forward and return postive <value>
|
21
|
+
def sub_step(value, type = :forward)
|
22
|
+
type = :backward if value < 0
|
23
|
+
send(type == :forward ? "sub_step #{value.abs}" : "sub_step -#{value.abs}" )
|
24
|
+
end
|
25
|
+
|
26
|
+
# Toggle OSD mode
|
27
|
+
# or set it to <level>
|
28
|
+
def osd(level=nil)
|
29
|
+
send(level.nil? ? "osd" : "osd #{level}")
|
30
|
+
end
|
31
|
+
|
32
|
+
# Show <string> on the OSD.
|
33
|
+
# :duration sets the length to display text.
|
34
|
+
# :level sets the osd level to display at. (default: 0 => always show)
|
35
|
+
def osd_show_text(string,options = {})
|
36
|
+
options.reverse_merge!({:duration => 0, :level => 0})
|
37
|
+
send("osd_show_text #{string} #{options[:duration]} #{options[:level]}")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Show an expanded property string on the OSD
|
41
|
+
# see -playing-msg for a list of available expansions
|
42
|
+
# :duration sets the length to display text.
|
43
|
+
# :level sets the osd level to display at. (default: 0 => always show)
|
44
|
+
def osd_show_property_text(string,options={})
|
45
|
+
options.reverse_merge!({:duration => 0, :level => 0})
|
46
|
+
send("osd_show_property_text #{string} #{options[:duration]} #{options[:level]}")
|
47
|
+
end
|
48
|
+
|
49
|
+
# Set/adjust video parameters.
|
50
|
+
# If :relative, modifies parameter by <value>.
|
51
|
+
# If :absolute, parameter is set to <value>.
|
52
|
+
# <value> is in the range [-100, 100].
|
53
|
+
def contrast(value, type = :relative)
|
54
|
+
setting :contrast, value, type
|
55
|
+
end
|
56
|
+
|
57
|
+
# Set/adjust video parameters.
|
58
|
+
# If :relative, modifies parameter by <value>.
|
59
|
+
# If :absolute, parameter is set to <value>.
|
60
|
+
# <value> is in the range [-100, 100].
|
61
|
+
def gamma(value, type = :relative)
|
62
|
+
setting :gamma, value, type
|
63
|
+
end
|
64
|
+
|
65
|
+
# Set/adjust video parameters.
|
66
|
+
# If :relative, modifies parameter by <value>.
|
67
|
+
# If :absolute, parameter is set to <value>.
|
68
|
+
# <value> is in the range [-100, 100].
|
69
|
+
def hue(value, type = :relative)
|
70
|
+
setting :hue, value, type
|
71
|
+
end
|
72
|
+
|
73
|
+
# Set/adjust video parameters.
|
74
|
+
# If :relative, modifies parameter by <value>.
|
75
|
+
# If :absolute, parameter is set to <value>.
|
76
|
+
# <value> is in the range [-100, 100].
|
77
|
+
def brightness(value, type = :relative)
|
78
|
+
setting :brightness, value, type
|
79
|
+
end
|
80
|
+
|
81
|
+
# Set/adjust video parameters.
|
82
|
+
# If :relative, modifies parameter by <value>.
|
83
|
+
# If :absolute, parameter is set to <value>.
|
84
|
+
# <value> is in the range [-100, 100].
|
85
|
+
def saturation(value, type = :relative)
|
86
|
+
setting :saturation, value, type
|
87
|
+
end
|
88
|
+
|
89
|
+
# Toggle/set frame dropping mode
|
90
|
+
# if :on, turns on dropping mode
|
91
|
+
# if :off, turns off dropping mode
|
92
|
+
# call by itself toggles dropping mode
|
93
|
+
def frame_drop(value = nil)
|
94
|
+
toggle :frame_drop, value
|
95
|
+
end
|
96
|
+
|
97
|
+
# Adjust/set subtitle position.
|
98
|
+
# If :relative, modifies parameter by <value>.
|
99
|
+
# If :absolute, parameter is set to <value>.
|
100
|
+
def sub_pos(value,type = :relative)
|
101
|
+
adjust_set :sub_pos, value, type
|
102
|
+
end
|
103
|
+
|
104
|
+
# Toggle/set subtitle alignment. [alignment]
|
105
|
+
# :top sets top alignment
|
106
|
+
# :center sets center alignment
|
107
|
+
# :bottom sets bottom alignment
|
108
|
+
def sub_alignment(alignment = nil)
|
109
|
+
send case alignment
|
110
|
+
when :top then "sub_alignment 0"
|
111
|
+
when :center then "sub_alignment 1"
|
112
|
+
when :bottom then "sub_alignment 2"
|
113
|
+
else "sub_alignment"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Toggle/set subtitle visibility.
|
118
|
+
# :on turns on visilibity.
|
119
|
+
# :off turns off visilibility.
|
120
|
+
# else toggles visibility.
|
121
|
+
def sub_visibility(value = nil)
|
122
|
+
toggle :sub_visibility, value
|
123
|
+
end
|
124
|
+
|
125
|
+
# Loads subtitles from <file>.
|
126
|
+
def sub_load(file)
|
127
|
+
raise ArgumentError, "Invalid File" unless File.exists? file
|
128
|
+
send("sub_load #{file}")
|
129
|
+
end
|
130
|
+
|
131
|
+
# Removes the selected sub file
|
132
|
+
# :all removes all sub files. (Default)
|
133
|
+
# <value> removes the sub file at that index.
|
134
|
+
def sub_remove(value = :all)
|
135
|
+
cmd = (value == :all ? -1 : value)
|
136
|
+
send "sub_remove #{cmd}"
|
137
|
+
end
|
138
|
+
|
139
|
+
# Displays subtitle
|
140
|
+
# :cycle will cycle through all sub_titles. (Default)
|
141
|
+
# <value> will display the sub_title at that index.
|
142
|
+
def sub_select(value = :cycle)
|
143
|
+
cmd = (value == :cycle ? -2 : value)
|
144
|
+
send "sub_select #{cmd}"
|
145
|
+
end
|
146
|
+
|
147
|
+
# Display first subtitle from <value>
|
148
|
+
# :sub for SUB_SOURCE_SUBS for file subs
|
149
|
+
# :vobsub for SUB_SOURCE_VOBSUB for VOBsub files
|
150
|
+
# :demux SUB_SOURCE_DEMUX for subtitle embedded in the media file or DVD subs.
|
151
|
+
# :off will turn off subtitle display.
|
152
|
+
# :cycle will cycle between the first subtitle of each currently available sources.
|
153
|
+
def sub_source(value = :cycle)
|
154
|
+
switch = case value
|
155
|
+
when :sub then 0
|
156
|
+
when :vobsub then 1
|
157
|
+
when :demux then 2
|
158
|
+
when :off then -1
|
159
|
+
when :cycle then -2
|
160
|
+
end
|
161
|
+
send "sub_source #{switch}"
|
162
|
+
end
|
163
|
+
|
164
|
+
# Display subtitle specifid by <value> for file subs. corresponding to ID_FILE_SUB_ID
|
165
|
+
# :off turns off sub
|
166
|
+
# :cycle will cycle all file subs. (Default)
|
167
|
+
def sub_vob(value = :cycle)
|
168
|
+
select_cycle :sub_vob, value
|
169
|
+
end
|
170
|
+
|
171
|
+
# Display subtitle specifid by <value> for file subs. corresponding to ID_VOBSUB_ID
|
172
|
+
# :off turns off sub
|
173
|
+
# :cycle will cycle all file subs. (Default)
|
174
|
+
def sub_file(value = :cycle)
|
175
|
+
select_cycle :sub_file, value
|
176
|
+
end
|
177
|
+
|
178
|
+
# Display subtitle specifid by <value> for file subs. corresponding to ID_SUBTITLE_ID
|
179
|
+
# :off turns off sub
|
180
|
+
# :cycle will cycle all file subs. (Default)
|
181
|
+
def sub_demux(value = :cycle)
|
182
|
+
select_cycle :sub_demux, value
|
183
|
+
end
|
184
|
+
|
185
|
+
# Adjust the subtitle size by +/- <value>
|
186
|
+
# :set set it to <value>
|
187
|
+
# :relative adjusts it by value
|
188
|
+
def sub_scale(value,type = :relative)
|
189
|
+
adjust_set :sub_scale, value, type
|
190
|
+
end
|
191
|
+
|
192
|
+
# switch_audio [value] (currently MPEG*, AVI, Matroska and streams handled by libavformat)
|
193
|
+
# <value> Switch to the audio track with the ID <value>.
|
194
|
+
# :cycle available tracks if [value] is omitted or negative.
|
195
|
+
def switch_audio(value = :cycle)
|
196
|
+
select_cycle :switch_audio, value
|
197
|
+
end
|
198
|
+
# switch_angle [value] (DVDs only)
|
199
|
+
# <value> Switch to the DVD angle with the ID [value].
|
200
|
+
# :cycle available angles if [value] is omitted or negative.
|
201
|
+
def switch_angle(value = :cycle)
|
202
|
+
select_cycle :switch_angle, value
|
203
|
+
end
|
204
|
+
|
205
|
+
# switch_title [value] (DVDNAV only)
|
206
|
+
# <value> Switch to the DVD title with the ID [value].
|
207
|
+
# :cycle available titles if [value] is omitted or negative.
|
208
|
+
def switch_title(value = :cycle)
|
209
|
+
select_cycle :switch_title, value
|
210
|
+
end
|
211
|
+
|
212
|
+
# switch_ratio [value]
|
213
|
+
# <value> Change aspect ratio at runtime. [value] is the new aspect ratio expressed
|
214
|
+
# as a float (e.g. 1.77778 for 16/9).
|
215
|
+
# There might be problems with some video filters.
|
216
|
+
def switch_ratio(value); send("switch_ratio #{value}"); end
|
217
|
+
|
218
|
+
# switch_vsync [value]
|
219
|
+
# :on Toggle vsync on
|
220
|
+
# :off Toggle off
|
221
|
+
# nil for just Toggle
|
222
|
+
def switch_vsync(value = nil)
|
223
|
+
toggle :switch_vsync, value
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
end
|
228
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{mplayer-ruby}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Arthur Chiu"]
|
12
|
+
s.date = %q{2010-02-01}
|
13
|
+
s.description = %q{A Ruby wrapper for MPlayer}
|
14
|
+
s.email = %q{mr.arthur.chiu@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc",
|
18
|
+
"TODO"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
".gitignore",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"TODO",
|
27
|
+
"VERSION",
|
28
|
+
"examples/general_playback.rb",
|
29
|
+
"lib/mplayer-ruby.rb",
|
30
|
+
"lib/mplayer-ruby/slave.rb",
|
31
|
+
"lib/mplayer-ruby/slave_commands.rb",
|
32
|
+
"lib/mplayer-ruby/slave_video_commands.rb",
|
33
|
+
"mplayer-ruby.gemspec",
|
34
|
+
"test.watchr",
|
35
|
+
"test/mplayer-ruby_test.rb",
|
36
|
+
"test/slave_commands_test.rb",
|
37
|
+
"test/slave_test.rb",
|
38
|
+
"test/slave_video_commands_test.rb",
|
39
|
+
"test/test.mp3",
|
40
|
+
"test/teststrap.rb"
|
41
|
+
]
|
42
|
+
s.homepage = %q{http://github.com/achiu/mplayer-ruby}
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = %q{1.3.5}
|
46
|
+
s.summary = %q{Ruby wrapper for MPlayer}
|
47
|
+
s.test_files = [
|
48
|
+
"test/mplayer-ruby_test.rb",
|
49
|
+
"test/slave_commands_test.rb",
|
50
|
+
"test/slave_test.rb",
|
51
|
+
"test/slave_video_commands_test.rb",
|
52
|
+
"test/teststrap.rb",
|
53
|
+
"examples/general_playback.rb"
|
54
|
+
]
|
55
|
+
|
56
|
+
if s.respond_to? :specification_version then
|
57
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
58
|
+
s.specification_version = 3
|
59
|
+
|
60
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
61
|
+
s.add_development_dependency(%q<riot>, [">= 0.10.11"])
|
62
|
+
s.add_development_dependency(%q<rr>, [">= 0.10.5"])
|
63
|
+
s.add_runtime_dependency(%q<open4>, [">= 1.0.1"])
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<riot>, [">= 0.10.11"])
|
66
|
+
s.add_dependency(%q<rr>, [">= 0.10.5"])
|
67
|
+
s.add_dependency(%q<open4>, [">= 1.0.1"])
|
68
|
+
end
|
69
|
+
else
|
70
|
+
s.add_dependency(%q<riot>, [">= 0.10.11"])
|
71
|
+
s.add_dependency(%q<rr>, [">= 0.10.5"])
|
72
|
+
s.add_dependency(%q<open4>, [">= 1.0.1"])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
data/test.watchr
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# 'autotest' for riot
|
3
|
+
# install watchr
|
4
|
+
# $ sudo gem install watchr
|
5
|
+
#
|
6
|
+
# Run With:
|
7
|
+
# $ watchr test.watchr
|
8
|
+
#
|
9
|
+
|
10
|
+
# --------------------------------------------------
|
11
|
+
# Helpers
|
12
|
+
# --------------------------------------------------
|
13
|
+
|
14
|
+
def run(cmd)
|
15
|
+
puts(cmd)
|
16
|
+
system(cmd)
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_all_tests
|
20
|
+
system( "rake test" )
|
21
|
+
end
|
22
|
+
|
23
|
+
def sudo(cmd)
|
24
|
+
run("sudo #{cmd}")
|
25
|
+
end
|
26
|
+
|
27
|
+
# --------------------------------------------------
|
28
|
+
# Watchr Rules
|
29
|
+
# --------------------------------------------------
|
30
|
+
watch("^lib.*/(.*)\.rb") { |m| run("ruby -rubygems test/#{m[1]}_test.rb") }
|
31
|
+
watch("test.*/teststrap\.rb") { run_all_tests }
|
32
|
+
watch('^test.*/(.*)_test\.rb') { |m| run("ruby -rubygems test/#{m[1]}_test.rb") }
|
33
|
+
watch('(.*)\.gemspec') { |m| sudo("rake install") }
|
34
|
+
|
35
|
+
# --------------------------------------------------
|
36
|
+
# Signal Handling
|
37
|
+
# --------------------------------------------------
|
38
|
+
# Ctrl-\
|
39
|
+
Signal.trap('QUIT') do
|
40
|
+
puts " --- Running all tests ---\n\n"
|
41
|
+
run_all_tests
|
42
|
+
end
|
43
|
+
|
44
|
+
# Ctrl-C
|
45
|
+
Signal.trap('INT') { abort("\n") }
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require File.expand_path("teststrap", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
context "MPlayer::Player" do
|
4
|
+
setup do
|
5
|
+
mock(Open4).popen4("/usr/bin/mplayer -slave -quiet test/test.mp3") { [true,true,true,true] }
|
6
|
+
stub(true).gets { "playback" }
|
7
|
+
@player = MPlayer::Slave.new('test/test.mp3')
|
8
|
+
end
|
9
|
+
|
10
|
+
context "pause" do
|
11
|
+
setup { mock_send @player, "pause" }
|
12
|
+
asserts("returns true") { @player.pause }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "quit" do
|
16
|
+
setup do
|
17
|
+
mock_send @player, "quit"
|
18
|
+
mock(@player.stdin).close { true }
|
19
|
+
end
|
20
|
+
asserts("returns true") { @player.quit }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "volume" do
|
24
|
+
|
25
|
+
context "increases" do
|
26
|
+
setup { mock_send @player, "volume 1","Volume: 10 %\n",/Volume/ }
|
27
|
+
asserts("returns true") { @player.volume :up }.equals "10"
|
28
|
+
end
|
29
|
+
|
30
|
+
context "decreases" do
|
31
|
+
setup { mock_send @player, "volume 0","Volume: 10 %\n",/Volume/ }
|
32
|
+
asserts("returns true") { @player.volume :down }.equals "10"
|
33
|
+
end
|
34
|
+
|
35
|
+
context "sets volume" do
|
36
|
+
setup { mock_send @player, "volume 40 1","Volume: 10 %\n",/Volume/ }
|
37
|
+
asserts("returns true") { @player.volume :set,40 }.equals "10"
|
38
|
+
end
|
39
|
+
|
40
|
+
context "incorrect action" do
|
41
|
+
setup { @player.volume :boo }
|
42
|
+
asserts("returns false").equals false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "seek" do
|
47
|
+
|
48
|
+
context "by relative" do
|
49
|
+
setup { mock_send @player, "seek 5 0","Position: 10 %\n",/Position/ }
|
50
|
+
asserts("seek 5") { @player.seek 5 }
|
51
|
+
asserts("seek 5,:relative") { @player.seek 5,:relative }.equals "10"
|
52
|
+
end
|
53
|
+
|
54
|
+
context "by percentage" do
|
55
|
+
setup { mock_send @player, "seek 5 1","Position: 10 %\n",/Position/ }
|
56
|
+
asserts("seek 5,:percent") { @player.seek 5,:percent }.equals "10"
|
57
|
+
end
|
58
|
+
|
59
|
+
context "by absolute" do
|
60
|
+
setup { mock_send @player, "seek 5 2","Position: 10 %\n",/Position/ }
|
61
|
+
asserts("seek 5,:absolute") { @player.seek 5,:absolute }.equals "10"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "edl_mark" do
|
66
|
+
setup { mock_send @player, "edl_mark"}
|
67
|
+
asserts("returns true") { @player.edl_mark }
|
68
|
+
end
|
69
|
+
|
70
|
+
context "speed_incr" do
|
71
|
+
setup { mock_send @player, "speed_incr 5","Speed: x 10",/Speed/ }
|
72
|
+
asserts("speed_incr 5") { @player.speed_incr 5 }.equals "10"
|
73
|
+
end
|
74
|
+
|
75
|
+
context "speed_mult" do
|
76
|
+
setup { mock_send @player, "speed_mult 5","Speed: x 10",/Speed/ }
|
77
|
+
asserts("speed_mult 5") { @player.speed_mult 5 }.equals "10"
|
78
|
+
end
|
79
|
+
|
80
|
+
context "speed_set" do
|
81
|
+
setup { mock_send @player, "speed_set 5","Speed: x 10",/Speed/ }
|
82
|
+
asserts("speed_set 5") { @player.speed_set 5 }.equals "10"
|
83
|
+
end
|
84
|
+
|
85
|
+
context "speed_set speed_mult speed_incr raise error" do
|
86
|
+
asserts("speed_incr 6") { @player.speed_incr 6 }.raises ArgumentError,"Value must be less than 6"
|
87
|
+
asserts("speed_mult 6") { @player.speed_mult 6 }.raises ArgumentError,"Value must be less than 6"
|
88
|
+
asserts("speed_set 6") { @player.speed_set 6 }.raises ArgumentError,"Value must be less than 6"
|
89
|
+
end
|
90
|
+
|
91
|
+
context "speed" do
|
92
|
+
|
93
|
+
context "increment" do
|
94
|
+
setup { mock(@player).speed_incr(5) { true } }
|
95
|
+
asserts("speed 5,:increment") { @player.speed 5,:increment }
|
96
|
+
end
|
97
|
+
|
98
|
+
context "multiply" do
|
99
|
+
setup { mock(@player).speed_mult(5) { true } }
|
100
|
+
asserts("speed 5,:multiply") { @player.speed 5,:multiply }
|
101
|
+
end
|
102
|
+
|
103
|
+
context "set" do
|
104
|
+
setup { mock(@player).speed_set(5) { true } }
|
105
|
+
asserts("speed 5") { @player.speed 5 }
|
106
|
+
asserts("speed 5, :set") { @player.speed 5,:set }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "frame_step" do
|
111
|
+
setup { mock_send @player, "frame_step" }
|
112
|
+
asserts("returns true") { @player.frame_step }
|
113
|
+
end
|
114
|
+
|
115
|
+
context "pt_step" do
|
116
|
+
|
117
|
+
context "forced" do
|
118
|
+
setup { mock_send @player, "pt_step 5 1" }
|
119
|
+
asserts("pt_step 5, :force") { @player.pt_step 5, :force }
|
120
|
+
end
|
121
|
+
|
122
|
+
context "not forced" do
|
123
|
+
setup { mock_send @player, "pt_step 5 0" }
|
124
|
+
asserts("pt_step 5") { @player.pt_step 5 }
|
125
|
+
asserts("pt_step 5, :no_force") { @player.pt_step 5, :no_force }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
context "pt_up_step" do
|
130
|
+
|
131
|
+
context "forced" do
|
132
|
+
setup { mock_send @player, "pt_up_step 5 1"}
|
133
|
+
asserts("pt_up_step 5, :force") { @player.pt_up_step 5, :force }
|
134
|
+
end
|
135
|
+
|
136
|
+
context "not forced" do
|
137
|
+
setup { mock_send @player, "pt_up_step 5 0" }
|
138
|
+
asserts("pt_up_step 5") { @player.pt_up_step 5 }
|
139
|
+
asserts("pt_up_step 5, :no_force") { @player.pt_up_step 5, :no_force }
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
context "alt_src_step" do
|
144
|
+
setup { mock_send @player, "alt_src_step 5" }
|
145
|
+
asserts("returns true") { @player.alt_src_step 5 }
|
146
|
+
end
|
147
|
+
|
148
|
+
context "loop" do
|
149
|
+
|
150
|
+
context "none" do
|
151
|
+
setup { mock_send @player,"loop -1" }
|
152
|
+
asserts("loop :none") { @player.loop :none }
|
153
|
+
end
|
154
|
+
|
155
|
+
context "forever" do
|
156
|
+
setup { mock_send @player, "loop 0" }
|
157
|
+
asserts("loop") { @player.loop }
|
158
|
+
asserts("loop :forever") { @player.loop :forever }
|
159
|
+
end
|
160
|
+
|
161
|
+
context "set value" do
|
162
|
+
setup { mock_send @player,"loop 5" }
|
163
|
+
asserts("loop :set, 5") { @player.loop :set, 5 }
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
context "use_master" do
|
168
|
+
setup { mock_send @player, "use_master" }
|
169
|
+
asserts("returns true") { @player.use_master }
|
170
|
+
end
|
171
|
+
|
172
|
+
context "mute" do
|
173
|
+
|
174
|
+
context "toggle" do
|
175
|
+
setup { mock_send @player, "mute", "Mute: enabled",/Mute/}
|
176
|
+
asserts("returns true") { @player.mute }.equals "enabled"
|
177
|
+
end
|
178
|
+
|
179
|
+
context "set on" do
|
180
|
+
setup { mock_send @player, "mute 1","Mute: enabled",/Mute/}
|
181
|
+
asserts("mute :on") { @player.mute :on }.equals "enabled"
|
182
|
+
end
|
183
|
+
|
184
|
+
context "set off" do
|
185
|
+
setup { mock_send @player, "mute 0","Mute: enabled",/Mute/}
|
186
|
+
asserts("mute :off") { @player.mute :off }.equals "enabled"
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context "get" do
|
191
|
+
|
192
|
+
%w[time_pos time_length file_name video_codec video_bitrate video_resolution
|
193
|
+
audio_codec audio_bitrate audio_samples meta_title meta_artist meta_album
|
194
|
+
meta_year meta_comment meta_track meta_genre].each do |info|
|
195
|
+
context info do
|
196
|
+
resp = case info
|
197
|
+
when "time_pos" then "ANS_TIME_POSITION"
|
198
|
+
when "time_length" then "ANS_LENGTH"
|
199
|
+
when "file_name" then "ANS_FILENAME"
|
200
|
+
else "ANS_#{info.upcase}"
|
201
|
+
end
|
202
|
+
setup { mock_send @player, "get_#{info}","#{resp}='100'",/#{resp}/ }
|
203
|
+
asserts("get :#{info}") { @player.get info.to_sym }
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context "load_file" do
|
209
|
+
|
210
|
+
asserts("invalid file") { @player.load_file 'booger' }.raises ArgumentError,"Invalid File"
|
211
|
+
context "append" do
|
212
|
+
setup { mock_send @player, "loadfile test/test.mp3 1" }
|
213
|
+
asserts("load_file test/test.mp3, :append") { @player.load_file 'test/test.mp3', :append }
|
214
|
+
end
|
215
|
+
|
216
|
+
context "no append" do
|
217
|
+
setup { mock_send @player, "loadfile test/test.mp3 0" }
|
218
|
+
asserts("load_file test/test.mp3") { @player.load_file 'test/test.mp3' }
|
219
|
+
asserts("load_file test/test.mp3, :no_append") { @player.load_file 'test/test.mp3', :no_append }
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "load_list" do
|
224
|
+
|
225
|
+
asserts("invalid playlist") { @player.load_list 'booger' }.raises ArgumentError,"Invalid File"
|
226
|
+
context "append" do
|
227
|
+
setup { mock_send @player, "loadlist test/test.mp3 1" }
|
228
|
+
asserts("load_list test/test.mp3, :append") { @player.load_list 'test/test.mp3', :append }
|
229
|
+
end
|
230
|
+
|
231
|
+
context "no append" do
|
232
|
+
setup { mock_send @player, "loadlist test/test.mp3 0" }
|
233
|
+
asserts("load_list test/test.mp3") { @player.load_list 'test/test.mp3' }
|
234
|
+
asserts("load_list test/test.mp3, :no_append") { @player.load_list 'test/test.mp3', :no_append }
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
end
|