Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jboix
Copy link
Member

@jboix jboix commented Aug 25, 2025

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 via idleIcon and activeIcon options.
  • GoogleCastLauncher: a wrapper around the native <google-cast-launcher> element for a plug-and-play experience (the default component).

Changes Made

  • 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.
  • Added endSessionOnClick to the GoogleCastButton options to allow terminating the session without showing the session context menu. Default is false.

Checklist

  • I have followed the project's style and contribution guidelines.
  • I have performed a self-review of my own changes.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.

@jboix jboix self-assigned this Aug 25, 2025
@jboix jboix requested a review from amtins August 25, 2025 09:21
Copy link

github-actions bot commented Aug 25, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 96.86% 4659 / 4810
🔵 Statements 96.86% 4659 / 4810
🔵 Functions 94.63% 335 / 354
🔵 Branches 88.87% 551 / 620
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/google-cast-sender/src/google-cast-sender.js 98.5% 94.11% 95.65% 98.5% 169-170, 305, 309, 454-455
packages/google-cast-sender/src/components/google-cast-button.js 98.62% 94.11% 100% 98.62% 74-75
packages/google-cast-sender/src/components/google-cast-launcher.js 92.78% 62.5% 100% 92.78% 39-40, 43-44, 66-68
Generated in workflow #212 for commit aeca0ac by the Vitest Coverage Report Action

Copy link

github-actions bot commented Aug 25, 2025

PR Preview Action v1.6.2

🚀 View preview at
https://SRGSSR.github.io/pillarbox-web-suite/pr-preview/pr-85/

Built to branch gh-pages at 2025-09-17 11:51 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@jboix jboix force-pushed the feat/google-cast-button branch 2 times, most recently from f6db814 to f93cffd Compare August 27, 2025 13:30
@jboix jboix changed the title feat(cast): add customizable Google Cast button and native launcher feat(cast): add customizable google cast button and native launcher Aug 27, 2025
@jboix jboix force-pushed the feat/google-cast-button branch 2 times, most recently from 89c2811 to c0ca45c Compare August 27, 2025 13:45
Copy link
Member

@amtins amtins left a 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
  },
});

@jboix
Copy link
Member Author

jboix commented Sep 12, 2025

there is indentation edits that don't affect behavior but make the diff harder to review and clutter history

For the destructred objects in the GoogleCastSender class I've revert the changes and changed my IDE configuration so that it doesn't bother when reformatting again.

For the SCSS file the the .editorconfig has it set to 2 spaces across the project. The SCSS was using 4 (not sure why 🤷), but 2 spaces should be the default.

could you create a separate PR for the svg-button to keep reviews atomic

Sure, I'll have to put this in hold though since it needs those changes.

deviation from original idea:

import "./scss/google-cast-sender.scss";
import "./src/google-cast-sender.js";

window.player = pillarbox("player", {
  plugins: {
    googleCastSender: true
  },
});

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.

@jboix jboix force-pushed the feat/google-cast-button branch from c0ca45c to 8ce5354 Compare September 16, 2025 06:56
@jboix jboix marked this pull request as draft September 16, 2025 06:57
@jboix
Copy link
Member Author

jboix commented Sep 16, 2025

On hold until #97 is merged.

@jboix jboix force-pushed the feat/google-cast-button branch from 8ce5354 to 6dfbe21 Compare September 17, 2025 08:25
@jboix jboix marked this pull request as ready for review September 17, 2025 10:54
@jboix jboix marked this pull request as draft September 17, 2025 10:55
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`.
@jboix jboix force-pushed the feat/google-cast-button branch from 6dfbe21 to aeca0ac Compare September 17, 2025 11:50
@jboix jboix marked this pull request as ready for review September 17, 2025 11:52
```javascript
import videojs from 'video.js';
import '@srgssr/google-cast-sender';
import '@srgssr/google-cast-sender/launcher';
Copy link
Member

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_);
Copy link
Member

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();
Copy link
Member

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?

Comment on lines +153 to +156
idleIcon: {
iconName: 'google-cast',
icon: googleCastIconIdle
},
Copy link
Member

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:

* @param {Object | undefined} options Configuration options for the button.
* @param {SVGElement|string|URL} [options.icon] An optional icon to be loaded into the button.

Comment on lines +168 to +178
googleCastButton: {
idleIcon: {
icon: idleIcon,
iconName: 'custom-idle'
},
activeIcon: {
icon: activeIcon,
iconName: 'custom-active'
}
}
},
Copy link
Member

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"
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a chromecast button
2 participants