AVFoundation: fix media player video rendering in QML.
The AVPlayerLayer was set on the QVideoRendererControl before its geometry was updated, causing the renderer control to display frames with an invalid size. Change-Id: I90e18dce69d4b48a3d7932d44a7eab4fd443f1fb Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
@@ -97,8 +97,6 @@ public Q_SLOTS:
|
|||||||
void processPositionChange();
|
void processPositionChange();
|
||||||
void processMediaLoadError();
|
void processMediaLoadError();
|
||||||
|
|
||||||
void processCurrentItemChanged();
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void positionChanged(qint64 position);
|
void positionChanged(qint64 position);
|
||||||
void durationChanged(qint64 duration);
|
void durationChanged(qint64 duration);
|
||||||
|
|||||||
@@ -340,9 +340,6 @@ static void *AVFMediaPlayerSessionObserverCurrentItemObservationContext = &AVFMe
|
|||||||
AVPlayerItem *newPlayerItem = [change objectForKey:NSKeyValueChangeNewKey];
|
AVPlayerItem *newPlayerItem = [change objectForKey:NSKeyValueChangeNewKey];
|
||||||
if (m_playerItem != newPlayerItem)
|
if (m_playerItem != newPlayerItem)
|
||||||
m_playerItem = newPlayerItem;
|
m_playerItem = newPlayerItem;
|
||||||
|
|
||||||
if (self.session)
|
|
||||||
QMetaObject::invokeMethod(m_session, "processCurrentItemChanged", Qt::AutoConnection);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -806,6 +803,10 @@ void AVFMediaPlayerSession::processLoadStateChange()
|
|||||||
playerLayer.bounds = CGRectMake(0.0f, 0.0f,
|
playerLayer.bounds = CGRectMake(0.0f, 0.0f,
|
||||||
videoTrack.naturalSize.width,
|
videoTrack.naturalSize.width,
|
||||||
videoTrack.naturalSize.height);
|
videoTrack.naturalSize.height);
|
||||||
|
|
||||||
|
if (m_videoOutput && m_state != QMediaPlayer::StoppedState) {
|
||||||
|
m_videoOutput->setLayer(playerLayer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,17 +837,3 @@ void AVFMediaPlayerSession::processMediaLoadError()
|
|||||||
Q_EMIT mediaStatusChanged(m_mediaStatus = QMediaPlayer::InvalidMedia);
|
Q_EMIT mediaStatusChanged(m_mediaStatus = QMediaPlayer::InvalidMedia);
|
||||||
Q_EMIT stateChanged(m_state = QMediaPlayer::StoppedState);
|
Q_EMIT stateChanged(m_state = QMediaPlayer::StoppedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVFMediaPlayerSession::processCurrentItemChanged()
|
|
||||||
{
|
|
||||||
#ifdef QT_DEBUG_AVF
|
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AVPlayerLayer *playerLayer = [(AVFMediaPlayerSessionObserver*)m_observer playerLayer];
|
|
||||||
|
|
||||||
if (m_videoOutput && m_state != QMediaPlayer::StoppedState) {
|
|
||||||
m_videoOutput->setLayer(playerLayer);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user