Getting duration of music file in android



  • Hi. I want to get duration of a music sound on android.
    I connected a slot to durationChanged signal of QMediaPlayer but it shows the following error in android

    W/dalvikvm(32228): No implementation found for native Lorg/qtproject/qt5/android/multimedia/QtAndroidMediaPlayer;.onStateChangedNative (IJ)V
    

    my code:

        player = new QMediaPlayer(this);
        player->setMedia(QMediaContent(QUrl(media_file_name)));
        connect(player, &QMediaPlayer::durationChanged, [=](qint64 duration){
            qDebug() << "Duration:" << duration;
            media_duration = duration;
        });
        connect(player, &QMediaPlayer::stateChanged, [=](QMediaPlayer::State newState){
            if(newState == QMediaPlayer::PlayingState)
                setTilesEnabled(false);
            else
                setTilesEnabled(true);
        });
    

    I commented second connect, but does not work either.

    Qt 5.6.0 on Arch linux
    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.