mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Expose current position for XMP
This commit is contained in:
parent
398c137c1a
commit
f7787e45ec
5 changed files with 19 additions and 0 deletions
|
|
@ -260,6 +260,8 @@ public:
|
|||
return ogg_inst_->position_seconds();
|
||||
if (gme_inst_)
|
||||
return gme_inst_->position_seconds();
|
||||
if (xmp_inst_)
|
||||
return xmp_inst_->position_seconds();
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,6 +116,16 @@ float Xmp<C>::duration_seconds() const {
|
|||
return static_cast<float>(info.total_time) / 1000.f;
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
float Xmp<C>::position_seconds() const {
|
||||
SRB2_ASSERT(instance_ != nullptr);
|
||||
SRB2_ASSERT(module_loaded_ == true);
|
||||
|
||||
xmp_frame_info info;
|
||||
xmp_get_frame_info(instance_, &info);
|
||||
return static_cast<float>(info.time) / 1000.f;
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
void Xmp<C>::seek(int position_ms) {
|
||||
SRB2_ASSERT(instance_ != nullptr);
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public:
|
|||
void looping(bool looping) { looping_ = looping; };
|
||||
void reset();
|
||||
float duration_seconds() const;
|
||||
float position_seconds() const;
|
||||
void seek(int position_ms);
|
||||
|
||||
~Xmp();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,11 @@ float XmpPlayer<C>::duration_seconds() const {
|
|||
return xmp_.duration_seconds();
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
float XmpPlayer<C>::position_seconds() const {
|
||||
return xmp_.position_seconds();
|
||||
}
|
||||
|
||||
template <size_t C>
|
||||
void XmpPlayer<C>::seek(float position_seconds) {
|
||||
xmp_.seek(static_cast<int>(std::round(position_seconds * 1000.f)));
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
void looping(bool looping) { xmp_.looping(looping); }
|
||||
void reset() { xmp_.reset(); }
|
||||
float duration_seconds() const;
|
||||
float position_seconds() const;
|
||||
void seek(float position_seconds);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue