DirectShow: fix media seeking while stopped.
When changing the position of a media player while stopped, playback was automatically resuming. We now cache the value and actually set the position only when starting playback. Task-number: QTBUG-38068 Change-Id: Ib35302e01967d70350125f9ad920551df2a3c25b Reviewed-by: Christian Stromme <christian.stromme@digia.com>
This commit is contained in:
committed by
The Qt Project
parent
d3ba2d6f3f
commit
bfccbcfc4e
@@ -83,6 +83,7 @@ DirectShowPlayerControl::DirectShowPlayerControl(DirectShowPlayerService *servic
|
||||
, m_streamTypes(0)
|
||||
, m_muteVolume(-1)
|
||||
, m_position(0)
|
||||
, m_pendingPosition(-1)
|
||||
, m_duration(0)
|
||||
, m_playbackRate(0)
|
||||
, m_seekable(false)
|
||||
@@ -112,12 +113,22 @@ qint64 DirectShowPlayerControl::duration() const
|
||||
|
||||
qint64 DirectShowPlayerControl::position() const
|
||||
{
|
||||
if (m_pendingPosition != -1)
|
||||
return m_pendingPosition;
|
||||
|
||||
return const_cast<qint64 &>(m_position) = m_service->position();
|
||||
}
|
||||
|
||||
void DirectShowPlayerControl::setPosition(qint64 position)
|
||||
{
|
||||
if (m_state == QMediaPlayer::StoppedState && m_pendingPosition != position) {
|
||||
m_pendingPosition = position;
|
||||
emit positionChanged(m_pendingPosition);
|
||||
return;
|
||||
}
|
||||
|
||||
m_service->seek(position);
|
||||
m_pendingPosition = -1;
|
||||
}
|
||||
|
||||
int DirectShowPlayerControl::volume() const
|
||||
@@ -253,6 +264,8 @@ void DirectShowPlayerControl::play()
|
||||
return;
|
||||
}
|
||||
m_service->play();
|
||||
if (m_pendingPosition != -1)
|
||||
setPosition(m_pendingPosition);
|
||||
emit stateChanged(m_state = QMediaPlayer::PlayingState);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,7 @@ private:
|
||||
int m_streamTypes;
|
||||
int m_muteVolume;
|
||||
qint64 m_position;
|
||||
qint64 m_pendingPosition;
|
||||
qint64 m_duration;
|
||||
qreal m_playbackRate;
|
||||
bool m_seekable;
|
||||
|
||||
Reference in New Issue
Block a user