Skip to content

Commit

Permalink
add AVPlayer.setTimeRange
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Mar 30, 2016
1 parent 0cc6201 commit 7fad30e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 881,16 @@ void AVPlayer::setStopPosition(qint64 pos)
Q_EMIT stopPositionChanged(d->stop_position);
}

void AVPlayer::setTimeRange(qint64 start, qint64 stop)
{
if (start > stop) {
qWarning("Invalid time range");
return;
}
setStopPosition(stop);
setStartPosition(start);
}

bool AVPlayer::isSeekable() const
{
return d->demuxer.isSeekable();
Expand Down
7 changes: 7 additions & 0 deletions src/QtAV/AVPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 441,13 @@ public slots:
* pos < 0: duration() pos
*/
void setStopPosition(qint64 pos);
/*!
* \brief setTimeRange
* Set startPosition and stopPosition. Make sure start <= stop.
* Calling setStartPosition() with a value lager than current stopPosition() will fail. setTimeRange() can avoid this.
*/
void setTimeRange(qint64 start, qint64 stop);

bool isSeekable() const;
/*!
* \brief setPosition equals to seek(qreal)
Expand Down

0 comments on commit 7fad30e

Please sign in to comment.