-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Only return the casting button when there are devices to cast to. #180
Only return the casting button when there are devices to cast to. #180
Conversation
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.
The casting button would not be removed when cast devices are not available anymore sadly.
I believe we should have a displayCastState()
function that would simply toggle cast button visibility when CAST_STATE_CHANGED
event is fired. WDYT?
@beaufortfrancois Right. I wasn't sure if dynamically removing the cast button from the once established UI without indicating what's happened would be a good solution from the UX perspective. But I guess with casting it's a relatively common pattern for the button to only appear when cast targets are available. Updated in 7cdfcdd. Would that work? |
src/index.js
Outdated
|
||
castButton.setAttribute('aria-label', 'Cast this video'); | ||
castButton.appendChild(castCustomElement); | ||
castButton.classList.add(CAST_BUTTON_HIDDEN_CLASSNAME); |
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.
This line is not needed as castButton
will only be added to the document once promise is resolved right?
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.
@beaufortfrancois The button is added to the document as soon as the Google Cast API becomes available after the recent changes – regardless of whether cast devices are available or not.
The button visibility (controlled using the class name) then depends on cast state changes.
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.
My understanding is that applyCastState()
is called just before resolve(castButton)
. As applyCastState()
controls the button visibility, the fist castButton.classList.add(CAST_BUTTON_HIDDEN_CLASSNAME);
would not shown to the user.
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.
Quite right. 🤦♂️
Thank you. Removed in 3cc1ef6.
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.
Thank you for working on this!
Summary
Only resolve the cast button promise when cast receiver devices are detected.
Fixes #179