-
-
Notifications
You must be signed in to change notification settings - Fork 24
Add setSource method #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add setSource method #153
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -477,6 +477,15 @@ export default class Player { | |
| this.methodSeekTo(newTime) | ||
| } | ||
|
|
||
| /** | ||
| * Set the media source | ||
| * @param source New media source URL | ||
| */ | ||
| setSource(source: string) { | ||
|
||
| this.media.src = source | ||
| this.media.load() | ||
| } | ||
|
|
||
| /** | ||
| * Request the fullscreen | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be added a mention to specify that it is only available for HTML5 video (and audio?)
You can get inspiration from similar examples in the README
https://github.com/vlitejs/vlite/blob/main/README.md?plain=1#L266-L270
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be implemented also for other non-HTML5 providers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've check and other providers have method to dynamically change the video source. Good news! And I prefer have common use case between providers.
loadVideoById()loadContent()loadVideo()The change can finally be in
Playerclass but the same method needs to work with all providers. You can inspired from other method for the logic. Their method seems to not be a Promise.The commun parameter seems to be
videoIdwhich contains the new video ID.Example of implementation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
videoIdparameter name is okay for Youtube, Vimeo and Dailymotion but not for HTML5 which have a video url. Needs to adapt