Skip to content

Commit

Permalink
Merge pull request #311 from akashic-games/fix-htmlaudioplayer
Browse files Browse the repository at this point in the history
Fix HTMLAudioPlayer
  • Loading branch information
ShinobuTakahashi authored May 13, 2024
2 parents c969416 + 4f7a817 commit 19fc379
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 2.9.2
* `HTMLAudioPlayer#play()` で同じ audio が連続で再生された時にエラーとなる不具合を修正

## 2.9.1
* View の外をクリック時に `pointDown` イベントが発生しないよう修正

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@akashic/pdi-browser",
"version": "2.9.1",
"version": "2.9.2",
"description": "An akashic-pdi implementation for Web browsers",
"main": "index.js",
"typings": "lib/full/index.d.ts",
Expand Down
8 changes: 8 additions & 0 deletions src/plugin/HTMLAudioPlugin/HTMLAudioPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ export class HTMLAudioPlayer extends AudioPlayer {

play(asset: HTMLAudioAsset): void {
if (this.currentAudio) {
if (asset.id === this.currentAudio.id) {
// 同じ audio を 連続で再生するとエラーとなる。これは audio.play() が非同期で開始されるためである。
// 現在再生中とこれから再生しようとする audio が同じ場合は現在の audio を先頭から再生し、これから再生しようとする audio は何もしないようにする。
super.stop();
this._audioInstance!.currentTime = (asset.offset ?? 0) / 1000;
super.play(asset);
return;
}
this.stop();
}
const audio = asset.cloneElement();
Expand Down

0 comments on commit 19fc379

Please sign in to comment.