Add setSource method
Fix #151
This PR contains a:
- [ ] bugfix
- [x] new feature
- [ ] code refactor
- [ ] test update
- [ ] typo fix
- [ ] metadata update
Note
To be tested and reviewed
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Updated (UTC) |
|---|---|---|---|
| vlite | Preview | Nov 18, 2025 2:51pm |
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?
Have you tested with audio and video HTML5?
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
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.
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?
The reset logic of the player should be added as event every time the source is changed by
srcattribute or bysetSourcemethod. 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 is attempting to deploy a commit to the Vlitejs Team on Vercel.
A member of the Team first needs to authorize it.
The status checks are not updating, workflow have changed. Development has been moved to another PR (#186); I am copying you in.