WMF: fixed various media player issues.
- Switch to BufferedMedia only once playback actually started, not when requesting to start. - Report the position to have changed when seeking in stopped state. Change-Id: I930b3e6977cebe5935ed033d0a4d4e1eb899ad2c Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
cbe9fc8e4d
commit
99bebdbb7d
@@ -1323,14 +1323,8 @@ void MFPlayerSession::stop(bool immediate)
|
|||||||
|
|
||||||
void MFPlayerSession::start()
|
void MFPlayerSession::start()
|
||||||
{
|
{
|
||||||
switch (m_status) {
|
if (m_status == QMediaPlayer::EndOfMedia)
|
||||||
case QMediaPlayer::EndOfMedia:
|
m_varStart.hVal.QuadPart = 0; // restart from the beginning
|
||||||
m_varStart.hVal.QuadPart = 0;
|
|
||||||
//since it must be loaded already, just fallthrough
|
|
||||||
case QMediaPlayer::LoadedMedia:
|
|
||||||
changeStatus(QMediaPlayer::BufferedMedia);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG_MEDIAFOUNDATION
|
#ifdef DEBUG_MEDIAFOUNDATION
|
||||||
qDebug() << "start";
|
qDebug() << "start";
|
||||||
@@ -1464,6 +1458,9 @@ void MFPlayerSession::setPositionInternal(qint64 position, Command requestCmd)
|
|||||||
if (m_state.command == CmdStop && requestCmd != CmdSeekResume) {
|
if (m_state.command == CmdStop && requestCmd != CmdSeekResume) {
|
||||||
m_varStart.vt = VT_I8;
|
m_varStart.vt = VT_I8;
|
||||||
m_varStart.hVal.QuadPart = LONGLONG(position * 10000);
|
m_varStart.hVal.QuadPart = LONGLONG(position * 10000);
|
||||||
|
// Even though the position is not actually set on the session yet,
|
||||||
|
// report it to have changed anyway for UI controls to be updated
|
||||||
|
emit positionChanged(this->position());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1563,6 +1560,8 @@ void MFPlayerSession::commitRateChange(qreal rate, BOOL isThin)
|
|||||||
m_presentationClock->GetCorrelatedTime(0, &hnsClockTime, &hnsSystemTime);
|
m_presentationClock->GetCorrelatedTime(0, &hnsClockTime, &hnsSystemTime);
|
||||||
Q_ASSERT(hnsSystemTime != 0);
|
Q_ASSERT(hnsSystemTime != 0);
|
||||||
|
|
||||||
|
m_request.setCommand(rate < 0 || m_state.rate < 0 ? CmdSeekResume : CmdStart);
|
||||||
|
|
||||||
// We need to stop only when dealing with negative rates
|
// We need to stop only when dealing with negative rates
|
||||||
if (rate >= 0 && m_state.rate >= 0)
|
if (rate >= 0 && m_state.rate >= 0)
|
||||||
pause();
|
pause();
|
||||||
@@ -1571,7 +1570,6 @@ void MFPlayerSession::commitRateChange(qreal rate, BOOL isThin)
|
|||||||
|
|
||||||
// If we deal with negative rates, we stopped the session and consequently
|
// If we deal with negative rates, we stopped the session and consequently
|
||||||
// reset the position to zero. We then need to resume to the current position.
|
// reset the position to zero. We then need to resume to the current position.
|
||||||
m_request.setCommand(rate < 0 || m_state.rate < 0 ? CmdSeekResume : CmdStart);
|
|
||||||
m_request.start = hnsClockTime / 10000;
|
m_request.start = hnsClockTime / 10000;
|
||||||
} else if (cmdNow == CmdPause) {
|
} else if (cmdNow == CmdPause) {
|
||||||
if (rate < 0 || m_state.rate < 0) {
|
if (rate < 0 || m_state.rate < 0) {
|
||||||
@@ -1606,10 +1604,11 @@ void MFPlayerSession::commitRateChange(qreal rate, BOOL isThin)
|
|||||||
// Changing rate from negative to zero requires to stop the session
|
// Changing rate from negative to zero requires to stop the session
|
||||||
m_presentationClock->GetCorrelatedTime(0, &hnsClockTime, &hnsSystemTime);
|
m_presentationClock->GetCorrelatedTime(0, &hnsClockTime, &hnsSystemTime);
|
||||||
|
|
||||||
|
m_request.setCommand(CmdSeekResume);
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
// Resumte to the current position (stop() will reset the position to 0)
|
// Resume to the current position (stop() will reset the position to 0)
|
||||||
m_request.setCommand(CmdSeekResume);
|
|
||||||
m_request.start = hnsClockTime / 10000;
|
m_request.start = hnsClockTime / 10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1837,6 +1836,12 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
|
|||||||
updatePendingCommands(CmdStart);
|
updatePendingCommands(CmdStart);
|
||||||
break;
|
break;
|
||||||
case MESessionStarted:
|
case MESessionStarted:
|
||||||
|
if (m_status == QMediaPlayer::EndOfMedia
|
||||||
|
|| m_status == QMediaPlayer::LoadedMedia) {
|
||||||
|
// If the session started, then enough data is buffered to play
|
||||||
|
changeStatus(QMediaPlayer::BufferedMedia);
|
||||||
|
}
|
||||||
|
|
||||||
updatePendingCommands(CmdStart);
|
updatePendingCommands(CmdStart);
|
||||||
#ifndef Q_WS_SIMULATOR
|
#ifndef Q_WS_SIMULATOR
|
||||||
// playback started, we can now set again the procAmpValues if they have been
|
// playback started, we can now set again the procAmpValues if they have been
|
||||||
@@ -1852,8 +1857,8 @@ void MFPlayerSession::handleSessionEvent(IMFMediaEvent *sessionEvent)
|
|||||||
m_varStart.hVal.QuadPart = 0;
|
m_varStart.hVal.QuadPart = 0;
|
||||||
|
|
||||||
// Reset to Loaded status unless we are loading a new media
|
// Reset to Loaded status unless we are loading a new media
|
||||||
// or if the media is buffered (to avoid restarting the video surface)
|
// or changing the playback rate to negative values (stop required)
|
||||||
if (m_status != QMediaPlayer::LoadingMedia && m_status != QMediaPlayer::BufferedMedia)
|
if (m_status != QMediaPlayer::LoadingMedia && m_request.command != CmdSeekResume)
|
||||||
changeStatus(QMediaPlayer::LoadedMedia);
|
changeStatus(QMediaPlayer::LoadedMedia);
|
||||||
}
|
}
|
||||||
updatePendingCommands(CmdStop);
|
updatePendingCommands(CmdStop);
|
||||||
|
|||||||
Reference in New Issue
Block a user