Skip to content

Commit

Permalink
add pause and stop to example to show difference
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisweb committed Aug 30, 2023
1 parent 82f43d8 commit d37839f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion examples/simple-player/client/src/library/player/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,18 @@ class PlayerUI {
this.player.play({ whichSound: 'last' });
}

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

if ($button.id === 'pause') {
this.player.pause();
}

if ($button.id === 'stop') {
this.player.stop();
}
}

protected _setPlayingProgress(percentage: number): void {
Expand Down
6 changes: 4 additions & 2 deletions examples/simple-player/html/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ <h1>web audio api player - simple example</h1>
<section id="js-extra-buttons">
<button id="js-first" class="button">First</button>
<button id="js-last" class="button">Last</button>
<button id="js-byId" class="button" data-song-id="1314412">Song by ID: 1314412 (= 1st song in queue)</button>
<button id="js-byId" class="button" data-song-id="1214935">Song by ID: 1214935 (= 2nd / last song in
<button id="js-byId-1" class="button" data-song-id="1314412">Song by ID: 1314412 (= 1st song in queue)</button>
<button id="js-byId-2" class="button" data-song-id="1214935">Song by ID: 1214935 (= 2nd / last song in
queue)</button>
<button id="pause" class="button">Pause</button>
<button id="stop" class="button">Stop</button>
</section>

</body>
Expand Down

0 comments on commit d37839f

Please sign in to comment.