File tree 5 files changed +31
-1
lines changed
5 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,19 @@ exports.Sound = function Sound(uriOrAudio) {
160
160
*/
161
161
this . stop = function ( ) {
162
162
channels . forEach ( function ( audio ) {
163
- audio . stop ( ) ;
163
+ audio . pause ( ) ;
164
+ audio . load ( ) ;
165
+ audio . currentTime = 0 ;
166
+ } ) ;
167
+ } ;
168
+
169
+ /**
170
+ * Pause the sound.
171
+ * This will pause the playback of this Sound on any active Channels.
172
+ */
173
+ this . pause = function ( ) {
174
+ channels . forEach ( function ( audio ) {
175
+ audio . pause ( ) ;
164
176
} ) ;
165
177
} ;
166
178
Original file line number Diff line number Diff line change
1
+ var gamejs = require ( 'gamejs' ) ;
2
+ qModule ( 'gamejs/audio' ) ;
3
+ var surfaceEqual = QUnit . surfaceEqual ;
4
+
5
+ var audio = null ;
6
+ QUnit . testStart ( function ( ) {
7
+ audio = new gamejs . audio . Sound ( document . getElementById ( 'sound-fixture' ) ) ;
8
+ } )
9
+
10
+ // this should just run through
11
+ QUnit . test ( 'basic' , 0 , function ( ) {
12
+ audio . play ( ) ;
13
+ audio . stop ( ) ;
14
+ audio . play ( ) ;
15
+ audio . pause ( ) ;
16
+ } ) ;
Original file line number Diff line number Diff line change 21
21
<!-- for testing the unit tests it's sometimes convinient to have a canvas present to
22
22
output images -->
23
23
< canvas id ="gjs-canvas " width =800 height =600 > </ canvas >
24
+ < audio id ="sound-fixture " src ="./sound-fixture.wav "> </ audio >
24
25
< h1 id ="qunit-header "> GameJs Test Suite</ h1 >
25
26
< h2 id ="qunit-banner "> </ h2 >
26
27
< div id ="qunit-testrunner-toolbar "> </ div >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ gamejs.ready(function() {
6
6
7
7
// NOTE can't name it `gamejs` because that would conflict with above
8
8
// maybe yabble bug
9
+ require ( './audio' ) ;
9
10
require ( './base64' ) ;
10
11
require ( './binaryheap' ) ;
11
12
require ( './draw' ) ;
You can’t perform that action at this time.
0 commit comments