Bladeren bron

fix(RN): bundle sound files in release build

On Android the files will be copied to the assets/sounds directory of
the SDK bundle on build time. To play the "asset:/" prefix has to be
used to locate the files correctly.

On iOS each sound file must be added to the SDK's Xcode project in order
to be bundled correctly. To playback we need to know the path of the SDK
bundle which is now exposed by the AppInfo iOS module.
master
paweldomas 7 jaren geleden
bovenliggende
commit
8b2ce21e1a

+ 16
- 0
android/sdk/build.gradle Bestand weergeven

@@ -71,6 +71,22 @@ gradle.projectsEvaluated {
71 71
         runBefore("processUniversal${buildNameCapitalized}Resources", currentFontTask)
72 72
         runBefore("process${buildNameCapitalized}Resources", currentFontTask)
73 73
 
74
+        def currentSoundsTask = tasks.create(
75
+                name: "copy${buildNameCapitalized}Sounds",
76
+                type: Copy) {
77
+             from("${projectDir}/../../sounds/joined.wav")
78
+             from("${projectDir}/../../sounds/left.wav")
79
+             into("${bundlePath}/assets/sounds")
80
+        }
81
+
82
+        currentSoundsTask.dependsOn("merge${buildNameCapitalized}Resources")
83
+        currentSoundsTask.dependsOn("merge${buildNameCapitalized}Assets")
84
+
85
+        runBefore("processArmeabi-v7a${buildNameCapitalized}Resources", currentSoundsTask)
86
+        runBefore("processX86${buildNameCapitalized}Resources", currentSoundsTask)
87
+        runBefore("processUniversal${buildNameCapitalized}Resources", currentSoundsTask)
88
+        runBefore("process${buildNameCapitalized}Resources", currentSoundsTask)
89
+
74 90
         // Bundle JavaScript and React resources.
75 91
         // (adapted from react-native/react.gradle)
76 92
         //

+ 4
- 4
ios/Podfile.lock Bestand weergeven

@@ -43,10 +43,10 @@ PODS:
43 43
     - React/Core
44 44
     - React/fishhook
45 45
     - React/RCTBlob
46
-  - RNSound (0.10.4):
46
+  - RNSound (0.10.9):
47 47
     - React/Core
48
-    - RNSound/Core (= 0.10.4)
49
-  - RNSound/Core (0.10.4):
48
+    - RNSound/Core (= 0.10.9)
49
+  - RNSound/Core (0.10.9):
50 50
     - React/Core
51 51
   - RNVectorIcons (4.4.2):
52 52
     - React
@@ -103,7 +103,7 @@ SPEC CHECKSUMS:
103 103
   react-native-keep-awake: 0de4bd66de0c23178107dce0c2fcc3354b2a8e94
104 104
   react-native-locale-detector: d1b2c6fe5abb56e3a1efb6c2d6f308c05c4251f1
105 105
   react-native-webrtc: bc044ca9530fc802e7533f247aa08fe1b6bf8dc5
106
-  RNSound: d0818fe2435254fe30540fae48a429c5ffb72e09
106
+  RNSound: b360b3862d3118ed1c74bb9825696b5957686ac4
107 107
   RNVectorIcons: c0dbfbf6068fefa240c37b0f71bd03b45dddac44
108 108
   yoga: 17521bbb0dd54a47c0b3ac43253e78cdac7488e0
109 109
 

+ 8
- 0
ios/sdk/sdk.xcodeproj/project.pbxproj Bestand weergeven

@@ -27,6 +27,8 @@
27 27
 		0BCA496C1EC4BBF900B793EE /* jitsi.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0BCA496B1EC4BBF900B793EE /* jitsi.ttf */; };
28 28
 		0BD906EA1EC0C00300C8C18E /* JitsiMeet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BD906E81EC0C00300C8C18E /* JitsiMeet.h */; settings = {ATTRIBUTES = (Public, ); }; };
29 29
 		0F65EECE1D95DA94561BB47E /* libPods-JitsiMeet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 03F2ADC957FF109849B7FCA1 /* libPods-JitsiMeet.a */; };
30
+		75635B0A20751D6D00F29C9F /* joined.wav in Resources */ = {isa = PBXBuildFile; fileRef = 75635B0820751D6D00F29C9F /* joined.wav */; };
31
+		75635B0B20751D6D00F29C9F /* left.wav in Resources */ = {isa = PBXBuildFile; fileRef = 75635B0920751D6D00F29C9F /* left.wav */; };
30 32
 		C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5B2053091D0040BE68 /* image-resize@2x.png */; };
31 33
 		C6245F5E2053091D0040BE68 /* image-resize@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = C6245F5C2053091D0040BE68 /* image-resize@3x.png */; };
