-
Bug
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.9.0
-
None
-
Qt Creator 16.02
Hello, i made the code, which works perfectly in Windows, but doesn't work in Android.
The code in order to reproduse a bug:
... pplayer->stop(); pplayer->setSource(url); int attempts = 25; bool isBroken = (pplayer->mediaStatus() == QMediaPlayer::LoadedMedia) && (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia); while(isBroken && pplayer) { QThread::msleep(20); if (!attempts) break; attempts--; isBroken = (pplayer->mediaStatus() == QMediaPlayer::LoadedMedia) && (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia); } if (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia) { qWarning() << "No preview for:" << abspath << " QMediaPlayer::InvalidMedia"; break; } m_alreadyFrame = false; qWarning() << "before wait:"; pplayer->pause(); QCoreApplication::processEvents(); QThread::msleep(10); attempts = 20; isBroken = (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia); while (!m_alreadyFrame && !isBroken && attempts) { QCoreApplication::processEvents(); QThread::msleep(10); isBroken = (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia); attempts--; } qWarning() << "after wait:"; QCoreApplication::processEvents(); if (m_alreadyFrame) { const QVideoFrame& vf = psink->videoFrame(); if (psink->videoFrame().map(QVideoFrame::ReadOnly)) { image = psink->videoFrame().toImage(); psink->videoFrame().unmap(); } else { qWarning() << "QVideoFrame psink is not mapped"; break; } if (image.format() == QImage::Format_Invalid) { qWarning() << "QImage::Format_Invalid"; isBroken = true; } } pplayer->stop(); m_alreadyFrame = false; if (isBroken || !attempts) { qWarning() << "No preview for:" << abspath ; qWarning() << "attempts:" << attempts << " isBroken:" << isBroken; break; } //setState(TPrevStates::eIdle); //break; QString key = fileName; qWarning() << "key is:" << key << " width is:" << image.width();
QScopedPointer<QMediaPlayer> pplayer; QImage image; QVideoFrame frame; pplayer.reset(new QMediaPlayer); QScopedPointer<QVideoSink> psink; //QVideoSink* psink = pplayer->videoSink(); psink.reset(new QVideoSink); pplayer->setVideoOutput(psink.get()); connect(psink.get(), &QVideoSink::videoFrameChanged, this, [&](const QVideoFrame & _frame){ if (!_frame.isValid()) { qWarning() << "frame is not valid"; return; } qWarning() << "frame is valid"; m_alreadyFrame = true; });