-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add setSource method #153
base: main
Are you sure you want to change the base?
Add setSource method #153
Changes from 2 commits
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if the method should be here, because the Player class is used by all providers with inheritance (Youtube, Dailymotion, HTML5, etc.) and this is a feature only for HTML5 video and audio. This is the first time this case has arisen I believe. This must also be documented. I will check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Video.js method is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, if this is a feature only for HTML, it can not be added but the doc should at least be updated with related use cases on how can be done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It can be added, but the player file is a bridge between all provider. If the method is for only one provider, it should be is the dedicated provider ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did a commit to move |
||
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
Player
class 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
videoId
which 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.
videoId
parameter name is okay for Youtube, Vimeo and Dailymotion but not for HTML5 which have a video url. Needs to adapt