feat: cast app id env variable, try to get session

This commit is contained in:
httpjamesm 2023-11-26 17:43:12 -05:00
parent f02c7877cd
commit 59d1d07bc3
No known key found for this signature in database
2 changed files with 23 additions and 0 deletions

View file

@ -7,6 +7,9 @@ import { t } from 'i18next';
import { getKexValue, setKexValue } from '@ente/shared/network/kexService';
import { SESSION_KEYS, getKey } from '@ente/shared/storage/sessionStorage';
import { boxSeal, toB64 } from '@ente/shared/crypto/internal/libsodium';
import { useCastSender } from '@ente/shared/hooks/useCastSender';
import { useEffect } from 'react';
import { logError } from '@ente/shared/sentry';
interface Props {
show: boolean;
@ -19,6 +22,8 @@ enum AlbumCastError {
}
export default function AlbumCastDialog(props: Props) {
const { cast } = useCastSender();
const onSubmit: SingleInputFormProps['callback'] = async (
value,
setFieldError
@ -68,6 +73,17 @@ export default function AlbumCastDialog(props: Props) {
// hey TV, we acknowlege you!
await setKexValue(encryptedPayloadForTvKexKey, encryptedPayload);
};
useEffect(() => {
if (!cast) return;
cast.framework.CastContext.getInstance()
.requestSession()
// .then(function (session) {
// // Session started successfully
// })
.catch((e) => {
logError(e, 'Failed to start cast session');
});
}, [cast]);
return (
<DialogBoxV2

View file

@ -25,6 +25,13 @@ const load = (() => {
'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1';
window.__onGCastApiAvailable = (isAvailable) => {
if (isAvailable) {
cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId:
process.env.NEXT_PUBLIC_CAST_APP_ID,
autoJoinPolicy:
chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
});
resolve({
chrome,
cast,