-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
32 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/app-harness/src/components/CastButton/index.mobile.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,10 @@ | ||
import { Button, View } from 'react-native'; | ||
import { CastButton, CastContext } from 'react-native-google-cast'; | ||
import { Text } from 'react-native'; | ||
import { testProps } from '../../config'; | ||
import { useLoggerContext } from '../../context'; | ||
|
||
export function CastComponent() { | ||
const { logDebug } = useLoggerContext(); | ||
export const CastComponent = () => { | ||
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> | ||
<Text style={{ color: 'black' }} {...testProps('app-harness-home-cast-support-text')}> | ||
Not supported | ||
</Text> | ||
); | ||
} | ||
}; |