質問
srcに変数を指定すると音声が再生できません。
:src="filepath"
定数だと再生できますが、原因は何でしょうか?
src=https://s3-ap-northeast-1.amazonaws.com/***/sound.mp3
ソースコード
vue
1<audio id="player" control> 2 <source :src="filepath" type="audio/mp3"> 3</audio> 4 5data() { 6 options: "", 7 filepath: "", 8}, 9mount() { 10 // Plyrを使用しています 11 const player = new Plyr("#player", this.options); 12}, 13methods: { 14 getSound(speaker) { 15 axios.get("/api/get/sound/") 16 .then(response => { 17 this.filepath = response.data; 18 }); 19 } 20}
php
1public function getSound() 2{ 3 //phpからはファイルの相対パスを返しています。 4 return 'media/sound.mp3'; 5}
エラー内容
Module parse failed: Unexpected character '�' (1:0) You may need an appropriate loader to handle this file type. (Source code omitted for this binary file)
response.data に期待通りのファイル名が入っていることは確認しているのでしょうか?
あなたの回答
tips
プレビュー