32 34
 		C6A3425F204EF76800E062DD /* PiPWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6A3425C204EF76800E062DD /* PiPWindow.swift */; };
@@ -60,6 +62,8 @@
60 62
 		0BD906E51EC0C00300C8C18E /* JitsiMeet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JitsiMeet.framework; sourceTree = BUILT_PRODUCTS_DIR; };
61 63
 		0BD906E81EC0C00300C8C18E /* JitsiMeet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JitsiMeet.h; sourceTree = "<group>"; };
62 64
 		0BD906E91EC0C00300C8C18E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
65
+		75635B0820751D6D00F29C9F /* joined.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = joined.wav; path = ../../sounds/joined.wav; sourceTree = "<group>"; };
66
+		75635B0920751D6D00F29C9F /* left.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = left.wav; path = ../../sounds/left.wav; sourceTree = "<group>"; };
63 67
 		98E09B5C73D9036B4ED252FC /* Pods-JitsiMeet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.debug.xcconfig"; sourceTree = "<group>"; };
64 68
 		9C77CA3CC919B081F1A52982 /* Pods-JitsiMeet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.release.xcconfig"; sourceTree = "<group>"; };
65 69
 		C6245F5B2053091D0040BE68 /* image-resize@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "image-resize@2x.png"; path = "src/picture-in-picture/image-resize@2x.png"; sourceTree = "<group>"; };
@@ -89,6 +93,8 @@
89 93
 		0BCA49681EC4BBE500B793EE /* Resources */ = {
90 94
 			isa = PBXGroup;
91 95
 			children = (
96
+				75635B0820751D6D00F29C9F /* joined.wav */,
97
+				75635B0920751D6D00F29C9F /* left.wav */,
92 98
 				0BC4B8681F8C01E100CE8B21 /* CallKitIcon.png */,
93 99
 				C6245F5B2053091D0040BE68 /* image-resize@2x.png */,
94 100
 				C6245F5C2053091D0040BE68 /* image-resize@3x.png */,
@@ -252,6 +258,8 @@
252 258
 				0BCA496C1EC4BBF900B793EE /* jitsi.ttf in Resources */,
253 259
 				C6245F5D2053091D0040BE68 /* image-resize@2x.png in Resources */,
254 260
 				0BC4B8691F8C03A700CE8B21 /* CallKitIcon.png in Resources */,
261
+				75635B0B20751D6D00F29C9F /* left.wav in Resources */,
262
+				75635B0A20751D6D00F29C9F /* joined.wav in Resources */,
255 263
 				C6245F5E2053091D0040BE68 /* image-resize@3x.png in Resources */,
256 264
 			);
257 265
 			runOnlyForDeploymentPostprocessing = 0;

+ 3
- 0
ios/sdk/src/AppInfo.m Bestand weergeven

@@ -45,8 +45,11 @@ RCT_EXPORT_MODULE();
45 45
         }
46 46
     }
47 47
 
48
+    NSString *sdkBundlePath = [[NSBundle bundleForClass:self.class] bundlePath];
49
+
48 50
     return @{
49 51
         @"name": name,
52
+        @"sdkBundlePath": sdkBundlePath,
50 53
         @"version": version
51 54
     };
52 55
 };

+ 3
- 3
package-lock.json Bestand weergeven

@@ -10405,9 +10405,9 @@
10405 10405
       "integrity": "sha1-QeDsKqfdjxLzo+6Dr51jxLZw+KE="
10406 10406
     },
10407 10407
     "react-native-sound": {
10408
-      "version": "0.10.4",
10409
-      "resolved": "https://registry.npmjs.org/react-native-sound/-/react-native-sound-0.10.4.tgz",
10410
-      "integrity": "sha512-V9v4CjKgv8ekQRLOJSoKA7pxJ03F4Ih3T/RfMIlMWLktz7v/O4sdJPjRBLOzZRqAnr9FWTLbSk1ZCjioXh3mjQ=="
10408
+      "version": "0.10.9",
10409
+      "resolved": "https://registry.npmjs.org/react-native-sound/-/react-native-sound-0.10.9.tgz",
10410
+      "integrity": "sha1-awCw9K/QF83gn7udFx3xtdW4Uag="
10411 10411
     },
