1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScriptで音声ファイル確認&再生

Posted at
const soundPlay = function(url) {
    // オブジェクト生成
    var soundObj = new Audio();

    soundObj.onerror = function() {
        // エラー時の処理
        alert("再生できませんでした");
    }
    // URL設定
    soundObj.src = url;
    // 再生(できないときはエラーに行く)
    soundObj.play();
}

使い方

soundPlay("assets/sound/temp.mp3");
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?