react-cast-sender
react-cast-sender copied to clipboard
Support Cast default media receiver app ID
At this point CastProvider
does not default to using the DEFAULT_MEDIA_RECEIVER_APP_ID
included with the cast framework when initializing CastContext
via cast.framework.CastContext.getInstance().setOptions()
.
It is not possible to pass this as a prop to the component since that component is both loading the SDK chrome.cast
as well as initializing context with the receiverApplicationId
. An undefined
receiverApplicationId
will error, and chrome.cast.media
cannot be referenced by the parent of the component that loads it.
Suggested changes to CastProvider
:
const defaultId = window.chrome.cast?.media?.DEFAULT_MEDIA_RECEIVER_APP_ID;
window.cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId: receiverApplicationId || defaultId,
resumeSavedSession,
autoJoinPolicy,
language
});
documentation: https://developers.google.com/cast/docs/chrome_sender/integrate#initialization