vlite icon indicating copy to clipboard operation
vlite copied to clipboard

Add setSource method

Open rtritto opened this issue 10 months ago • 7 comments

Fix #151

This PR contains a:

  • [ ] bugfix
  • [x] new feature
  • [ ] code refactor
  • [ ] test update
  • [ ] typo fix
  • [ ] metadata update

Note

To be tested and reviewed

rtritto avatar Feb 18 '25 16:02 rtritto

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
vlite Ready Ready Preview Nov 18, 2025 2:51pm

vercel[bot] avatar Feb 18 '25 16:02 vercel[bot]

In my test, I have the videoReference (HTMLVideoElement). Having an initial source, to change the source, I use:

videoReference.src = 'new-src.mp4'  // prefer src method over videoReference.setAttribute('src', 'new-src.mp4'); both trigger the DOM but src method also triggers a reload of the video content
videoReference.load()  // force video reload

The issue is that the player doesn't reload time (current time and time duration) and current progress bar.

https://github.com/user-attachments/assets/87977857-7774-4982-af4a-8773e2321a28

There is any method of player that I should call?

rtritto avatar Feb 19 '25 00:02 rtritto

Have you tested with audio and video HTML5?

yoriiis avatar Feb 20 '25 19:02 yoriiis

Have you tested with audio and video HTML5?

Yes, the change works also with audio: the source is updated but the player doesn't reload time (current time and time duration) and current progress bar:

https://github.com/user-attachments/assets/1f0f2310-67d8-455e-ab32-5ec4659b40bf

rtritto avatar Feb 22 '25 22:02 rtritto

the source is updated but the player doesn't reload time (current time and time duration) and current progress bar:

The action to be taken after loading the new media is not so simple. The player needs to be “reset”

  • Time updates
  • Progress bar reset
  • Poster and big play button displayed
  • Plugin sync (for example subtitle needs to be hide/reload) etc.

yoriiis avatar Feb 23 '25 17:02 yoriiis

The reset logic of the player should be added as event every time the source is changed by src attribute or by setSource method. Do you agree?

rtritto avatar Feb 23 '25 22:02 rtritto

The reset logic of the player should be added as event every time the source is changed by src attribute or by setSource method. Do you agree?

Yes. We can dispatch a new event sourcechange.

But this is only for user-specific purposes. The whole process of updating the player after changing the source should be dealt with here.

yoriiis avatar Feb 28 '25 17:02 yoriiis

@yoriiis is attempting to deploy a commit to the Vlitejs Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Nov 18 '25 14:11 vercel[bot]

The status checks are not updating, workflow have changed. Development has been moved to another PR (#186); I am copying you in.

yoriiis avatar Nov 18 '25 17:11 yoriiis