10412 10412
     "react-native-vector-icons": {
10413 10413
       "version": "4.4.2",

+ 1
- 1
package.json Bestand weergeven

@@ -64,7 +64,7 @@
64 64
     "react-native-keep-awake": "2.0.6",
65 65
     "react-native-locale-detector": "github:jitsi/react-native-locale-detector#cc76092fc4335488a28a9529c8b50afae2c3ecdc",
66 66
     "react-native-prompt": "1.0.0",
67
-    "react-native-sound": "0.10.4",
67
+    "react-native-sound": "0.10.9",
68 68
     "react-native-vector-icons": "4.4.2",
69 69
     "react-native-webrtc": "github:jitsi/react-native-webrtc#84aee6693195c5be6b6f5f794a1e52dc7913fb3b",
70 70
     "react-redux": "5.0.6",

+ 10
- 0
react/features/app/functions.native.js Bestand weergeven

@@ -11,3 +11,13 @@ export * from './getRouteToRender';
11 11
 export function getName() {
12 12
     return NativeModules.AppInfo.name;
13 13
 }
14
+
15
+/**
16
+ * Returns the path to the Jitsi Meet SDK bundle on iOS. On Android it will be
17
+ * undefined.
18
+ *
19
+ * @returns {string|undefined}
20
+ */
21
+export function getSdkBundlePath() {
22
+    return NativeModules.AppInfo.sdkBundlePath;
23
+}

+ 1
- 1
react/features/base/media/components/native/Audio.js Bestand weergeven

@@ -44,7 +44,7 @@ export default class Audio extends AbstractAudio {
44 44
         this._sound
45 45
             = this.props.src
46 46
                 ? new Sound(
47
-                    this.props.src,
47
+                    this.props.src, null,
48 48
                     this._soundLoadedCallback.bind(this))
49 49
                 : null;
50 50
     }

+ 5
- 8
react/features/base/participants/middleware.js Bestand weergeven

@@ -34,10 +34,7 @@ import {
34 34
     getParticipantById,
35 35
     getParticipantCount
36 36
 } from './functions';
37
-import {
38
-    PARTICIPANT_JOINED_SRC,
39
-    PARTICIPANT_LEFT_SRC
40
-} from './sounds';
37
+import { PARTICIPANT_JOINED_FILE, PARTICIPANT_LEFT_FILE } from './sounds';
41 38
 
42 39
 declare var APP: Object;
43 40
 
@@ -214,9 +211,9 @@ function _maybePlaySounds({ getState, dispatch }, action) {
214 211
  */
215 212
 function _registerSounds({ dispatch }) {
216 213
     dispatch(
217
-        registerSound(PARTICIPANT_JOINED_SOUND_ID, PARTICIPANT_JOINED_SRC));
214
+        registerSound(PARTICIPANT_JOINED_SOUND_ID, PARTICIPANT_JOINED_FILE));
218 215
     dispatch(
219
-        registerSound(PARTICIPANT_LEFT_SOUND_ID, PARTICIPANT_LEFT_SRC));
216
+        registerSound(PARTICIPANT_LEFT_SOUND_ID, PARTICIPANT_LEFT_FILE));
220 217
 }
221 218
 
222 219
 /**
@@ -228,7 +225,7 @@ function _registerSounds({ dispatch }) {
228 225
  */
229 226
 function _unregisterSounds({ dispatch }) {
230 227
     dispatch(
231
-        unregisterSound(PARTICIPANT_JOINED_SOUND_ID, PARTICIPANT_JOINED_SRC));
228
+        unregisterSound(PARTICIPANT_JOINED_SOUND_ID));
232 229
     dispatch(
233
-        unregisterSound(PARTICIPANT_LEFT_SOUND_ID, PARTICIPANT_LEFT_SRC));
230
+        unregisterSound(PARTICIPANT_LEFT_SOUND_ID));
234 231
 }

+ 11
- 0
react/features/base/participants/sounds.js Bestand weergeven

@@ -0,0 +1,11 @@
1
+/**
2
+ * The name of the bundled sound file which will be played when new participant
3
+ * joins the conference.
4
+ */
5
+export const PARTICIPANT_JOINED_FILE = 'joined.wav';
6
+
7
+/**
8
+ * The name of the bundled sound file which will be played when any participant
9
+ * leaves the conference.
10
+ */
11
+export const PARTICIPANT_LEFT_FILE = 'left.wav';

+ 0
- 13
react/features/base/participants/sounds.native.js Bestand weergeven

@@ -1,13 +0,0 @@
1
-/**
2
- * Points to the sound file which will be played when new participant joins
3
- * the conference.
4
- */
5
-export const PARTICIPANT_JOINED_SRC
6
-    = require('../../../../sounds/joined.wav');
7
-
8
-/**
9
- * Points to the sound file which will be played when any participant leaves
10
- * the conference.
11
- */
12
-export const PARTICIPANT_LEFT_SRC
13
-    = require('../../../../sounds/left.wav');

+ 0
- 11
react/features/base/participants/sounds.web.js Bestand weergeven

@@ -1,11 +0,0 @@
1
-/**
2
- * Points to the sound file which will be played when new participant joins
3
- * the conference.
4
- */
5
-export const PARTICIPANT_JOINED_SRC = 'sounds/joined.wav';
6
-
7
-/**
8
- * Points to the sound file which will be played when any participant leaves
9
- * the conference.
10
- */
11
-export const PARTICIPANT_LEFT_SRC = 'sounds/left.wav';

