mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
LibWeb: Begin tracking HTMLMediaElement playback positions
There are several playback positions to be tracked, depending on the state of the media element.
This commit is contained in:
parent
6b51c3c1ce
commit
3d9106b1b5
5 changed files with 195 additions and 9 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/IDAllocator.h>
|
||||
#include <AK/Time.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
|
@ -31,6 +32,9 @@ VideoTrack::VideoTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> medi
|
|||
m_playback_manager->on_video_frame = [this](auto frame) {
|
||||
if (is<HTMLVideoElement>(*m_media_element))
|
||||
verify_cast<HTMLVideoElement>(*m_media_element).set_current_frame({}, move(frame));
|
||||
|
||||
auto playback_position_ms = static_cast<double>(position().to_milliseconds());
|
||||
m_media_element->set_current_playback_position(playback_position_ms / 1000.0);
|
||||
};
|
||||
|
||||
m_playback_manager->on_decoder_error = [](auto) {
|
||||
|
@ -77,6 +81,11 @@ void VideoTrack::pause_video(Badge<HTMLVideoElement>)
|
|||
m_playback_manager->pause_playback();
|
||||
}
|
||||
|
||||
Time VideoTrack::position() const
|
||||
{
|
||||
return m_playback_manager->current_playback_time();
|
||||
}
|
||||
|
||||
Time VideoTrack::duration() const
|
||||
{
|
||||
return m_playback_manager->selected_video_track().video_data().duration;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue