Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix google cast not working #1738

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/app-harness/renative.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@
}
},
"react-native-google-cast": {
"ios": {
"disabled": true
},
"androidwear": {
"disabled": true
},
Expand Down

This file was deleted.

36 changes: 36 additions & 0 deletions packages/app-harness/src/components/CastButton/index.mobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Button, View } from 'react-native';
import { CastButton, CastContext } from 'react-native-google-cast';
import { testProps } from '../../config';
import { useLoggerContext } from '../../context';

export function CastComponent() {
const { logDebug } = useLoggerContext();
return (
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-around' }}>
<CastButton
{...testProps('app-harness-home-cast-support-button')}
style={{ width: 24, height: 24, tintColor: 'black' }}
/>
<Button
title="Load Media"
onPress={async () => {
try {
const client = (await CastContext.getSessionManager().getCurrentCastSession())?.client;
if (!client) {
logDebug(`Cast: client is "${client}"`);
return;
}
await client.loadMedia({
mediaInfo: {
contentUrl:
'https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4',
},
});
} catch (e) {
logDebug(`Cast: ${e}`);
}
}}
/>
</View>
);
}
5 changes: 4 additions & 1 deletion packages/app-harness/test/specs/e2e.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ describe('Test App Harness', () => {
await FlexnRunner.expectToBeDisplayedByText('Cast to');
await FlexnRunner.waitForDisplayedByText('OK');
await FlexnRunner.expectToBeDisplayedByText('OK');
} else if (process.env.PLATFORM === 'ios') {
await FlexnRunner.clickById('app-harness-home-cast-support-button');
await FlexnRunner.expectToBeDisplayedByText('Cast to');
} else {
await FlexnRunner.expectToHaveTextById('app-harness-home-cast-support-text', 'Not supported');
}
}
});
});
34 changes: 10 additions & 24 deletions packages/config-templates/renative.templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -2599,39 +2599,23 @@
},
"ios": {
"templateXcode": {
"appDelegateImports": [
"GoogleCast"
],
"AppDelegate_mm": {
"appDelegateImports": [
"GoogleCast/GoogleCast.h"
],
"appDelegateImports": ["GoogleCast/GoogleCast.h"],
"appDelegateMethods": {
"application": {
"didFinishLaunchingWithOptions": [
"NSString *receiverAppID = kGCKDefaultMediaReceiverApplicationID; // or @\"ABCD1234\"",
"GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID];",
"GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria];",
"[GCKCastContext setSharedInstanceWithOptions:options];"
"GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID]",
"GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria]",
"options.disableDiscoveryAutostart = {{props.DISABLE_DISCOVERY_AUTOSTART}}",
"options.startDiscoveryAfterFirstTapOnCastButton = {{props.START_DISCOVERY_AFTER_FIRST_TAP_ON_CAST_BUTTON}}",
"[GCKCastContext setSharedInstanceWithOptions:options]"
]
}
}
},
"appDelegateMethods": {
"application": {
"didFinishLaunchingWithOptions": [
"let receiverAppID = \"{{props.APPLICATION_ID}}\" // or \"ABCD1234\"",
"let criteria = GCKDiscoveryCriteria(applicationID: receiverAppID)",
"let options = GCKCastOptions(discoveryCriteria: criteria)",
"GCKCastContext.setSharedInstanceWith(options)"
]
}
},
"Info_plist": {
"NSBonjourServices": [
"_googlecast._tcp",
"_CC1AD845._googlecast._tcp"
],
"NSBonjourServices": ["_googlecast._tcp", "_CC1AD845._googlecast._tcp"],
"NSLocalNetworkUsageDescription": "${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network."
}
},
Expand All @@ -2640,7 +2624,9 @@
"podName": "react-native-google-cast/NoBluetoothArm"
},
"props": {
"APPLICATION_ID": "01234"
"APPLICATION_ID": "01234",
"DISABLE_DISCOVERY_AUTOSTART": "false",
"START_DISCOVERY_AFTER_FIRST_TAP_ON_CAST_BUTTON": "false"
},
"version": "4.8.0"
},
Expand Down
Loading