Fix song continuously rewinding when seeking using keyboard arrow keys.
This commit is contained in:
parent
7bac8cb451
commit
4af4e185da
0
src/engines/enginebase.h
Executable file → Normal file
0
src/engines/enginebase.h
Executable file → Normal file
0
src/engines/gstengine.cpp
Executable file → Normal file
0
src/engines/gstengine.cpp
Executable file → Normal file
0
src/engines/gstengine.h
Executable file → Normal file
0
src/engines/gstengine.h
Executable file → Normal file
@ -77,6 +77,7 @@ GstEnginePipeline::GstEnginePipeline(GstEngine* engine)
|
||||
pipeline_is_initialised_(false),
|
||||
pipeline_is_connected_(false),
|
||||
pending_seek_nanosec_(-1),
|
||||
last_known_position_(0),
|
||||
volume_percent_(100),
|
||||
volume_modifier_(1.0),
|
||||
pipeline_(nullptr),
|
||||
@ -976,10 +977,10 @@ void GstEnginePipeline::TransitionToNext() {
|
||||
}
|
||||
|
||||
qint64 GstEnginePipeline::position() const {
|
||||
gint64 value = 0;
|
||||
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &value);
|
||||
if (pipeline_is_initialised_)
|
||||
gst_element_query_position(pipeline_, GST_FORMAT_TIME, &last_known_position_);
|
||||
|
||||
return value;
|
||||
return last_known_position_;
|
||||
}
|
||||
|
||||
qint64 GstEnginePipeline::length() const {
|
||||
@ -1033,6 +1034,7 @@ bool GstEnginePipeline::Seek(qint64 nanosec) {
|
||||
}
|
||||
|
||||
pending_seek_nanosec_ = -1;
|
||||
last_known_position_ = nanosec;
|
||||
return gst_element_seek_simple(pipeline_, GST_FORMAT_TIME,
|
||||
GST_SEEK_FLAG_FLUSH, nanosec);
|
||||
}
|
||||
|
@ -258,6 +258,13 @@ signals:
|
||||
bool pipeline_is_connected_;
|
||||
qint64 pending_seek_nanosec_;
|
||||
|
||||
// We can only use gst_element_query_position() when the pipeline is in
|
||||
// PAUSED nor PLAYING state. Whenever we get a new position (e.g. after a
|
||||
// correct call to gst_element_query_position() or after a seek), we store
|
||||
// it here so that we can use it when using gst_element_query_position() is
|
||||
// not possible.
|
||||
mutable gint64 last_known_position_;
|
||||
|
||||
int volume_percent_;
|
||||
qreal volume_modifier_;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user