1. 程式人生 > >Ubuntu下Firefox播放mp3顯示HTTP "Content-Type" of "audio/mpeg" is not supported錯誤的解決辦法

Ubuntu下Firefox播放mp3顯示HTTP "Content-Type" of "audio/mpeg" is not supported錯誤的解決辦法

在Ubuntu下,使用javascript進行mp3播放

var audio = new Audio('file.mp3');
audio.play();

如果遇到

HTTP “Content-Type” of “audio/mpeg” is not supported. Load of media resource … failed.

錯誤,原因很可能是因為沒有安裝mp3解碼器。

要解決這個錯誤,請輸入以下命令:

$ sudo apt-get install -y ubuntu-restricted-extras

$ sudo apt-get
install gstreamer1.0-plugins-bad $ sudo apt-get install gstreamer1.0-plugins-ugly

完成後重啟瀏覽器即可。