From 34b6194b51a8fc76e9a805fc2c2303258142eaf4 Mon Sep 17 00:00:00 2001 From: Raymond Jacobson Date: Thu, 2 May 2024 17:19:29 -0700 Subject: [PATCH 1/2] [QA-121] Fix chromecast support --- package-lock.json | 21 +++++++++++-------- package.json | 1 + packages/mobile/ios/Podfile.lock | 16 +++++++------- .../react-native-google-cast+4.6.2.patch | 13 ++++++++++++ .../src/components/audio/AudioPlayer.tsx | 14 +++++++++++++ .../src/components/audio/GoogleCast.tsx | 4 +++- .../now-playing-drawer/ActionsBar.tsx | 20 ++++++++---------- 7 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 packages/mobile/patches/react-native-google-cast+4.6.2.patch diff --git a/package-lock.json b/package-lock.json index 7525bb1f5f4..2b63c116cce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,8 @@ "@escape.tech/mookme": "2.4.1", "@redux-devtools/remote": "0.8.0", "@web3modal/ethers": "4.1.0", - "pg": "8.8.0" + "pg": "8.8.0", + "react-native-google-cast": "4.6.2" }, "devDependencies": { "@emotion/eslint-plugin": "11.11.0", @@ -87659,6 +87660,15 @@ "react-native": ">=0.56" } }, + "node_modules/react-native-google-cast": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/react-native-google-cast/-/react-native-google-cast-4.6.2.tgz", + "integrity": "sha512-sYXFX8U9rMCGhvJ7ayV9hAjR0JghJTzAHsnAbCZhbTNI8Nx6kvSwAifS6MBf+A8bIqBFXZJb2LzMtE/vmyOzPQ==", + "peerDependencies": { + "react": ">=15.1 || >=16.0.0", + "react-native": ">=0.40" + } + }, "node_modules/react-native-inset-shadow": { "version": "1.0.3", "license": "Unlicense", @@ -111890,6 +111900,7 @@ "dev": true }, "packages/ddex/processor": { + "name": "@audius/ddex-processor", "version": "0.0.13", "dependencies": { "@audius/sdk": "*", @@ -143116,14 +143127,6 @@ } } }, - "packages/mobile/node_modules/react-native-google-cast": { - "version": "4.6.2", - "license": "MIT", - "peerDependencies": { - "react": ">=15.1 || >=16.0.0", - "react-native": ">=0.40" - } - }, "packages/mobile/node_modules/react-native-haptic-feedback": { "version": "2.2.0", "license": "MIT", diff --git a/package.json b/package.json index 22128b7d45f..ab61748a1d6 100644 --- a/package.json +++ b/package.json @@ -106,6 +106,7 @@ "@escape.tech/mookme": "2.4.1", "@redux-devtools/remote": "0.8.0", "@web3modal/ethers": "4.1.0", + "react-native-google-cast": "4.6.2", "pg": "8.8.0" }, "overrides": { diff --git a/packages/mobile/ios/Podfile.lock b/packages/mobile/ios/Podfile.lock index e5233621b14..aa160bb9545 100644 --- a/packages/mobile/ios/Podfile.lock +++ b/packages/mobile/ios/Podfile.lock @@ -30,7 +30,7 @@ PODS: - FingerprintPro (2.3.2) - fmt (6.2.1) - glog (0.3.5) - - google-cast-sdk-dynamic-xcframework-no-bluetooth (4.8.0) + - google-cast-sdk-dynamic-xcframework-no-bluetooth (4.7.1) - hermes-engine (0.73.1): - hermes-engine/Pre-built (= 0.73.1) - hermes-engine/Pre-built (0.73.1) @@ -54,7 +54,7 @@ PODS: - lottie-ios (~> 4.3.3) - React-Core - nSure (1.3.1) - - PromisesObjC (2.3.1) + - PromisesObjC (2.4.0) - RCT-Folly (2022.05.16.00): - boost - DoubleConversion @@ -948,7 +948,7 @@ PODS: - React - react-native-google-cast/NoBluetoothArm (= 4.6.2) - react-native-google-cast/NoBluetoothArm (4.6.2): - - google-cast-sdk-dynamic-xcframework-no-bluetooth + - google-cast-sdk-dynamic-xcframework-no-bluetooth (= 4.7.1) - React - react-native-google-cast/RNGoogleCast - react-native-google-cast/RNGoogleCast (4.6.2): @@ -1301,7 +1301,7 @@ DEPENDENCIES: - react-native-document-picker (from `../node_modules/react-native-document-picker`) - react-native-fast-crypto (from `../../../node_modules/react-native-fast-crypto`) - react-native-get-random-values (from `../../../node_modules/react-native-get-random-values`) - - react-native-google-cast (from `../node_modules/react-native-google-cast`) + - react-native-google-cast (from `../../../node_modules/react-native-google-cast`) - react-native-image-picker (from `../node_modules/react-native-image-picker`) - react-native-in-app-review (from `../node_modules/react-native-in-app-review`) - "react-native-keep-awake (from `../node_modules/@sayem314/react-native-keep-awake`)" @@ -1471,7 +1471,7 @@ EXTERNAL SOURCES: react-native-get-random-values: :path: "../../../node_modules/react-native-get-random-values" react-native-google-cast: - :path: "../node_modules/react-native-google-cast" + :path: "../../../node_modules/react-native-google-cast" react-native-image-picker: :path: "../node_modules/react-native-image-picker" react-native-in-app-review: @@ -1605,7 +1605,7 @@ SPEC CHECKSUMS: FingerprintPro: c6444f5a00d1126446da664124529e754475f198 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 - google-cast-sdk-dynamic-xcframework-no-bluetooth: 09d47191ef8821d82e813e754bcf98bc61a3dbc9 + google-cast-sdk-dynamic-xcframework-no-bluetooth: 1fa9e267df3fd6f8a1c6e3345142ca5286297968 hermes-engine: 34df9d5034e90bd9bf1505e1ca198760373935af JWT: ef71dfb03e1f842081e64dc42eef0e164f35d251 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 @@ -1613,7 +1613,7 @@ SPEC CHECKSUMS: lottie-ios: 3d98679b41fa6fd6aff2352b3953dbd3df8a397e lottie-react-native: a2ae9c27c273b060b2affff2957bc0ff7fdca353 nSure: b2d7022f54c180c5afd88f9f79073841e1cfa844 - PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 + PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 RCT-Folly: 7169b2b1c44399c76a47b5deaaba715eeeb476c0 RCTRequired: 6dda55e483f75d2b43781d8ad5bd7df276a50981 RCTTypeSafety: df0f2632f4e89938b9b9f6152b5e6c66fc6e969e @@ -1643,7 +1643,7 @@ SPEC CHECKSUMS: react-native-document-picker: b4f4a23b73f864ce17965b284c0757648993805b react-native-fast-crypto: 5943c42466b86ad70be60d3a5f64bd22251e5d9e react-native-get-random-values: 384787fd76976f5aec9465aff6fa9e9129af1e74 - react-native-google-cast: 18b9b2fc518caabfa65d309409e160b3fc6d1733 + react-native-google-cast: 0a82cf63114470403e41e04ffa2b13d6448b6112 react-native-image-picker: 6c51359eca7a7df9f07e297218c25696eb9da976 react-native-in-app-review: db8bb167a5f238e7ceca5c242d6b36ce8c4404a4 react-native-keep-awake: ad1d67f617756b139536977a0bf06b27cec0714a diff --git a/packages/mobile/patches/react-native-google-cast+4.6.2.patch b/packages/mobile/patches/react-native-google-cast+4.6.2.patch new file mode 100644 index 00000000000..f05167b7445 --- /dev/null +++ b/packages/mobile/patches/react-native-google-cast+4.6.2.patch @@ -0,0 +1,13 @@ +diff --git a/node_modules/react-native-google-cast/react-native-google-cast.podspec b/node_modules/react-native-google-cast/react-native-google-cast.podspec +index d1948aa..39212a4 100644 +--- a/node_modules/react-native-google-cast/react-native-google-cast.podspec ++++ b/node_modules/react-native-google-cast/react-native-google-cast.podspec +@@ -32,7 +32,7 @@ Pod::Spec.new do |s| + + s.subspec 'NoBluetoothArm' do |ss| + ss.dependency "#{package['name']}/RNGoogleCast" +- ss.dependency 'google-cast-sdk-dynamic-xcframework-no-bluetooth' ++ ss.dependency 'google-cast-sdk-dynamic-xcframework-no-bluetooth', '4.7.1' + end + + s.subspec 'RNGoogleCast' do |ss| diff --git a/packages/mobile/src/components/audio/AudioPlayer.tsx b/packages/mobile/src/components/audio/AudioPlayer.tsx index 049ff103143..9d94303d250 100644 --- a/packages/mobile/src/components/audio/AudioPlayer.tsx +++ b/packages/mobile/src/components/audio/AudioPlayer.tsx @@ -65,6 +65,7 @@ import { OfflineDownloadStatus } from 'app/store/offline-downloads/slice' +import { CastState, useChromecast } from './GoogleCast' import { useSavePodcastProgress } from './useSavePodcastProgress' const { getUserId } = accountSelectors @@ -237,6 +238,19 @@ export const AudioPlayer = () => { }, {}) }, isEqual) + // Cast + const { castState } = useChromecast() + useEffect(() => { + if ( + castState === CastState.CONNECTED || + castState === CastState.CONNECTING + ) { + TrackPlayer.setVolume(0) + } else { + TrackPlayer.setVolume(1) + } + }, [castState]) + const dispatch = useDispatch() const isLongFormContentRef = useRef(false) diff --git a/packages/mobile/src/components/audio/GoogleCast.tsx b/packages/mobile/src/components/audio/GoogleCast.tsx index 11d565f1e0b..34e7e21dcf1 100644 --- a/packages/mobile/src/components/audio/GoogleCast.tsx +++ b/packages/mobile/src/components/audio/GoogleCast.tsx @@ -24,6 +24,8 @@ const { getCurrentTrack, getPlaying, getSeek, getCounter } = playerSelectors const { getUser } = cacheUsersSelectors +export { CastState } from 'react-native-google-cast' + export const useChromecast = () => { const dispatch = useDispatch() @@ -136,6 +138,6 @@ export const useChromecast = () => { }, [client, seek]) return { - isCasting: castState === CastState.CONNECTED + castState } } diff --git a/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx b/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx index 7c1ec1f8313..2fb1654479b 100644 --- a/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx +++ b/packages/mobile/src/components/now-playing-drawer/ActionsBar.tsx @@ -39,7 +39,6 @@ import { } from '@audius/harmony-native' import { useAirplay } from 'app/components/audio/Airplay' import { Button } from 'app/components/core' -import { useIsOfflineModeEnabled } from 'app/hooks/useIsOfflineModeEnabled' import { useFeatureFlag } from 'app/hooks/useRemoteConfig' import { useToast } from 'app/hooks/useToast' import { makeStyles } from 'app/styles' @@ -113,7 +112,6 @@ export const ActionsBar = ({ track }: ActionsBarProps) => { const accountUser = useSelector(getAccountUser) const { neutral, neutralLight6, primary } = useThemeColors() const dispatch = useDispatch() - const isOfflineModeEnabled = useIsOfflineModeEnabled() const isReachable = useSelector(getIsReachable) const { isEnabled: isNewPodcastControlsEnabled } = useFeatureFlag( FeatureFlags.PODCAST_CONTROL_UPDATES_ENABLED, @@ -269,7 +267,15 @@ export const ActionsBar = ({ track }: ActionsBarProps) => { /> ) } - return isOfflineModeEnabled && !isReachable ? ( + return isReachable ? ( + + ) : ( { style={{ transform: [{ scaleX: -1 }] }} /> - ) : ( - ) } From b76a313abcf028a540cc132c1e5128bd346a461a Mon Sep 17 00:00:00 2001 From: Raymond Jacobson Date: Thu, 2 May 2024 18:13:17 -0700 Subject: [PATCH 2/2] Clean up --- .../mobile/src/components/audio/AudioPlayer.tsx | 17 +++-------------- .../mobile/src/components/audio/GoogleCast.tsx | 11 +++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/mobile/src/components/audio/AudioPlayer.tsx b/packages/mobile/src/components/audio/AudioPlayer.tsx index 9d94303d250..240ffd6e288 100644 --- a/packages/mobile/src/components/audio/AudioPlayer.tsx +++ b/packages/mobile/src/components/audio/AudioPlayer.tsx @@ -65,7 +65,7 @@ import { OfflineDownloadStatus } from 'app/store/offline-downloads/slice' -import { CastState, useChromecast } from './GoogleCast' +import { useChromecast } from './GoogleCast' import { useSavePodcastProgress } from './useSavePodcastProgress' const { getUserId } = accountSelectors @@ -186,6 +186,8 @@ export const AudioPlayer = () => { const nftAccessSignatureMap = useSelector(getNftAccessSignatureMap) const { storageNodeSelector } = useAppContext() + useChromecast() + // Queue Things const queueIndex = useSelector(getIndex) const queueShuffle = useSelector(getShuffle) @@ -238,19 +240,6 @@ export const AudioPlayer = () => { }, {}) }, isEqual) - // Cast - const { castState } = useChromecast() - useEffect(() => { - if ( - castState === CastState.CONNECTED || - castState === CastState.CONNECTING - ) { - TrackPlayer.setVolume(0) - } else { - TrackPlayer.setVolume(1) - } - }, [castState]) - const dispatch = useDispatch() const isLongFormContentRef = useRef(false) diff --git a/packages/mobile/src/components/audio/GoogleCast.tsx b/packages/mobile/src/components/audio/GoogleCast.tsx index 34e7e21dcf1..9e02495f3de 100644 --- a/packages/mobile/src/components/audio/GoogleCast.tsx +++ b/packages/mobile/src/components/audio/GoogleCast.tsx @@ -137,6 +137,17 @@ export const useChromecast = () => { } }, [client, seek]) + useEffect(() => { + if ( + castState === CastState.CONNECTED || + castState === CastState.CONNECTING + ) { + TrackPlayer.setVolume(0) + } else { + TrackPlayer.setVolume(1) + } + }, [castState]) + return { castState }