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. QMediaPlayer doesn't work on Android 10
Qt 6.11 is out! See what's new in the release blog

QMediaPlayer doesn't work on Android 10

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
2 Posts 2 Posters 765 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.
  • D Offline
    D Offline
    Devoo
    wrote on last edited by Devoo
    #1

    Hi,
    I created simple qt quick project to test QMediaPlayer.
    For some reason it works perfectly on Windows but it is silent on Android.
    I just changed main.cpp:

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    #include <QMediaPlayer>
    #include <thread>
    #include <QDebug>
    #include <QtConcurrent>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
    
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/qml/main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl)
        {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        },
        Qt::QueuedConnection);
        engine.load(url);
    
    
        // Test
        QMediaPlayer* player;
        auto thread = QtConcurrent::run([&player]()
        {
            using namespace std::chrono_literals;
            qDebug() << "Hello waiter";
            std::this_thread::sleep_for(3s);
    
            // ...
            player = new QMediaPlayer();
            player->setMedia(QUrl("http://www.hochmuth.com/mp3/Vivaldi_Sonata_eminor_.mp3"));
            player->setVolume(50);
            player->play();
    
            qDebug() << "Player is playing now";
    
        });
    
        return app.exec();
    }
    
    

    and added multimedia to .pro file.

    Logs:

    D libGui_armeabi-v7a.so: Hello waiter
    V MediaHTTPService: MediaHTTPService(android.media.MediaHTTPService@6d73455): Cookies: null
    D libGui_armeabi-v7a.so: Player is playing now
    V MediaHTTPService: makeHTTPConnection: CookieManager created: java.net.CookieManager@a515e6a
    V MediaHTTPService: makeHTTPConnection(android.media.MediaHTTPService@6d73455): cookieHandler: java.net.CookieManager@a515e6a Cookies: null
    D NetworkSecurityConfig: No Network Security Config specified, using platform default
    

    Android: 10
    Qt: 5.15.1

    What's wrong with this code?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vega4
      wrote on last edited by
      #2

      https://forum.qt.io/topic/127649/mp3-not-being-played-on-android/13

      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