-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cast): add customizable google cast button and native launcher #85
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?
Conversation
Coverage Report
File Coverage
|
|
f6db814
to
f93cffd
Compare
89c2811
to
c0ca45c
Compare
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.
Thanks for the PR and the work done, I've a few general comments:
- there is indentation edits that don't affect behavior but make the diff harder to review and clutter history
- could you create a separate PR for the
svg-button
to keep reviews atomic - deviation from original idea:
import "./scss/google-cast-sender.scss";
import "./src/google-cast-sender.js";
window.player = pillarbox("player", {
plugins: {
googleCastSender: true
},
});
For the destructred objects in the For the SCSS file the the
Sure, I'll have to put this in hold though since it needs those changes.
I didn't understand it like that but I like the idea, however it would come at the cost of the integrators not being able to tree shake the launcher off the final build even if they decide to use the customisable button. It is also possible to do this without reintroducing the flag if we want to, so that the button import substitute the launcher automatically. |
c0ca45c
to
8ce5354
Compare
On hold until #97 is merged. |
8ce5354
to
6dfbe21
Compare
Resolves #75 by introducing two new components: - `GoogleCastButton`: a customizable Cast button based on SvgButton, allowing developers to integrate with their own visual identity. The icon can be customized via `icon` or `iconName`. - `GoogleCastLauncher`: a wrapper around the native `<google-cast-launcher>` element for a plug-and-play experience. The enableDefaultCastButton option has been renamed enableDefaultCastLauncher.
- Utilized the Video.js plugin state API to monitor session state changes in the `google-cast-sender` plugin. See: https://videojs.com/guides/plugins/#statefulness - Added a `statechanged` listener to the customizable `GoogleCastButton` to reflect session state using default active and idle SVGs. - Enabled configuration of both active and idle SVGs via the button options.
…ogle-cast-button - Added `endSessionOnClick` to the `GoogleCastButton` options to allow terminating the session without showing the session context menu. Default is `false`.
6dfbe21
to
aeca0ac
Compare
```javascript | ||
import videojs from 'video.js'; | ||
import '@srgssr/google-cast-sender'; | ||
import '@srgssr/google-cast-sender/launcher'; |
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.
oversight ?
* Dispose of the GoogleCastButton instance. | ||
*/ | ||
dispose() { | ||
this.googleCastSender().off('statechanged', this.onPlaylistStateChanged_); |
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.
wrong copy-tomato-sauce-pasta ?
this.options().endSessionOnClick && | ||
this.player().hasClass('vjs-chromecast-connected') | ||
) { | ||
this.player().googleCastSender().endCurrentSession(); |
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.
why not using googleCastSender
since it's defined above?
idleIcon: { | ||
iconName: 'google-cast', | ||
icon: googleCastIconIdle | ||
}, |
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.
In retrospective, I find the semantics strange. We are in the context of an icon, but we repeat icon in that same context. Why not something like :
idleIcon: {
name: 'google-cast-active',
src: googleCastIconActive
}
Also is it really an icon or a button? I should have noticed this in:
pillarbox-web-suite/packages/svg-button/src/svg-button.js
Lines 36 to 37 in bb08391
* @param {Object | undefined} options Configuration options for the button. | |
* @param {SVGElement|string|URL} [options.icon] An optional icon to be loaded into the button. |
googleCastButton: { | ||
idleIcon: { | ||
icon: idleIcon, | ||
iconName: 'custom-idle' | ||
}, | ||
activeIcon: { | ||
icon: activeIcon, | ||
iconName: 'custom-active' | ||
} | ||
} | ||
}, |
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.
shouldn't you register it into the control bar like this?
controlBarChildren.splice(controlBarChildren.length - 1, 0, 'googleCastButton');
"test": "vitest run --silent --coverage --coverage.reporter text" | ||
}, | ||
"dependencies": { | ||
"@srgssr/svg-button": "^1.0.0" |
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 be 1.1.0
Description
Resolves #75 by introducing two new components:
GoogleCastButton
: a customizable Cast button based on SvgButton, allowing developers to integrate with their own visual identity. The icon can be customized viaidleIcon
andactiveIcon
options.GoogleCastLauncher
: a wrapper around the native<google-cast-launcher>
element for a plug-and-play experience (the default component).Changes Made
enableDefaultCastButton
option has been renamedenableDefaultCastLauncher
.google-cast-sender
plugin. See: https://videojs.com/guides/plugins/#statefulnessstatechanged
listener to the customizableGoogleCastButton
to reflect session state using default active and idle SVGs.endSessionOnClick
to theGoogleCastButton
options to allow terminating the session without showing the session context menu. Default isfalse
.Checklist