+ 6
- 6
react/features/base/sounds/actions.js Bestand weergeven

@@ -9,6 +9,7 @@ import {
9 9
     REGISTER_SOUND,
10 10
     UNREGISTER_SOUND
11 11
 } from './actionTypes';
12
+import { getSoundsPath } from './functions';
12 13
 
13 14
 /**
14 15
  * Adds {@link AudioElement} instance to the base/sounds feature state for the
@@ -81,20 +82,19 @@ export function playSound(soundId: string): Object {
81 82
  *
82 83
  * @param {string} soundId - The global identifier which identify the sound
83 84
  * created for given source object.
84
- * @param {Object|string} src - Either path to an audio file or a raw object
85
- * which specifies the audio resource that will be associated with the given
86
- * {@code soundId}.
85
+ * @param {string} soundName - The name of bundled audio file that will be
86
+ * associated with the given {@code soundId}.
87 87
  * @returns {{
88 88
  *     type: REGISTER_SOUND,
89 89
  *     soundId: string,
90
- *     src: (Object | string)
90
+ *     src: string
91 91
  * }}
92 92
  */
93
-export function registerSound(soundId: string, src: Object | string): Object {
93
+export function registerSound(soundId: string, soundName: string): Object {
94 94
     return {
95 95
         type: REGISTER_SOUND,
96 96
         soundId,
97
-        src
97
+        src: `${getSoundsPath()}/${soundName}`
98 98
     };
99 99
 }
100 100
 

+ 9
- 0
react/features/base/sounds/functions.android.js Bestand weergeven

@@ -0,0 +1,9 @@
1
+/**
2
+ * Returns the location of the sounds. On Android sounds files are copied to
3
+ * the 'assets/sounds/' folder of the SDK bundle on build time.
4
+ *
5
+ * @returns {string}
6
+ */
7
+export function getSoundsPath() {
8
+    return 'asset:/sounds';
9
+}

+ 12
- 0
react/features/base/sounds/functions.ios.js Bestand weergeven

@@ -0,0 +1,12 @@
1
+import { getSdkBundlePath } from '../../app';
2
+
3
+/**
4
+ * Returns the location of the sounds. On iOS it's the location of the SDK
5
+ * bundle on the phone. Each sound file must be added to the SDK's XCode project
6
+ * in order to be bundled correctly.
7
+ *
8
+ * @returns {string}
9
+ */
10
+export function getSoundsPath() {
11
+    return getSdkBundlePath();
12
+}

+ 9
- 0
react/features/base/sounds/functions.web.js Bestand weergeven

@@ -0,0 +1,9 @@
1
+/**
2
+ * Returns the location of the sounds. On Web it's the relative path to
3
+ * the sounds folder placed in the source root.
4
+ *
5
+ * @returns {string}
6
+ */
7
+export function getSoundsPath() {
8
+    return 'sounds';
9
+}

+ 2
- 2
react/features/chat/middleware.js Bestand weergeven

@@ -7,7 +7,7 @@ import { MiddlewareRegistry } from '../base/redux';
7 7
 import { playSound, registerSound, unregisterSound } from '../base/sounds';
8 8
 
9 9
 import { INCOMING_MSG_SOUND_ID } from './constants';
10
-import { INCOMING_MSG_SOUND_SRC } from './sounds';
10
+import { INCOMING_MSG_SOUND_FILE } from './sounds';
11 11
 
12 12
 declare var APP: Object;
13 13
 
@@ -24,7 +24,7 @@ MiddlewareRegistry.register(store => next => action => {
24 24
         // on mobile.
25 25
         typeof APP === 'undefined'
26 26
             || store.dispatch(
27
-                registerSound(INCOMING_MSG_SOUND_ID, INCOMING_MSG_SOUND_SRC));
27
+                registerSound(INCOMING_MSG_SOUND_ID, INCOMING_MSG_SOUND_FILE));
28 28
         break;
29 29
 
30 30
     case APP_WILL_UNMOUNT:

+ 3
- 2
react/features/chat/sounds.web.js Bestand weergeven

@@ -1,6 +1,7 @@
1 1
 /**
2
- * The audio source for the incoming chat message sound.
2
+ * The name of the bundled audio file which will be played for the incoming chat
3
+ * message sound.
3 4
  *
4 5
  * @type {string}
5 6
  */
6
-export const INCOMING_MSG_SOUND_SRC = 'sounds/incomingMessage.wav';
7
+export const INCOMING_MSG_SOUND_FILE = 'incomingMessage.wav';

Laden…
Annuleren
Opslaan