Skip to content

Conversation

@ronalduQualabs
Copy link
Contributor

@ronalduQualabs ronalduQualabs commented Dec 8, 2025

This PR resolves 12 also resolves 205 adds tracking of played ranges to the iframe based media elements. Played time ranges are merged if they overlap, and seeking is properly taken into account, providing an accurate representation of which parts of the video have been played.

Add this ability to:

Youtube
Vimeo

@vercel
Copy link

vercel bot commented Dec 8, 2025

@ronalduQualabs is attempting to deploy a commit to the Mux Team on Vercel.

A member of the Team first needs to authorize it.

@snyk-io
Copy link

snyk-io bot commented Dec 8, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@luwes
Copy link
Collaborator

luwes commented Dec 9, 2025

This looks good. There is an indenting and line space issue.

I think it would be good to make this a mixin utility like @heff pointed out so it could be used for other iframe video elements.

Something like
https://justinfagnani.com/2015/12/21/real-mixins-with-javascript-classes/

let MyMixin = (superclass) => class extends superclass {
  foo() {
    console.log('foo from MyMixin');
  }
};

You might have to override the dispatchEvent method to execute code before the events are fired.
Don't use Vimeo's API in this mixin but use the HTMLVideoElement API so the util can be shared with the others.

@ronalduQualabs ronalduQualabs requested a review from luwes December 10, 2025 17:14
@ronalduQualabs
Copy link
Contributor Author

ronalduQualabs commented Dec 10, 2025

@luwes It's ok if we close this one then in another issue migrate this logic into a mixin ?

@luwes luwes changed the title Add played ranges tracking to Vimeo element with overlap merging feat: Add played ranges tracking to Vimeo element Dec 18, 2025
@ronalduQualabs ronalduQualabs changed the title feat: Add played ranges tracking to Vimeo element feat: Add played ranges tracking to iframe based media elements Jan 5, 2026
Comment on lines 7 to 8
addPlayedRange(start: number, end: number): void;
readonly played: TimeRanges;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also add (onPlaybackStart, onSeeking, onSeeked, etc)

Copy link
Collaborator

@luwes luwes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would start with only supporting Vimeo and YT.
It shouldn't require that many changes to the media elements themselves.

See this comment:

You might have to override the dispatchEvent method to execute code before the events are fired.

Try not to call any specialized methods from the mixin in the child class.

@ronalduQualabs ronalduQualabs requested a review from luwes January 16, 2026 18:06
this.api.on('pause', () => {
this.#paused = true;
this.dispatchEvent(new Event('pause'));
this.#paused = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

this.api.on('ended', () => {
this.#paused = true;
this.dispatchEvent(new Event('ended'));
this.#paused = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


this.api.on('timeupdate', ({ seconds }) => {
this.#currentTime = seconds;
const currentTime = Math.round(seconds * 100) / 100;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if (!playFired) {
playFired = true;
this.dispatchEvent(new Event('play'));
this.dispatchEvent(new Event('play'));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ronalduQualabs ronalduQualabs requested a review from luwes January 21, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make played ranges tracking generic to be used beyond vimeo element [Vimeo] Not able to access HTMLMediaElement.played

3 participants