mvlc 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +46 -1
- data/lib/mvlc.rb +1 -1
- data/lib/mvlc/context.rb +11 -12
- data/lib/mvlc/instructions/player.rb +3 -3
- data/lib/mvlc/player/state.rb +18 -17
- data/lib/mvlc/player/wrapper.rb +71 -14
- metadata +2 -13
- data/test/context_test.rb +0 -65
- data/test/helper.rb +0 -6
- data/test/helper/numbers_test.rb +0 -57
- data/test/instructions/midi_test.rb +0 -78
- data/test/instructions/player_test.rb +0 -66
- data/test/media/1.mov +0 -0
- data/test/media/2.mov +0 -0
- data/test/media/3.mov +0 -0
- data/test/midi/message_handler_test.rb +0 -315
- data/test/midi/wrapper_test.rb +0 -229
- data/test/player/wrapper_test.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f27439f0f528cbacaa62a77d0b6365b218405f6
|
4
|
+
data.tar.gz: 23421cc936761e6786c93c6b8566b24b87f72537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c609cda1b7f4d7e9f2187bf9f12270c09486b73ce2d9e257bd47ff577471720a9e63e851825065dcbd78c85937b6716860f1bbd8df7e421ab6933121b40234ef
|
7
|
+
data.tar.gz: 8f78ea1cff61ea2d0c6b8e8ca38a111b7f596ea22f9655c0b9e2367721de0303f42c6d53069c274227077d3beaebc0ae46ac0cdca160a6be286da74027a9186a
|
data/README.md
CHANGED
@@ -2,7 +2,52 @@
|
|
2
2
|
|
3
3
|
Control [VLC Media Player](https://en.wikipedia.org/wiki/VLC_media_player) with MIDI
|
4
4
|
|
5
|
-
This is a fork of [mmplayer](https://github.com/arirusso/mvlc), a gem to control MPlayer with MIDI
|
5
|
+
*This is a fork of [mmplayer](https://github.com/arirusso/mvlc), a gem to control MPlayer with MIDI*
|
6
|
+
|
7
|
+
Enabling VLC to be controlled by MIDI opens up a host of possibilities for live video performance, media automation and more
|
8
|
+
|
9
|
+
This project provides a Ruby DSL to define realtime interactions between MIDI input and VLC
|
10
|
+
|
11
|
+
## Install
|
12
|
+
|
13
|
+
You'll need to install VLC before using this. More information about that is available on [the VLC website](http://www.videolan.org/vlc/index.html)
|
14
|
+
|
15
|
+
This project itself can be installed as a Ruby Gem using
|
16
|
+
|
17
|
+
`gem install mvlc`
|
18
|
+
|
19
|
+
Or if you're using Bundler, add this to your Gemfile
|
20
|
+
|
21
|
+
`gem "mvlc"`
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "mvlc"
|
27
|
+
|
28
|
+
@input = UniMIDI::Input.gets
|
29
|
+
|
30
|
+
@player = MVLC.new(@input) do
|
31
|
+
|
32
|
+
rx_channel 0
|
33
|
+
|
34
|
+
system(:start) { play("1.mov") }
|
35
|
+
|
36
|
+
note(1) { play("2.mov") }
|
37
|
+
note("C2") { play("3.mov") }
|
38
|
+
|
39
|
+
cc(1) { |value| set_volume(value) }
|
40
|
+
cc(20) { |value| seek_percent(to_percent(value)) }
|
41
|
+
|
42
|
+
eof { puts "finished" }
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
@player.start
|
47
|
+
|
48
|
+
```
|
49
|
+
|
50
|
+
An annotated breakdown of this example can be found [here](https://github.com/arirusso/mvlc/blob/master/examples/simple.rb)
|
6
51
|
|
7
52
|
## License
|
8
53
|
|
data/lib/mvlc.rb
CHANGED
data/lib/mvlc/context.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
module MVLC
|
2
2
|
|
3
|
-
# DSL context for interfacing an
|
3
|
+
# DSL context for interfacing an video player instance with MIDI
|
4
4
|
class Context
|
5
5
|
|
6
6
|
include Helper::Numbers
|
7
7
|
include Instructions::MIDI
|
8
8
|
include Instructions::Player
|
9
9
|
|
10
|
-
attr_reader :midi, :player
|
10
|
+
attr_reader :midi, :playback_thread, :player
|
11
11
|
|
12
12
|
# @param [UniMIDI::Input, Array<UniMIDI::Input>] midi_input
|
13
13
|
# @param [Hash] options
|
14
14
|
# @option options [Integer] :midi_buffer_length Length of MIDI message buffer in seconds
|
15
|
-
# @option options [String] :mplayer_flags The command-line flags to invoke MPlayer with
|
16
15
|
# @option options [Integer] :receive_channel (also: :rx_channel) A MIDI channel to subscribe to. By default, responds to all
|
17
16
|
# @yield
|
18
17
|
def initialize(midi_input, options = {}, &block)
|
@@ -21,19 +20,20 @@ module MVLC
|
|
21
20
|
:receive_channel => options[:receive_channel] || options[:rx_channel]
|
22
21
|
}
|
23
22
|
@midi = MIDI.new(midi_input, midi_options)
|
24
|
-
@player = Player.new
|
23
|
+
@player = Player.new
|
25
24
|
instance_eval(&block) if block_given?
|
26
25
|
end
|
27
26
|
|
28
|
-
# Start listening for MIDI
|
29
|
-
# Note that MPlayer will start when Context#play (aka Instructions::Player#play) is called
|
27
|
+
# Start listening for MIDI, start video player
|
30
28
|
# @param [Hash] options
|
31
29
|
# @option options [Boolean] :background Whether to run in a background thread
|
32
30
|
# @return [Boolean]
|
33
31
|
def start(options = {})
|
34
32
|
@midi.start
|
35
33
|
begin
|
36
|
-
@playback_thread =
|
34
|
+
@playback_thread = ::MVLC::Thread.new(:timeout => false) do
|
35
|
+
playback_loop
|
36
|
+
end
|
37
37
|
@playback_thread.join unless !!options[:background]
|
38
38
|
rescue SystemExit, Interrupt
|
39
39
|
stop
|
@@ -54,12 +54,11 @@ module MVLC
|
|
54
54
|
|
55
55
|
# Main playback loop
|
56
56
|
def playback_loop
|
57
|
-
|
58
|
-
|
59
|
-
sleep(0.1)
|
60
|
-
end
|
61
|
-
@player.playback_loop
|
57
|
+
until @player.active?
|
58
|
+
sleep(0.1)
|
62
59
|
end
|
60
|
+
@player.playback_loop
|
61
|
+
true
|
63
62
|
end
|
64
63
|
|
65
64
|
end
|
@@ -2,7 +2,7 @@ module MVLC
|
|
2
2
|
|
3
3
|
module Instructions
|
4
4
|
|
5
|
-
# Instructions dealing with the
|
5
|
+
# Instructions dealing with the video player
|
6
6
|
module Player
|
7
7
|
|
8
8
|
# Assign a callback for updating progress
|
@@ -30,7 +30,7 @@ module MVLC
|
|
30
30
|
base.send(:def_delegators, :@player, :active?, :play)
|
31
31
|
end
|
32
32
|
|
33
|
-
# Add all of the
|
33
|
+
# Add all of the video player methods to the context as instructions
|
34
34
|
def method_missing(method, *args, &block)
|
35
35
|
if @player.respond_to?(method)
|
36
36
|
@player.send(method, *args, &block)
|
@@ -39,7 +39,7 @@ module MVLC
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
# Add all of the
|
42
|
+
# Add all of the video player methods to the context as instructions
|
43
43
|
def respond_to_missing?(method, include_private = false)
|
44
44
|
super || @player.respond_to?(method)
|
45
45
|
end
|
data/lib/mvlc/player/state.rb
CHANGED
@@ -4,39 +4,40 @@ module MVLC
|
|
4
4
|
|
5
5
|
class State
|
6
6
|
|
7
|
-
attr_accessor :
|
8
|
-
alias_method :eof?, :
|
9
|
-
alias_method :pause?, :
|
10
|
-
alias_method :paused?, :
|
11
|
-
alias_method :play?, :
|
12
|
-
alias_method :playing?, :
|
7
|
+
attr_accessor :is_eof, :is_paused, :is_playing, :volume
|
8
|
+
alias_method :eof?, :is_eof
|
9
|
+
alias_method :pause?, :is_paused
|
10
|
+
alias_method :paused?, :is_paused
|
11
|
+
alias_method :play?, :is_playing
|
12
|
+
alias_method :playing?, :is_playing
|
13
13
|
|
14
14
|
def initialize
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
15
|
+
@is_eof = false
|
16
|
+
@is_playing = false
|
17
|
+
@is_paused = false
|
18
|
+
@volume = nil
|
18
19
|
end
|
19
20
|
|
20
21
|
def toggle_pause
|
21
|
-
@
|
22
|
+
@is_paused = !@is_paused
|
22
23
|
end
|
23
24
|
|
24
25
|
def progressing?
|
25
|
-
@
|
26
|
+
@is_playing && !@is_paused
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
-
@
|
29
|
+
def eof_possible?
|
30
|
+
@is_playing && !@is_paused && !@is_eof
|
30
31
|
end
|
31
32
|
|
32
33
|
def handle_eof
|
33
|
-
@
|
34
|
-
@
|
34
|
+
@is_eof = true
|
35
|
+
@is_playing = false
|
35
36
|
end
|
36
37
|
|
37
38
|
def handle_start
|
38
|
-
@
|
39
|
-
@
|
39
|
+
@is_playing = true
|
40
|
+
@is_eof = false
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
data/lib/mvlc/player/wrapper.rb
CHANGED
@@ -2,10 +2,10 @@ module MVLC
|
|
2
2
|
|
3
3
|
module Player
|
4
4
|
|
5
|
-
# Wrapper for
|
5
|
+
# Wrapper for video player functionality
|
6
6
|
class Wrapper
|
7
7
|
|
8
|
-
VOLUME_FACTOR = 2.4
|
8
|
+
VOLUME_FACTOR = 2.4 # Factor at which volume value is scaled
|
9
9
|
|
10
10
|
extend Forwardable
|
11
11
|
|
@@ -15,13 +15,25 @@ module MVLC
|
|
15
15
|
def initialize(options = {})
|
16
16
|
@callback = {}
|
17
17
|
@state = State.new
|
18
|
-
@player =
|
18
|
+
@player = initialize_player
|
19
|
+
@pid = player_pid
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
# Set the volume level to the given value.
|
23
|
+
# Value is expected to be 0..100 but this is not strictly enforced
|
24
|
+
# @param [Integer] value
|
25
|
+
# @return [Integer]
|
26
|
+
def volume=(value)
|
27
|
+
@state.volume = value * VOLUME_FACTOR
|
28
|
+
@player.volume(@state.volume)
|
29
|
+
@state.volume
|
23
30
|
end
|
31
|
+
alias_method :set_volume, :volume=
|
24
32
|
|
33
|
+
# Seek to the given percent in the currently playing file
|
34
|
+
# Value is expected to be 0..100
|
35
|
+
# @param [Integer] value
|
36
|
+
# @return [Integer]
|
25
37
|
def seek_percent(percent)
|
26
38
|
begin
|
27
39
|
length_in_seconds = @player.length
|
@@ -44,7 +56,7 @@ module MVLC
|
|
44
56
|
end
|
45
57
|
end
|
46
58
|
|
47
|
-
# Is
|
59
|
+
# Is the video player active?
|
48
60
|
# @return [Boolean]
|
49
61
|
def active?
|
50
62
|
!@player.nil?
|
@@ -62,8 +74,7 @@ module MVLC
|
|
62
74
|
# @return [Boolean]
|
63
75
|
def playback_loop
|
64
76
|
loop do
|
65
|
-
|
66
|
-
handle_progress if handle_progress?
|
77
|
+
handle_playback_events
|
67
78
|
sleep(0.05)
|
68
79
|
end
|
69
80
|
true
|
@@ -85,14 +96,14 @@ module MVLC
|
|
85
96
|
true
|
86
97
|
end
|
87
98
|
|
88
|
-
#
|
99
|
+
# Exit the video player
|
89
100
|
# @return [Boolean]
|
90
101
|
def quit
|
91
|
-
|
102
|
+
kill_player
|
92
103
|
true
|
93
104
|
end
|
94
105
|
|
95
|
-
# Add all of the
|
106
|
+
# Add all of the video player methods to the wrapper as instructions
|
96
107
|
def method_missing(method, *args, &block)
|
97
108
|
if @player.respond_to?(method)
|
98
109
|
@player.send(method, *args, &block)
|
@@ -101,35 +112,77 @@ module MVLC
|
|
101
112
|
end
|
102
113
|
end
|
103
114
|
|
104
|
-
# Add all of the
|
115
|
+
# Add all of the video player methods to the wrapper as instructions
|
105
116
|
def respond_to_missing?(method, include_private = false)
|
106
117
|
super || @player.respond_to?(method)
|
107
118
|
end
|
108
119
|
|
109
120
|
private
|
110
121
|
|
122
|
+
# Fire playback event callbacks when appropriate during
|
123
|
+
# the playback loop
|
124
|
+
# @return [Boolean]
|
125
|
+
def handle_playback_events
|
126
|
+
handle_eof if handle_eof?
|
127
|
+
handle_progress if handle_progress?
|
128
|
+
true
|
129
|
+
end
|
130
|
+
|
131
|
+
# Instantiate the VLC player instance
|
132
|
+
# @return [VLC::System]
|
133
|
+
def initialize_player
|
134
|
+
VLC::System.new(headless: true)
|
135
|
+
end
|
136
|
+
|
137
|
+
# The OS PID of the player
|
138
|
+
# @return [Integer]
|
139
|
+
def player_pid
|
140
|
+
@player.server.instance_variable_get("@pid")
|
141
|
+
end
|
142
|
+
|
143
|
+
# Kill the VLC player instance
|
144
|
+
# @return [Boolean]
|
145
|
+
def kill_player
|
146
|
+
@player.connection.write("quit")
|
147
|
+
# TODO: Process.kill not working here
|
148
|
+
`kill -9 #{@pid}`
|
149
|
+
@player.server.stop
|
150
|
+
true
|
151
|
+
end
|
152
|
+
|
153
|
+
# Should a progress callback be fired?
|
154
|
+
# @return [Boolean]
|
111
155
|
def handle_progress?
|
112
156
|
@state.progressing? && progress_callback?
|
113
157
|
end
|
114
158
|
|
159
|
+
# Has a progress callback been specified?
|
160
|
+
# @return [Boolean]
|
115
161
|
def progress_callback?
|
116
162
|
!@callback[:progress].nil?
|
117
163
|
end
|
118
164
|
|
165
|
+
# Has an EOF callback been specified?
|
166
|
+
# @return [Boolean]
|
119
167
|
def eof_callback?
|
120
168
|
!@callback[:end_of_file].nil?
|
121
169
|
end
|
122
170
|
|
171
|
+
# Should an EOF callback be fired?
|
172
|
+
# @return [Boolean]
|
123
173
|
def handle_eof?
|
124
174
|
eof? && eof_callback?
|
125
175
|
end
|
126
176
|
|
177
|
+
# Fire the progress callback. Used during the playback loop
|
178
|
+
# @return [Boolean]
|
127
179
|
def handle_progress
|
128
|
-
@callback[:progress].call
|
180
|
+
@callback[:progress].call(@player.progress)
|
129
181
|
true
|
130
182
|
end
|
131
183
|
|
132
184
|
# Handle the end of playback for a single media file
|
185
|
+
# @return [Boolean]
|
133
186
|
def handle_eof
|
134
187
|
@callback[:end_of_file].call
|
135
188
|
@state.handle_eof
|
@@ -137,10 +190,14 @@ module MVLC
|
|
137
190
|
end
|
138
191
|
|
139
192
|
# Handle the beginning of playback for a single media file
|
193
|
+
# @return [Boolean]
|
140
194
|
def handle_start
|
141
195
|
@state.handle_start
|
196
|
+
true
|
142
197
|
end
|
143
198
|
|
199
|
+
# Is media playing?
|
200
|
+
# @return [Boolean]
|
144
201
|
def playing?
|
145
202
|
begin
|
146
203
|
@player.playing?
|
@@ -152,7 +209,7 @@ module MVLC
|
|
152
209
|
# Has the end of a media file been reached?
|
153
210
|
# @return [Boolean]
|
154
211
|
def eof?
|
155
|
-
@state.
|
212
|
+
@state.eof_possible? && !playing?
|
156
213
|
end
|
157
214
|
|
158
215
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvlc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -212,17 +212,6 @@ files:
|
|
212
212
|
- lib/mvlc/player/state.rb
|
213
213
|
- lib/mvlc/player/wrapper.rb
|
214
214
|
- lib/mvlc/thread.rb
|
215
|
-
- test/context_test.rb
|
216
|
-
- test/helper.rb
|
217
|
-
- test/helper/numbers_test.rb
|
218
|
-
- test/instructions/midi_test.rb
|
219
|
-
- test/instructions/player_test.rb
|
220
|
-
- test/media/1.mov
|
221
|
-
- test/media/2.mov
|
222
|
-
- test/media/3.mov
|
223
|
-
- test/midi/message_handler_test.rb
|
224
|
-
- test/midi/wrapper_test.rb
|
225
|
-
- test/player/wrapper_test.rb
|
226
215
|
homepage: http://github.com/arirusso/mvlc
|
227
216
|
licenses:
|
228
217
|
- Apache-2.0
|
data/test/context_test.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::ContextTest < Minitest::Test
|
4
|
-
|
5
|
-
context "Context" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
VLC::System.stubs(:new)
|
9
|
-
@input = Object.new
|
10
|
-
@context = MVLC::Context.new(@input)
|
11
|
-
@player = Object.new
|
12
|
-
@context.player.stubs(:player).returns(@player)
|
13
|
-
@context.player.stubs(:quit).returns(true)
|
14
|
-
@context.player.stubs(:active?).returns(true)
|
15
|
-
end
|
16
|
-
|
17
|
-
teardown do
|
18
|
-
@context.player.unstub(:player)
|
19
|
-
@context.player.unstub(:quit)
|
20
|
-
@context.player.unstub(:active?)
|
21
|
-
end
|
22
|
-
|
23
|
-
context "#start" do
|
24
|
-
|
25
|
-
setup do
|
26
|
-
@context.midi.listener.expects(:on_message).once
|
27
|
-
@context.midi.listener.expects(:start).once
|
28
|
-
end
|
29
|
-
|
30
|
-
teardown do
|
31
|
-
@context.midi.listener.unstub(:on_message)
|
32
|
-
@context.midi.listener.unstub(:start)
|
33
|
-
end
|
34
|
-
|
35
|
-
should "activate player" do
|
36
|
-
assert @context.start(:background => true)
|
37
|
-
assert @context.stop
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
context "#stop" do
|
43
|
-
|
44
|
-
setup do
|
45
|
-
@context.midi.listener.expects(:on_message).once
|
46
|
-
@context.midi.listener.expects(:start).once
|
47
|
-
@context.midi.listener.expects(:stop).once
|
48
|
-
@context.player.expects(:quit).once
|
49
|
-
assert @context.start(:background => true)
|
50
|
-
end
|
51
|
-
|
52
|
-
teardown do
|
53
|
-
@context.midi.listener.unstub(:on_message)
|
54
|
-
@context.midi.listener.unstub(:start)
|
55
|
-
@context.player.unstub(:quit)
|
56
|
-
end
|
57
|
-
|
58
|
-
should "stop player" do
|
59
|
-
assert @context.stop
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
data/test/helper.rb
DELETED
data/test/helper/numbers_test.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::Helper::NumbersTest < Minitest::Test
|
4
|
-
|
5
|
-
context "Numbers" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@util = Object.new
|
9
|
-
@util.class.send(:include, MVLC::Helper::Numbers)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "#to_midi_value" do
|
13
|
-
|
14
|
-
should "convert 0" do
|
15
|
-
val = @util.to_midi_value(0)
|
16
|
-
refute_nil val
|
17
|
-
assert_equal 0x0, val
|
18
|
-
end
|
19
|
-
|
20
|
-
should "convert 64" do
|
21
|
-
val = @util.to_midi_value(50)
|
22
|
-
refute_nil val
|
23
|
-
assert_equal 0x40, val
|
24
|
-
end
|
25
|
-
|
26
|
-
should "convert 127" do
|
27
|
-
val = @util.to_midi_value(100)
|
28
|
-
refute_nil val
|
29
|
-
assert_equal 0x7F, val
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
context "#to_percent" do
|
35
|
-
|
36
|
-
should "convert 0%" do
|
37
|
-
val = @util.to_percent(0x0)
|
38
|
-
refute_nil val
|
39
|
-
assert_equal 0, val
|
40
|
-
end
|
41
|
-
|
42
|
-
should "convert 50%" do
|
43
|
-
val = @util.to_percent(0x40)
|
44
|
-
refute_nil val
|
45
|
-
assert_equal 50, val
|
46
|
-
end
|
47
|
-
|
48
|
-
should "convert 100%" do
|
49
|
-
val = @util.to_percent(0x7F)
|
50
|
-
refute_nil val
|
51
|
-
assert_equal 100, val
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::Instructions::MIDITest < Minitest::Test
|
4
|
-
|
5
|
-
context "MIDI" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@input = Object.new
|
9
|
-
@context = MVLC::Context.new(@input)
|
10
|
-
assert @context.kind_of?(MVLC::Instructions::MIDI)
|
11
|
-
end
|
12
|
-
|
13
|
-
context "#note" do
|
14
|
-
|
15
|
-
setup do
|
16
|
-
@context.midi.expects(:add_note_callback).once.returns({})
|
17
|
-
end
|
18
|
-
|
19
|
-
teardown do
|
20
|
-
@context.midi.unstub(:add_note_callback)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "assign callback" do
|
24
|
-
refute_nil @context.note(1) { something }
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
context "#cc" do
|
30
|
-
|
31
|
-
setup do
|
32
|
-
@context.midi.expects(:add_cc_callback).once.returns({})
|
33
|
-
end
|
34
|
-
|
35
|
-
teardown do
|
36
|
-
@context.midi.unstub(:add_cc_callback)
|
37
|
-
end
|
38
|
-
|
39
|
-
should "assign callback" do
|
40
|
-
refute_nil @context.cc(1) { |val| something }
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context "#system" do
|
46
|
-
|
47
|
-
setup do
|
48
|
-
@context.midi.expects(:add_system_callback).once.returns({})
|
49
|
-
end
|
50
|
-
|
51
|
-
teardown do
|
52
|
-
@context.midi.unstub(:add_system_callback)
|
53
|
-
end
|
54
|
-
|
55
|
-
should "assign callback" do
|
56
|
-
refute_nil @context.system(:stop) { something }
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
context "#receive_channel" do
|
62
|
-
|
63
|
-
setup do
|
64
|
-
@context.midi.expects(:channel=).once.with(3).returns(3)
|
65
|
-
end
|
66
|
-
|
67
|
-
teardown do
|
68
|
-
@context.midi.unstub(:channel=)
|
69
|
-
end
|
70
|
-
|
71
|
-
should "assign callback" do
|
72
|
-
refute_nil @context.receive_channel(3)
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::Instructions::PlayerTest < Minitest::Test
|
4
|
-
|
5
|
-
context "Player" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@player = Object.new
|
9
|
-
@player.stubs(:quit)
|
10
|
-
@player.stubs(:seek).returns(true)
|
11
|
-
VLC::System.stubs(:new).returns(@player)
|
12
|
-
@input = Object.new
|
13
|
-
@context = MVLC::Context.new(@input)
|
14
|
-
assert @context.kind_of?(MVLC::Instructions::Player)
|
15
|
-
end
|
16
|
-
|
17
|
-
context "#on_end_of_file" do
|
18
|
-
|
19
|
-
setup do
|
20
|
-
@context.player.expects(:add_end_of_file_callback).once.returns({})
|
21
|
-
end
|
22
|
-
|
23
|
-
teardown do
|
24
|
-
@context.player.unstub(:add_end_of_file_callback)
|
25
|
-
end
|
26
|
-
|
27
|
-
should "assign callback" do
|
28
|
-
refute_nil @context.on_end_of_file { something }
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
context "#method_missing" do
|
34
|
-
|
35
|
-
setup do
|
36
|
-
@context.player.expects(:mplayer_send).once.with(:seek, 50, :percent).returns(true)
|
37
|
-
end
|
38
|
-
|
39
|
-
teardown do
|
40
|
-
@context.player.unstub(:mplayer_send)
|
41
|
-
end
|
42
|
-
|
43
|
-
should "delegate" do
|
44
|
-
refute_nil @context.seek(50, :percent)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
context "#respond_to?" do
|
50
|
-
|
51
|
-
setup do
|
52
|
-
@context.player.expects(:mplayer_respond_to?).once.with(:seek).returns(true)
|
53
|
-
end
|
54
|
-
|
55
|
-
teardown do
|
56
|
-
@context.player.unstub(:mplayer_respond_to?)
|
57
|
-
end
|
58
|
-
|
59
|
-
should "delegate" do
|
60
|
-
refute_nil @context.respond_to?(:seek)
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
data/test/media/1.mov
DELETED
Binary file
|
data/test/media/2.mov
DELETED
Binary file
|
data/test/media/3.mov
DELETED
Binary file
|
@@ -1,315 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::MIDI::MessageHandlerTest < Minitest::Test
|
4
|
-
|
5
|
-
context "MessageHandler" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@handler = MVLC::MIDI::MessageHandler.new
|
9
|
-
end
|
10
|
-
|
11
|
-
context "#note_message" do
|
12
|
-
|
13
|
-
setup do
|
14
|
-
@message = MIDIMessage::NoteOn.new(0, 10, 100)
|
15
|
-
end
|
16
|
-
|
17
|
-
context "callback exists" do
|
18
|
-
|
19
|
-
setup do
|
20
|
-
@var = nil
|
21
|
-
@callback = proc { |vel| @var = vel }
|
22
|
-
@handler.add_callback(:note, @message.note, &@callback)
|
23
|
-
@callback.expects(:call).once
|
24
|
-
end
|
25
|
-
|
26
|
-
teardown do
|
27
|
-
@callback.unstub(:call)
|
28
|
-
end
|
29
|
-
|
30
|
-
context "has catch-all callback" do
|
31
|
-
|
32
|
-
setup do
|
33
|
-
@var2 = nil
|
34
|
-
@catchall = proc { |vel| @var2 = vel }
|
35
|
-
@handler.add_callback(:note, nil, &@catchall)
|
36
|
-
@catchall.expects(:call).once
|
37
|
-
end
|
38
|
-
|
39
|
-
teardown do
|
40
|
-
@catchall.unstub(:call)
|
41
|
-
end
|
42
|
-
|
43
|
-
should "call both callbacks" do
|
44
|
-
assert @handler.send(:note_message, @message)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
context "no catch-all callback" do
|
50
|
-
|
51
|
-
should "call specific callback" do
|
52
|
-
assert @handler.send(:note_message, @message)
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
context "callback doesn't exist" do
|
60
|
-
|
61
|
-
context "has catch-all callback" do
|
62
|
-
|
63
|
-
setup do
|
64
|
-
@var = nil
|
65
|
-
@callback = proc { |vel| @var = vel }
|
66
|
-
@handler.add_callback(:note, nil, &@callback)
|
67
|
-
@callback.expects(:call).once
|
68
|
-
end
|
69
|
-
|
70
|
-
should "call callback" do
|
71
|
-
assert @handler.send(:note_message, @message)
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
context "no catch-all callback" do
|
77
|
-
|
78
|
-
should "do nothing" do
|
79
|
-
refute @handler.send(:note_message, @message)
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
context "#cc_message" do
|
89
|
-
|
90
|
-
setup do
|
91
|
-
@message = MIDIMessage::ControlChange.new(0, 8, 100)
|
92
|
-
end
|
93
|
-
|
94
|
-
context "callback exists" do
|
95
|
-
|
96
|
-
setup do
|
97
|
-
@var = nil
|
98
|
-
@callback = proc { |vel| @var = vel }
|
99
|
-
@handler.add_callback(:cc, @message.index, &@callback)
|
100
|
-
@callback.expects(:call).once
|
101
|
-
end
|
102
|
-
|
103
|
-
teardown do
|
104
|
-
@callback.unstub(:call)
|
105
|
-
end
|
106
|
-
|
107
|
-
should "call callback" do
|
108
|
-
assert @handler.send(:cc_message, @message)
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
context "callback doesn't exist" do
|
114
|
-
|
115
|
-
context "has catch-all callback" do
|
116
|
-
|
117
|
-
setup do
|
118
|
-
@var = nil
|
119
|
-
@callback = proc { |vel| @var = vel }
|
120
|
-
@handler.add_callback(:cc, nil, &@callback)
|
121
|
-
@callback.expects(:call).once
|
122
|
-
end
|
123
|
-
|
124
|
-
should "call callback" do
|
125
|
-
assert @handler.send(:cc_message, @message)
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
context "no catch-all callback" do
|
131
|
-
|
132
|
-
should "do nothing" do
|
133
|
-
refute @handler.send(:cc_message, @message)
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
context "#system_message" do
|
143
|
-
|
144
|
-
setup do
|
145
|
-
@message = MIDIMessage::SystemRealtime.new(0x8) # clock
|
146
|
-
end
|
147
|
-
|
148
|
-
context "callback exists" do
|
149
|
-
|
150
|
-
setup do
|
151
|
-
@var = nil
|
152
|
-
@callback = proc { |vel| @var = vel }
|
153
|
-
@handler.add_callback(:system, :clock, &@callback)
|
154
|
-
@callback.expects(:call).once
|
155
|
-
end
|
156
|
-
|
157
|
-
teardown do
|
158
|
-
@callback.unstub(:call)
|
159
|
-
end
|
160
|
-
|
161
|
-
should "call callback" do
|
162
|
-
assert @handler.send(:system_message, @message)
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
166
|
-
|
167
|
-
context "callback doesn't exist" do
|
168
|
-
|
169
|
-
should "do nothing" do
|
170
|
-
refute @handler.send(:system_message, @message)
|
171
|
-
end
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
end
|
176
|
-
|
177
|
-
context "#channel_message" do
|
178
|
-
|
179
|
-
context "omni" do
|
180
|
-
|
181
|
-
setup do
|
182
|
-
@channel = nil
|
183
|
-
end
|
184
|
-
|
185
|
-
context "control change" do
|
186
|
-
|
187
|
-
setup do
|
188
|
-
@message = MIDIMessage::ControlChange.new(0, 8, 100)
|
189
|
-
@handler.expects(:cc_message).once.with(@message).returns(true)
|
190
|
-
end
|
191
|
-
|
192
|
-
teardown do
|
193
|
-
@handler.unstub(:cc_message)
|
194
|
-
end
|
195
|
-
|
196
|
-
should "handle control change" do
|
197
|
-
assert @handler.send(:channel_message, @channel, @message)
|
198
|
-
end
|
199
|
-
|
200
|
-
end
|
201
|
-
|
202
|
-
context "note" do
|
203
|
-
|
204
|
-
setup do
|
205
|
-
@message = MIDIMessage::NoteOn.new(0, 10, 100)
|
206
|
-
@handler.expects(:note_message).once.with(@message).returns(true)
|
207
|
-
end
|
208
|
-
|
209
|
-
teardown do
|
210
|
-
@handler.unstub(:note_message)
|
211
|
-
end
|
212
|
-
|
213
|
-
should "handle note" do
|
214
|
-
assert @handler.send(:channel_message, @channel, @message)
|
215
|
-
end
|
216
|
-
|
217
|
-
end
|
218
|
-
|
219
|
-
end
|
220
|
-
|
221
|
-
context "with channel" do
|
222
|
-
|
223
|
-
setup do
|
224
|
-
@channel = 5
|
225
|
-
end
|
226
|
-
|
227
|
-
context "control change" do
|
228
|
-
|
229
|
-
setup do
|
230
|
-
@message = MIDIMessage::ControlChange.new(@channel, 8, 100)
|
231
|
-
end
|
232
|
-
|
233
|
-
context "matching channel" do
|
234
|
-
|
235
|
-
setup do
|
236
|
-
@handler.expects(:cc_message).once.with(@message).returns(true)
|
237
|
-
end
|
238
|
-
|
239
|
-
teardown do
|
240
|
-
@handler.unstub(:cc_message)
|
241
|
-
end
|
242
|
-
|
243
|
-
should "handle control change" do
|
244
|
-
assert @handler.send(:channel_message, @channel, @message)
|
245
|
-
end
|
246
|
-
|
247
|
-
end
|
248
|
-
|
249
|
-
context "non matching channel" do
|
250
|
-
|
251
|
-
setup do
|
252
|
-
@handler.expects(:cc_message).never
|
253
|
-
@other_message = MIDIMessage::ControlChange.new(@channel + 1, 8, 100)
|
254
|
-
end
|
255
|
-
|
256
|
-
teardown do
|
257
|
-
@handler.unstub(:cc_message)
|
258
|
-
end
|
259
|
-
|
260
|
-
should "do nothing" do
|
261
|
-
refute @handler.send(:channel_message, @channel, @other_message)
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
|
266
|
-
end
|
267
|
-
|
268
|
-
context "note" do
|
269
|
-
|
270
|
-
setup do
|
271
|
-
@message = MIDIMessage::NoteOn.new(@channel, 10, 100)
|
272
|
-
end
|
273
|
-
|
274
|
-
context "matching channel" do
|
275
|
-
|
276
|
-
setup do
|
277
|
-
@handler.expects(:note_message).once.with(@message).returns(true)
|
278
|
-
end
|
279
|
-
|
280
|
-
teardown do
|
281
|
-
@handler.unstub(:note_message)
|
282
|
-
end
|
283
|
-
|
284
|
-
should "call callback" do
|
285
|
-
assert @handler.send(:channel_message, @channel, @message)
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|
289
|
-
|
290
|
-
context "non matching channel" do
|
291
|
-
|
292
|
-
setup do
|
293
|
-
@handler.expects(:note_message).never
|
294
|
-
@other_message = MIDIMessage::ControlChange.new(@channel + 1, 8, 100)
|
295
|
-
end
|
296
|
-
|
297
|
-
teardown do
|
298
|
-
@handler.unstub(:note_message)
|
299
|
-
end
|
300
|
-
|
301
|
-
should "not call callback" do
|
302
|
-
refute @handler.send(:channel_message, @channel, @other_message)
|
303
|
-
end
|
304
|
-
|
305
|
-
end
|
306
|
-
|
307
|
-
end
|
308
|
-
|
309
|
-
end
|
310
|
-
|
311
|
-
end
|
312
|
-
|
313
|
-
end
|
314
|
-
|
315
|
-
end
|
data/test/midi/wrapper_test.rb
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::MIDI::WrapperTest < Minitest::Test
|
4
|
-
|
5
|
-
context "Wrapper" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@input = Object.new
|
9
|
-
@midi = MVLC::MIDI::Wrapper.new(@input)
|
10
|
-
end
|
11
|
-
|
12
|
-
context "#handle_new_event" do
|
13
|
-
|
14
|
-
context "with no buffer length" do
|
15
|
-
|
16
|
-
setup do
|
17
|
-
@midi.message_handler.expects(:process).once
|
18
|
-
@event = {
|
19
|
-
:message => MIDIMessage::NoteOn.new(0, 64, 120),
|
20
|
-
:timestamp=> 9266.395330429077
|
21
|
-
}
|
22
|
-
@result = @midi.send(:handle_new_event, @event)
|
23
|
-
end
|
24
|
-
|
25
|
-
teardown do
|
26
|
-
@midi.message_handler.unstub(:process)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "return event" do
|
30
|
-
refute_nil @result
|
31
|
-
assert_equal @event, @result
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with buffer length" do
|
37
|
-
|
38
|
-
context "recent message" do
|
39
|
-
|
40
|
-
setup do
|
41
|
-
@midi.message_handler.expects(:process).once
|
42
|
-
@event = {
|
43
|
-
:message => MIDIMessage::NoteOn.new(0, 64, 120),
|
44
|
-
:timestamp=> 9266.395330429077
|
45
|
-
}
|
46
|
-
@result = @midi.send(:handle_new_event, @event)
|
47
|
-
end
|
48
|
-
|
49
|
-
teardown do
|
50
|
-
@midi.message_handler.unstub(:process)
|
51
|
-
end
|
52
|
-
|
53
|
-
should "return event" do
|
54
|
-
refute_nil @result
|
55
|
-
assert_equal @event, @result
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with too-old message" do
|
61
|
-
|
62
|
-
setup do
|
63
|
-
@midi.instance_variable_set("@buffer_length", 1)
|
64
|
-
@midi.instance_variable_set("@start_time", Time.now.to_i)
|
65
|
-
sleep(2)
|
66
|
-
@midi.message_handler.expects(:process).never
|
67
|
-
@event = {
|
68
|
-
:message => MIDIMessage::NoteOn.new(0, 64, 120),
|
69
|
-
:timestamp => 0.1
|
70
|
-
}
|
71
|
-
@result = @midi.send(:handle_new_event, @event)
|
72
|
-
end
|
73
|
-
|
74
|
-
teardown do
|
75
|
-
@midi.message_handler.unstub(:process)
|
76
|
-
end
|
77
|
-
|
78
|
-
should "not return event" do
|
79
|
-
assert_nil @result
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
context "#initialize_listener" do
|
89
|
-
|
90
|
-
setup do
|
91
|
-
@midi.listener.expects(:on_message).once
|
92
|
-
@result = @midi.send(:initialize_listener)
|
93
|
-
end
|
94
|
-
|
95
|
-
teardown do
|
96
|
-
@midi.listener.unstub(:on_message)
|
97
|
-
end
|
98
|
-
|
99
|
-
should "return listener" do
|
100
|
-
refute_nil @result
|
101
|
-
assert_equal MIDIEye::Listener, @result.class
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
context "#start" do
|
107
|
-
|
108
|
-
setup do
|
109
|
-
@midi.listener.expects(:on_message).once
|
110
|
-
@midi.listener.expects(:start).once
|
111
|
-
end
|
112
|
-
|
113
|
-
teardown do
|
114
|
-
@midi.listener.unstub(:on_message)
|
115
|
-
@midi.listener.unstub(:start)
|
116
|
-
end
|
117
|
-
|
118
|
-
should "activate callbacks" do
|
119
|
-
assert @midi.start
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
context "#add_note_callback" do
|
125
|
-
|
126
|
-
setup do
|
127
|
-
@var = nil
|
128
|
-
@midi.add_note_callback(10) { |vel| @var = vel }
|
129
|
-
end
|
130
|
-
|
131
|
-
should "store callback" do
|
132
|
-
refute_nil @midi.message_handler.callback[:note][10]
|
133
|
-
assert_equal Proc, @midi.message_handler.callback[:note][10].class
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
context "#add_system_callback" do
|
139
|
-
|
140
|
-
setup do
|
141
|
-
@var = nil
|
142
|
-
@midi.add_system_callback(:start) { |val| @var = val }
|
143
|
-
end
|
144
|
-
|
145
|
-
should "store callback" do
|
146
|
-
refute_nil @midi.message_handler.callback[:system][:start]
|
147
|
-
assert_equal Proc, @midi.message_handler.callback[:system][:start].class
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
|
152
|
-
context "#add_cc_callback" do
|
153
|
-
|
154
|
-
setup do
|
155
|
-
@var = nil
|
156
|
-
@midi.add_cc_callback(2) { |val| @var = val }
|
157
|
-
end
|
158
|
-
|
159
|
-
should "store callback" do
|
160
|
-
refute_nil @midi.message_handler.callback[:cc][2]
|
161
|
-
assert_equal Proc, @midi.message_handler.callback[:cc][2].class
|
162
|
-
end
|
163
|
-
|
164
|
-
end
|
165
|
-
|
166
|
-
context "#channel=" do
|
167
|
-
|
168
|
-
setup do
|
169
|
-
# stub out MIDIEye
|
170
|
-
@listener = Object.new
|
171
|
-
@listener.stubs(:event).returns([])
|
172
|
-
@midi.instance_variable_set("@listener", @listener)
|
173
|
-
end
|
174
|
-
|
175
|
-
teardown do
|
176
|
-
@listener.unstub(:clear)
|
177
|
-
@listener.unstub(:on_message)
|
178
|
-
@listener.unstub(:event)
|
179
|
-
@listener.unstub(:running?)
|
180
|
-
end
|
181
|
-
|
182
|
-
context "before listener is started" do
|
183
|
-
|
184
|
-
setup do
|
185
|
-
@listener.stubs(:running?).returns(false)
|
186
|
-
@listener.expects(:clear).never
|
187
|
-
@listener.expects(:on_message).never
|
188
|
-
end
|
189
|
-
|
190
|
-
should "change channel" do
|
191
|
-
assert_equal 3, @midi.channel = 3
|
192
|
-
assert_equal 3, @midi.channel
|
193
|
-
refute @midi.omni?
|
194
|
-
end
|
195
|
-
|
196
|
-
should "set channel nil" do
|
197
|
-
assert_nil @midi.channel = nil
|
198
|
-
assert_nil @midi.channel
|
199
|
-
assert @midi.omni?
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
context "after listener is started" do
|
204
|
-
|
205
|
-
setup do
|
206
|
-
@listener.stubs(:running?).returns(true)
|
207
|
-
@listener.expects(:clear).once
|
208
|
-
@listener.expects(:on_message).once
|
209
|
-
end
|
210
|
-
|
211
|
-
should "change channel" do
|
212
|
-
assert_equal 3, @midi.channel = 3
|
213
|
-
assert_equal 3, @midi.channel
|
214
|
-
refute @midi.omni?
|
215
|
-
end
|
216
|
-
|
217
|
-
should "set channel nil" do
|
218
|
-
assert_nil @midi.channel = nil
|
219
|
-
assert_nil @midi.channel
|
220
|
-
assert @midi.omni?
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|
228
|
-
|
229
|
-
end
|
data/test/player/wrapper_test.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require "helper"
|
2
|
-
|
3
|
-
class MVLC::Player::WrapperTest < Minitest::Test
|
4
|
-
|
5
|
-
context "Wrapper" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
@player = Object.new
|
9
|
-
@player.stubs(:quit)
|
10
|
-
conn = Object.new
|
11
|
-
conn.stubs(:write)
|
12
|
-
@player.stubs(:connection).returns(conn)
|
13
|
-
VLC::System.stubs(:new).returns(@player)
|
14
|
-
@player = MVLC::Player::Wrapper.new
|
15
|
-
end
|
16
|
-
|
17
|
-
context "#quit" do
|
18
|
-
|
19
|
-
setup do
|
20
|
-
#@vlc.expects(:quit).once
|
21
|
-
#@player.instance_variable_get("@threads").first.expects(:kill).once
|
22
|
-
end
|
23
|
-
|
24
|
-
teardown do
|
25
|
-
#@vlc.unstub(:quit)
|
26
|
-
# @player.instance_variable_get("@threads").first.unstub(:kill)
|
27
|
-
end
|
28
|
-
|
29
|
-
should "exit MPlayer and kill the player thread" do
|
30
|
-
assert @player.quit
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
context "#play" do
|
36
|
-
|
37
|
-
setup do
|
38
|
-
@player.expects(:play).once.returns(true)
|
39
|
-
end
|
40
|
-
|
41
|
-
teardown do
|
42
|
-
@player.unstub(:play)
|
43
|
-
end
|
44
|
-
|
45
|
-
should "lazily invoke mplayer and play" do
|
46
|
-
assert @player.play("file.mov")
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|