Linux 下 Qt Multimedia 模塊無法播放 MP3,系統播放器正常。
Qt Multimedia 依賴 **GStreamer** 做音視頻解碼,發行版默認可能未安裝 MP3 解碼插件(gstreamer1.0-plugins-ugly 或 gstreamer0.10-plugins-ugly)。
# Ubuntu/Debian (Qt5 通常用 GStreamer 1.0)
sudo apt-get update
sudo apt-get install gstreamer1.0-plugins-ugly gstreamer1.0-plugins-bad gstreamer1.0-plugins-good
# 若項目強依賴 GStreamer 0.10 (舊版 Qt4/早期 Qt5)
sudo apt-get install gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-plugins-good
安裝後重新運行程序,MP3 應可正常播放。若仍失敗,檢查 QMediaPlayer::errorString() 並確認 gst-inspect-1.0 | grep mp3 有 mp3parse、mad 等元素。
Qt 6 已改用 FFmpeg 作為默認後端,若用 Qt 6 需安裝 libavcodec 等 FFmpeg 庫。