Skip to content

feat: Add support for chromecast#3

Open
judicaelandria wants to merge 3 commits intosilvermine:masterfrom
judicaelandria:mandriamahandry/add-chromecast-support
Open

feat: Add support for chromecast#3
judicaelandria wants to merge 3 commits intosilvermine:masterfrom
judicaelandria:mandriamahandry/add-chromecast-support

Conversation

@judicaelandria
Copy link
Contributor

No description provided.

@judicaelandria judicaelandria marked this pull request as draft November 10, 2025 15:41
@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch 4 times, most recently from dd83b05 to fe3ba58 Compare November 11, 2025 05:40
@judicaelandria judicaelandria changed the title feat: add chromecast support feat: Implements Chromecast functionality for Video.js with remoteplayback API Nov 11, 2025
@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch from fe3ba58 to f92a3dc Compare November 11, 2025 07:06
@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch 6 times, most recently from a91ed87 to 9bebbd8 Compare January 20, 2026 16:40
@judicaelandria judicaelandria changed the title feat: Implements Chromecast functionality for Video.js with remoteplayback API feat: Add support for chromecast Jan 20, 2026
@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch 6 times, most recently from fc8d9e3 to 7f2c9ca Compare January 27, 2026 07:27
@judicaelandria judicaelandria marked this pull request as ready for review January 27, 2026 07:29
Copy link

@kmuncie kmuncie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@judicaelandria here is a very surface level review to consider before @joshuacurtiss is back and able to give this a thorough review.

* (e.g. the Chromecast button) can respond to connect / connecting /
* disconnect transitions.
*/
private _setupEventListeners(): void {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to cleanup these listeners at some point? Should we add a dispose() method that removes these listeners, similar to how ChromecastButton handles cleanup at ChromecastButton.ts:287-291, or is that handled somewhere else?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you aimed to solve this one, I will leave this open until @joshuacurtiss has a look

private _setupDirectAPIListeners(): void {
const videoElement = getVideoElement(this._player);

if (!videoElement || !checkClientChromecastSupport()) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to handle the !checkClientChromecastSupport down on L285 instead of here?

}

if (!this._isSetup) {
throw new Error('ChromecastManager not properly initialized. Call setup first.');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Error message says "Call setup first" but there's no public setup() method - initialization happens automatically in the constructor. Suggestion: Revise to: ChromecastManager initialization failed - video element with Remote Playback support not found.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good


/* Ensure button is visible when Chromecast is available */
.vjs-chromecast-button:not(.vjs-hidden) {
display: block;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is block correct here? I see alot of out rules for buttons above setting flex?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you removed this block entirely, was it actually not needed at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we didn't need it

CHROMECAST_NOT_SUPPORTED: 'Chromecast not supported on this device',
CHROMECAST_SUPPORTED: 'Chromecast support detected',
GOOGLE_CAST_SUPPORTED: 'Google Cast API supported - full device compatibility',
GOOGLE_CAST_PREFERRED: 'Using Google Cast API for full device list',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two GOOGLE_CAST... constants are apparently never used, is that intentional?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see they were deleted.

@@ -0,0 +1,49 @@
$icon-chromecast--default: '../assets/ic_cast_white_24px.svg' !default;
$icon-chromecast--hover: '../assets/ic_cast_connected_white_24dp.png' !default;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats up with the mixed file types? SVG for normal button and then hover switches to PNG? Do we need better assets for hover?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see any changes here but I assume it will be considered further

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed @kmuncie

@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch 2 times, most recently from 6b3def0 to e45da59 Compare February 2, 2026 15:33
@joshuacurtiss
Copy link

Hi @judicaelandria, just posting this for reference; today IRL we discussed:

  • Making the logic and form of the Button and Manager classes for AirPlay and Chromecast consistent with each other.
  • Is it possible to improve the chromecast implementation to use feature detection instead of browser detection?
  • Can the main RemotePlayback class track which method (for now, either AirPlay or Chromecast) is active, so that it just calls the function from that active manager? In our discussion, we were calling this a proxy pattern, but it actually is better described by the Strategy Pattern. See here: Strategy pattern example in TypeScript.

@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch 2 times, most recently from b04ed24 to 324c77f Compare March 11, 2026 13:50
@joshuacurtiss
Copy link

joshuacurtiss commented Mar 13, 2026

@judicaelandria, thanks for your work. I tested with Android and Google TV and it works! Here are some questions that I'm not clear on when reviewing this code. Please note first I'm hoping you can just answer these to help me understand. Then we could decide which questions merit some code changes. Thank you!!

I noticed that the RemotePlaybackPlugin has a dispose method that calls this._chromecastManager.dispose(); but it doesn't make a similar call for AirPlayManager. Is this because the AirPlayManager class doesn't need one? Is its disposal approach different? Why? Which way is preferred?

I see _getActiveManager returns the manager that it detects is connected. (This is different than my Strategy Pattern suggestion, but it is light since isConnected isn't doing anything heavy.) Then it also returns one even if it is not connected. Why? Is this used in any situation?

When ChromecastManager sets this._remotePlayback = null in its dispose method, is this successfully disposing of the event handlers?

In ChromecastButton, is there a reason why you hardcoded the vjs-chromecast-casting-state instead of using the convention to store the classes in CSS_CLASSES?

The ic_cast_white_connected.svg is coded to be much larger than the other icons. Why?

When I run the tests, they fail. Should the Chromecast tests be failing? I also noticed that the tests set up a user agent string. Is that still relevant?

@judicaelandria
Copy link
Contributor Author

In ChromecastButton, is there a reason why you hardcoded the vjs-chromecast-casting-state instead of using the convention to store the classes in CSS_CLASSES?
no reason, my bad. I moved it to the css classes
for the test, its fixed now
for _getActiveManager, I just reimplemented the RemotePlaybackPlugin using Strategy pattern like suggested so we should have that issue anymore
Airplay and Chromecast should have their dispose method now since they implements Strategy interfaces, dispose method have been added

- Implement core Chromecast functionality for the plugin
The AirPlay getVideoElement function returns an HTMLVideoElementWithAirPlay type,
while Chromecast's getVideoElement returns a standard HTMLVideoElement. This type
mismatch could cause runtime errors when the functions are used interchangeably.
@judicaelandria judicaelandria force-pushed the mandriamahandry/add-chromecast-support branch from 324c77f to 4887697 Compare March 20, 2026 16:32
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.

3 participants