Skip to content

Commit

Permalink
add signal parameter AVPlayer.seekFinished(qint64)
Browse files Browse the repository at this point in the history
The position() you get in the slot is not exactly the video seek finish
timestamp, but the clock value. You must use the signal parameter. So if
audio stream seeking is not finished, the value can be very different
from video timestamp.
TODO: emit seekFinished when all streams done the seeking?
  • Loading branch information
wang-bin committed Jan 24, 2016
1 parent af0df77 commit 4851402
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
6 changes: 3 additions & 3 deletions examples/player/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void MainWindow::initPlayer()
connect(mpVolumeSlider, SIGNAL(sliderPressed()), SLOT(setVolume()));
connect(mpVolumeSlider, SIGNAL(valueChanged(int)), SLOT(setVolume()));

connect(mpPlayer, SIGNAL(seekFinished()), SLOT(onSeekFinished()));
connect(mpPlayer, SIGNAL(seekFinished(qint64)), SLOT(onSeekFinished(qint64)));
connect(mpPlayer, SIGNAL(mediaStatusChanged(QtAV::MediaStatus)), SLOT(onMediaStatusChanged()));
connect(mpPlayer, SIGNAL(bufferProgressChanged(qreal)), SLOT(onBufferProgress(qreal)));
connect(mpPlayer, SIGNAL(error(QtAV::AVError)), this, SLOT(handleError(QtAV::AVError)));
Expand All @@ -194,9 +194,9 @@ void MainWindow::initPlayer()
emit ready(); //emit this signal after connection. otherwise the slots may not be called for the first time
}

void MainWindow::onSeekFinished()
void MainWindow::onSeekFinished(qint64 pos)
{
qDebug("seek finished at %lld", mpPlayer->position());
qDebug("seek finished at %lld/%lld", pos, mpPlayer->position());
}

void MainWindow::stopUnload()
Expand Down
2 changes: 1 addition & 1 deletion examples/player/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private slots:
void onHueChanged(int h);
void onSaturationChanged(int s);

void onSeekFinished();
void onSeekFinished(qint64 pos);
void onCaptureConfigChanged();
void onAVFilterVideoConfigChanged();
void onAVFilterAudioConfigChanged();
Expand Down
4 changes: 2 additions & 2 deletions qml/QmlAV/QmlAVPlayer.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
Copyright (C) 2013-2016 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -235,7 +235,7 @@ public Q_SLOTS:
void stopped();
void playing();
void seekableChanged();
void seekFinished();
void seekFinished(); //WARNING: position() now is not the seek finished video timestamp
void fastSeekChanged();
void bufferProgressChanged();
void videoCodecPriorityChanged();
Expand Down
4 changes: 2 additions & 2 deletions qml/QmlAVPlayer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2013-2015 Wang Bin <[email protected]>
Copyright (C) 2013-2016 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -82,7 +82,7 @@ void QmlAVPlayer::classBegin()
connect(mpPlayer, SIGNAL(stopped()), SLOT(_q_stopped()));
connect(mpPlayer, SIGNAL(positionChanged(qint64)), SIGNAL(positionChanged()));
connect(mpPlayer, SIGNAL(seekableChanged()), SIGNAL(seekableChanged()));
connect(mpPlayer, SIGNAL(seekFinished()), this, SIGNAL(seekFinished()), Qt::DirectConnection);
connect(mpPlayer, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished()), Qt::DirectConnection);
connect(mpPlayer, SIGNAL(bufferProgressChanged(qreal)), SIGNAL(bufferProgressChanged()));
connect(this, SIGNAL(channelLayoutChanged()), SLOT(applyChannelLayout()));
// direct connection to ensure volume() in slots is correct
Expand Down
2 changes: 1 addition & 1 deletion src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ void AVPlayer::updateMediaStatus(QtAV::MediaStatus status)
void AVPlayer::onSeekFinished(qint64 value)
{
d->seeking = false;
Q_EMIT seekFinished();
Q_EMIT seekFinished(value);
//d->clock->updateValue(value/1000.0);
Q_EMIT positionChanged(value);
}
Expand Down
7 changes: 6 additions & 1 deletion src/QtAV/AVPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,12 @@ public slots:
void startPositionChanged(qint64 position);
void stopPositionChanged(qint64 position);
void seekableChanged();
void seekFinished();
/*!
* \brief seekFinished
* If there is a video stream currently playing, emitted when video seek is finished. If only an audio stream is playing, emitted when audio seek is finished. The position() is the master clock value, It can be very different from video timestamp at this time.
* \param position The video or audio timestamp when seek is finished
*/
void seekFinished(qint64 position);
void positionChanged(qint64 position);
void interruptTimeoutChanged();
void interruptOnTimeoutChanged();
Expand Down

0 comments on commit 4851402

Please sign in to comment.