mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
@@ -655,11 +655,13 @@ void Seek::update(Source *s, float dt)
|
||||
// access media player if target source is a media source
|
||||
MediaSource *ms = dynamic_cast<MediaSource *>(s);
|
||||
if (ms != nullptr) {
|
||||
// set target position
|
||||
// get media info
|
||||
GstClockTime media_duration = ms->mediaplayer()->timeline()->duration();
|
||||
GstClockTime t = (double) media_duration * (double) target_percent_;
|
||||
if (target_time_ > 0)
|
||||
t = target_time_;
|
||||
// set target position
|
||||
GstClockTime t = target_time_;
|
||||
// set target as percent if not provided
|
||||
if (t<1)
|
||||
t = ms->mediaplayer()->timeline()->timeFromPercent(target_percent_);
|
||||
|
||||
// perform seek
|
||||
if (GST_CLOCK_TIME_IS_VALID(t) && GST_CLOCK_TIME_IS_VALID(media_duration)
|
||||
|
||||
@@ -78,7 +78,7 @@ void Timeline::reset()
|
||||
clearFading();
|
||||
}
|
||||
|
||||
bool Timeline::is_valid()
|
||||
bool Timeline::is_valid() const
|
||||
{
|
||||
return timing_.is_valid() && step_ != GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
@@ -314,6 +314,32 @@ GstClockTime Timeline::sectionsTimeAt(GstClockTime t) const
|
||||
return d;
|
||||
}
|
||||
|
||||
GstClockTime Timeline::timeFromPercent(const float p) const
|
||||
{
|
||||
if (!is_valid())
|
||||
return 0;
|
||||
|
||||
// compute time at p % of actural section duration
|
||||
GstClockTime percent = (double) p * 100000;
|
||||
GstClockTime d = (sectionsDuration() * percent ) / 100000;
|
||||
|
||||
// loop over gaps
|
||||
for (auto g = gaps_.begin(); g != gaps_.end(); ++g) {
|
||||
// gap before target?
|
||||
if ( g->begin < d ) {
|
||||
// jump over gap
|
||||
d += g->duration();
|
||||
}
|
||||
else
|
||||
// done
|
||||
break;
|
||||
}
|
||||
|
||||
// return time corresponding to p% of play duration
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
size_t Timeline::fillSectionsArrays( float* const gaps, float* const fading)
|
||||
{
|
||||
size_t arraysize = MAX_TIMELINE_ARRAY;
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
~Timeline();
|
||||
Timeline& operator = (const Timeline& b);
|
||||
|
||||
bool is_valid();
|
||||
bool is_valid() const;
|
||||
void update();
|
||||
void refresh();
|
||||
|
||||
@@ -121,6 +121,7 @@ public:
|
||||
inline TimeInterval interval() const { return timing_; }
|
||||
GstClockTime next(GstClockTime time) const;
|
||||
GstClockTime previous(GstClockTime time) const;
|
||||
GstClockTime timeFromPercent(const float p) const;
|
||||
|
||||
// Manipulation of gaps
|
||||
inline TimeIntervalSet gaps() const { return gaps_; }
|
||||
|
||||
Reference in New Issue
Block a user