void QAndroidMediaPlayerControl::onVideoSizeChanged(qint32 width, qint32 height)
{
    QSize newSize(width, height);

    if (width == 0 || height == 0 || newSize == mVideoSize)
        return;

    setVideoAvailable(true);
    mVideoSize = newSize;

    if (mVideoOutput)
        mVideoOutput->setVideoSize(mVideoSize);
}
void QAndroidMediaPlayerControl::onVideoSizeChanged(qint32 width, qint32 height)
{
    if (width == 0 || height == 0)
        return;

    setVideoAvailable(true);

    if (mVideoOutput) {
        if (!mMediaPlayer->display())
            mMediaPlayer->setDisplay(mVideoOutput->surfaceHolder());
        if (mMediaPlayer->display())
            mVideoOutput->setVideoSize(QSize(width, height));
    }
}
void QAndroidMediaPlayerControl::setMedia(const QMediaContent &mediaContent,
                                          QIODevice *stream)
{
    mMediaContent = mediaContent;
    mMediaStream = stream;

    const QString uri = mediaContent.canonicalUrl().toString();

    if (!uri.isEmpty())
        mMediaPlayer->setDataSource(uri);
    else
        setMediaStatus(QMediaPlayer::NoMedia);

    Q_EMIT mediaChanged(mMediaContent);

    resetBufferingProgress();

    // reset some properties
    setAudioAvailable(false);
    setVideoAvailable(false);
    setSeekable(true);
}
void QAndroidMediaPlayerControl::setMedia(const QMediaContent &mediaContent,
                                          QIODevice *stream)
{
    mMediaContent = mediaContent;
    mMediaStream = stream;

    if (mVideoOutput && !mMediaPlayer->display()) {
        // if a video output is set but the video texture is not ready, delay loading the media
        // since it can cause problems on some hardware
        mPendingSetMedia = true;
        return;
    }

    const QUrl url = mediaContent.canonicalUrl();
    QString mediaPath;
    if (url.scheme() == QLatin1String("qrc")) {
        const QString path = url.toString().mid(3);
        mTempFile.reset(QTemporaryFile::createNativeFile(path));
        if (!mTempFile.isNull())
            mediaPath = QLatin1String("file://") + mTempFile->fileName();
    } else {
        mediaPath = url.toString();
    }

    if (!mediaPath.isEmpty())
        mMediaPlayer->setDataSource(mediaPath);
    else
        setMediaStatus(QMediaPlayer::NoMedia);

    Q_EMIT mediaChanged(mMediaContent);

    resetBufferingProgress();

    // reset some properties
    setAudioAvailable(false);
    setVideoAvailable(false);
    setSeekable(true);
}