-
Notifications
You must be signed in to change notification settings - Fork 11
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
Issue #10 - Web component #16
Merged
englishm
merged 25 commits into
englishm:main
from
santipuppoQualabs:feature/web-component
Jan 16, 2025
Merged
Issue #10 - Web component #16
englishm
merged 25 commits into
englishm:main
from
santipuppoQualabs:feature/web-component
Jan 16, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…is commit should be reverted before merging.
…diaElement naming
…them to dom if no attribute is present. Added mute attribute like in <video> tag
… namespace and fingerprint as attributes or have them included as query params in the src attribute
… present as an attirubte. Also renamed variables to #element
…atch tsx. Style tbd
e68f284
to
18d9328
Compare
…ponent with controls) and new usage examples
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR to add the player as a Web Component as per Issue #10.
I haven't done web components before, all feedback is appreciated!
The main focus of the PR are the following files:
lib/video-moq/index.ts
: Containing all code related to the custom component.lib/video-moq/examples/*.html
: Containing two simple examples of how to use the custom component.lib/video-moq/video-moq.css
: Contains css for the web component based off the original tailwind css.lib/playback/index.ts
andweb/src/components/watch.tsx
Work done in this PR:
As of the video-moq.ts, the code is quite simple, but a bit verbose.
connectedCallback
is in charge of attribute processing for now, but I intend to move this to its own private function so it can also be called from attributeChangedCallback (not yet implemented). It also is in charge of adding the event listeners to the different controls (only if attribute controls is present).As of now we support
src
,fingerprint
,controls
,namespace
,width
,height
,aspect-ratio
attributes.This function also initializes the player.
disconnectedCallback
is in charge of cleanup of the stuff done in connectedCallback. i.e. removing listeners and closing the player.toggleShowControls
,togglePlayPause
,toggleMute
,toggleShowTracks
,switchTrack
andparseDimension
.video-moq.css
. This was done by copying the css from devtools on the watch.tsx example. I tried to maintain the names of the classes in case using tailwind here is ok, but for some stuff I wasn't getting to work I did make some changes. Mainly:bg-{color}/number
->bg-{color}-{number}
.play()
,pause()
,src
,muted
,controls
play()
,pause()
,togglePlayPause()
functions andmuted
,videoTrackName
attributes. (Renamed oldplay()
intotogglePlayPause()
and fixed references).customElements.define("video-moq", VideoMoq)
;Future work:
autoplay
,muted
,poster
.lib/video-moq/examples/advanced.html
):