Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt Android MediaPlayer for .mp3 files not working
Forum Updated to NodeBB v4.3 + New Features

Qt Android MediaPlayer for .mp3 files not working

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 2 Posters 67 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarcoDC
    wrote last edited by
    #1

    Hey there :D

    I am almost done with porting my app from Qt5.15.17 QMake to Qt6.9.1 CMake :DDD
    Last thing I noticed is that for some reason playing an .mp3 sound file does not work anymore :/

    Previously there were no problems,
    but after switching to the new version I receive output like

    I/qt.multimedia.ffmpeg(30077): Using Qt multimedia with FFmpeg version 7.1.1 LGPL version 2.1 or later
    ...
    W/AudioCapabilities(30077): Unsupported mime audio/ac4
    W/AudioCapabilities(30077): Unsupported mime audio/x-ima
    W/AudioCapabilities(30077): Unsupported mime audio/eac3-joc
    W/AudioCapabilities(30077): Unsupported mime audio/evrc
    W/AudioCapabilities(30077): Unsupported mime audio/mpeg-L1
    W/AudioCapabilities(30077): Unsupported mime audio/mpeg-L2
    W/AudioCapabilities(30077): Unsupported mime audio/qcelp
    W/AudioCapabilities(30077): Unsupported mime audio/x-ms-wma
    W/AudioCapabilities(30077): Unsupported mime audio/evrc
    W/AudioCapabilities(30077): Unsupported mime audio/qcelp
    W/VideoCapabilities(30077): Unrecognized profile 4 for video/hevc
    W/VideoCapabilities(30077): Unsupported mime video/mp43
    W/VideoCapabilities(30077): Unrecognized profile/level 1/32 for video/mp4v-es
    W/VideoCapabilities(30077): Unrecognized profile/level 32768/2 for video/mp4v-es
    W/VideoCapabilities(30077): Unrecognized profile/level 32768/64 for video/mp4v-es
    W/VideoCapabilities(30077): Unsupported mime video/wvc1
    

    on startup,
    and when trying to play my set .mp3 file just:

    W/ ( 8481): 273 - 2 2025-06-25 15:31:34.397 QAudioSink::start: QAudioFormat not supported by QAudioDevice >> :0 ()

    Why is that? The Android device I am using is the same as before and this worked perfectly using Qt5.15.

    I put some code in my main.cpp to print supported formats like

    QAudioDevice device = QMediaDevices::defaultAudioOutput();
    qDebug() << "Supported sample formats:";
    for (auto fmt : device.supportedSampleFormats())
        qDebug() << "  " << fmt;
    
    QAudioFormat format = device.preferredFormat();
    qDebug() << "Sample rate:" << format.sampleRate();
    qDebug() << "Channel count:" << format.channelCount();
    qDebug() << "Sample format:" << format.sampleFormat();
    

    and received this output:

    D/default (30077): Supported sample formats:
    D/default (30077): Int16
    D/default (30077): Sample rate: 48000
    D/default (30077): Channel count: 2
    D/default (30077): Sample format: Int16

    Because I did not find a real solution to this problem I just converted my .mp3 file to a .wav file which seems to work, but has an 10 times increased file size that also is reflected in the resulting apk/aab binary :/

    Is anyone aware of a solution that allows me to continue playing .mp3 files on my Android device? This also works fine on iOS and macOS builds

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MarcoDC
      wrote last edited by
      #2

      Ah I forgot, in my root project CMakeLists I just add Multimedia package to link against:

      find_package(Qt6 REQUIRED COMPONENTS Quick Qml QuickControls2 ... Multimedia)
      target_link_libraries(${PROJECT_NAME} PRIVATE
          Qt::Concurrent
          Qt::Qml
          Qt::Quick
          Qt::QuickControls2
          ...
          Qt::Multimedia
      )
      

      For iOS I needed to add

      # Add FFMpeg lib for MediaPlayer support
      qt_add_ios_ffmpeg_libraries(${PROJECT_NAME})
      

      for audio to work at all, macOS does not need any additional stuff

      So maybe there is some dependency for Android that I am just missing?

      1 Reply Last reply
      0
      • JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote last edited by JoeCFD
        #3

        both audio and video encoders/decoders have to be added in your android build.

        M 1 Reply Last reply
        0
        • JoeCFDJ JoeCFD

          both audio and video encoders/decoders have to be added in your android build.

          M Offline
          M Offline
          MarcoDC
          wrote last edited by
          #4

          Hey @JoeCFD thanks for your answer :D

          How/where to I do this?

          JoeCFDJ 1 Reply Last reply
          0
          • M MarcoDC

            Hey @JoeCFD thanks for your answer :D

            How/where to I do this?

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote last edited by JoeCFD
            #5

            @MarcoDC If gstreamer(you may use FFmpeg) build for Android is downloaded, the libs and plugins are static and can not be linked for commercial use. What I did was to build all gstreamer stuff into a single dynamic lib. Very messy! But if your app is not commercial, you can simply link static ones to your app.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved