Skip to content

Commit d37839f

Browse files
committed
add pause and stop to example to show difference
1 parent 82f43d8 commit d37839f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

examples/simple-player/client/src/library/player/ui.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,18 @@ class PlayerUI {
149149
this.player.play({ whichSound: 'last' });
150150
}
151151

152-
if ($button.id === 'js-byId') {
152+
if ($button.id.substring(0, 7) === 'js-byId') {
153153
const songId = $button.getAttribute('data-song-id');
154154
this.player.play({ whichSound: parseInt(songId) });
155155
}
156156

157+
if ($button.id === 'pause') {
158+
this.player.pause();
159+
}
160+
161+
if ($button.id === 'stop') {
162+
this.player.stop();
163+
}
157164
}
158165

159166
protected _setPlayingProgress(percentage: number): void {

examples/simple-player/html/main.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ <h1>web audio api player - simple example</h1>
6060
<section id="js-extra-buttons">
6161
<button id="js-first" class="button">First</button>
6262
<button id="js-last" class="button">Last</button>
63-
<button id="js-byId" class="button" data-song-id="1314412">Song by ID: 1314412 (= 1st song in queue)</button>
64-
<button id="js-byId" class="button" data-song-id="1214935">Song by ID: 1214935 (= 2nd / last song in
63+
<button id="js-byId-1" class="button" data-song-id="1314412">Song by ID: 1314412 (= 1st song in queue)</button>
64+
<button id="js-byId-2" class="button" data-song-id="1214935">Song by ID: 1214935 (= 2nd / last song in
6565
queue)</button>
66+
<button id="pause" class="button">Pause</button>
67+
<button id="stop" class="button">Stop</button>
6668
</section>
6769

6870
</body>

0 commit comments

Comments
 (0)