@mux/mux-react-native-player 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MuxReactNativePlayer.podspec +37 -0
- package/README.md +134 -0
- package/android/build.gradle +33 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/mux/reactnativeplayer/MuxReactNativePlayerModule.kt +135 -0
- package/android/src/main/java/com/mux/reactnativeplayer/MuxVideoRecords.kt +174 -0
- package/android/src/main/java/com/mux/reactnativeplayer/MuxVideoView.kt +452 -0
- package/android/src/main/res/layout/mux_video_player_view.xml +6 -0
- package/assets/MuxRobot_02.gif +0 -0
- package/assets/MuxRobot_02@2x.gif +0 -0
- package/assets/MuxRobot_03.gif +0 -0
- package/assets/MuxRobot_03@2x.gif +0 -0
- package/assets/MuxRobot_04.gif +0 -0
- package/assets/MuxRobot_04@2x.gif +0 -0
- package/assets/MuxRobot_05.gif +0 -0
- package/assets/MuxRobot_05@2x.gif +0 -0
- package/build/MuxVideoControls.d.ts +21 -0
- package/build/MuxVideoControls.d.ts.map +1 -0
- package/build/MuxVideoControls.js +1032 -0
- package/build/MuxVideoPlayer.d.ts +59 -0
- package/build/MuxVideoPlayer.d.ts.map +1 -0
- package/build/MuxVideoPlayer.js +265 -0
- package/build/MuxVideoView.d.ts +39 -0
- package/build/MuxVideoView.d.ts.map +1 -0
- package/build/MuxVideoView.js +254 -0
- package/build/NativeMuxVideoView.d.ts +5 -0
- package/build/NativeMuxVideoView.d.ts.map +1 -0
- package/build/NativeMuxVideoView.js +4 -0
- package/build/index.d.ts +6 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/normalizeSource.d.ts +7 -0
- package/build/normalizeSource.d.ts.map +1 -0
- package/build/normalizeSource.js +76 -0
- package/build/screenOrientation.d.ts +3 -0
- package/build/screenOrientation.d.ts.map +1 -0
- package/build/screenOrientation.js +38 -0
- package/build/types.d.ts +170 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +1 -0
- package/expo-module.config.json +13 -0
- package/ios/MuxReactNativePlayerModule.swift +139 -0
- package/ios/MuxVideoRecords.swift +212 -0
- package/ios/MuxVideoView.swift +502 -0
- package/package.json +69 -0
- package/plugin/index.d.ts +11 -0
- package/plugin/index.js +1 -0
- package/plugin/withMuxReactNativePlayer.js +203 -0
- package/src/MuxVideoControls.tsx +1772 -0
- package/src/MuxVideoPlayer.ts +338 -0
- package/src/MuxVideoView.tsx +412 -0
- package/src/NativeMuxVideoView.ts +15 -0
- package/src/index.ts +32 -0
- package/src/normalizeSource.ts +101 -0
- package/src/screenOrientation.ts +46 -0
- package/src/types.ts +228 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
const {
|
|
2
|
+
createRunOncePlugin,
|
|
3
|
+
withAndroidManifest,
|
|
4
|
+
withGradleProperties,
|
|
5
|
+
withInfoPlist,
|
|
6
|
+
withProjectBuildGradle,
|
|
7
|
+
withSettingsGradle,
|
|
8
|
+
withXcodeProject,
|
|
9
|
+
} = require('@expo/config-plugins');
|
|
10
|
+
|
|
11
|
+
const pkg = require('../package.json');
|
|
12
|
+
|
|
13
|
+
const MUX_MAVEN_URL = 'https://muxinc.jfrog.io/artifactory/default-maven-release-local';
|
|
14
|
+
const MUX_MAVEN_LINE = ` maven { url = uri("${MUX_MAVEN_URL}") }\n`;
|
|
15
|
+
const ANDROID_COMPILE_SDK = '36';
|
|
16
|
+
const KOTLIN_VERSION = '2.2.10';
|
|
17
|
+
const KSP_VERSION = '2.2.10-2.0.2';
|
|
18
|
+
const MUX_IOS_EMBED_PHASE_NAME = '[Mux] Embed Mux Player Swift frameworks';
|
|
19
|
+
|
|
20
|
+
function withMuxReactNativePlayer(config, props = {}) {
|
|
21
|
+
config = withInfoPlist(config, mod => {
|
|
22
|
+
const shouldEnableBackgroundAudio =
|
|
23
|
+
props.enableBackgroundAudio === true || props.enablePictureInPicture === true;
|
|
24
|
+
|
|
25
|
+
if (shouldEnableBackgroundAudio) {
|
|
26
|
+
const modes = new Set(mod.modResults.UIBackgroundModes || []);
|
|
27
|
+
modes.add('audio');
|
|
28
|
+
mod.modResults.UIBackgroundModes = Array.from(modes);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return mod;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
config = withXcodeProject(config, mod => {
|
|
35
|
+
addMuxIosEmbedFrameworksPhase(mod.modResults);
|
|
36
|
+
return mod;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
config = withAndroidManifest(config, mod => {
|
|
40
|
+
addAndroidPermission(mod.modResults.manifest, 'android.permission.INTERNET');
|
|
41
|
+
addAndroidPermission(mod.modResults.manifest, 'android.permission.ACCESS_NETWORK_STATE');
|
|
42
|
+
return mod;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
config = withGradleProperties(config, mod => {
|
|
46
|
+
setGradleProperty(mod.modResults, 'android.compileSdkVersion', ANDROID_COMPILE_SDK);
|
|
47
|
+
setGradleProperty(mod.modResults, 'android.suppressUnsupportedCompileSdk', ANDROID_COMPILE_SDK);
|
|
48
|
+
setGradleProperty(mod.modResults, 'kotlinVersion', KOTLIN_VERSION);
|
|
49
|
+
setGradleProperty(mod.modResults, 'kspVersion', KSP_VERSION);
|
|
50
|
+
return mod;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
config = withSettingsGradle(config, mod => {
|
|
54
|
+
mod.modResults.contents = addMuxMavenToSettingsGradle(mod.modResults.contents);
|
|
55
|
+
return mod;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
config = withProjectBuildGradle(config, mod => {
|
|
59
|
+
mod.modResults.contents = addAndroidToolchainOverrides(
|
|
60
|
+
addMuxMavenToProjectBuildGradle(mod.modResults.contents)
|
|
61
|
+
);
|
|
62
|
+
return mod;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return config;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function addMuxIosEmbedFrameworksPhase(project) {
|
|
69
|
+
const shellScriptPhases = project.hash.project.objects.PBXShellScriptBuildPhase || {};
|
|
70
|
+
const alreadyAdded = Object.values(shellScriptPhases).some(
|
|
71
|
+
phase => phase && phase.name === `"${MUX_IOS_EMBED_PHASE_NAME}"`
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (alreadyAdded) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const appTargetUuid = getIosAppTargetUuid(project);
|
|
79
|
+
|
|
80
|
+
project.addBuildPhase([], 'PBXShellScriptBuildPhase', MUX_IOS_EMBED_PHASE_NAME, appTargetUuid, {
|
|
81
|
+
inputPaths: [],
|
|
82
|
+
outputPaths: ['"$(TARGET_BUILD_DIR)/$(FRAMEWORKS_FOLDER_PATH)/MuxCore.framework"'],
|
|
83
|
+
shellPath: '/bin/sh',
|
|
84
|
+
shellScript: createMuxIosEmbedFrameworksScript(),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getIosAppTargetUuid(project) {
|
|
89
|
+
const targets = project.hash.project.objects.PBXNativeTarget || {};
|
|
90
|
+
const appTarget = Object.entries(targets).find(([, target]) => {
|
|
91
|
+
return target?.productType === '"com.apple.product-type.application"';
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return appTarget?.[0] || project.getFirstTarget().uuid;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function createMuxIosEmbedFrameworksScript() {
|
|
98
|
+
return [
|
|
99
|
+
'set -euo pipefail',
|
|
100
|
+
'',
|
|
101
|
+
'FRAMEWORK_NAME="MuxCore.framework"',
|
|
102
|
+
'DESTINATION_DIR="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"',
|
|
103
|
+
'SOURCE_FRAMEWORK="${BUILT_PRODUCTS_DIR}/${FRAMEWORK_NAME}"',
|
|
104
|
+
'',
|
|
105
|
+
'if [ ! -d "${SOURCE_FRAMEWORK}" ]; then',
|
|
106
|
+
' SOURCE_FRAMEWORK="${BUILT_PRODUCTS_DIR}/MuxReactNativePlayer/${FRAMEWORK_NAME}"',
|
|
107
|
+
'fi',
|
|
108
|
+
'',
|
|
109
|
+
'if [ ! -d "${SOURCE_FRAMEWORK}" ]; then',
|
|
110
|
+
' echo "warning: ${FRAMEWORK_NAME} was not found. Mux Player Swift may fail to load at runtime."',
|
|
111
|
+
' exit 0',
|
|
112
|
+
'fi',
|
|
113
|
+
'',
|
|
114
|
+
'mkdir -p "${DESTINATION_DIR}"',
|
|
115
|
+
'rsync -a --delete "${SOURCE_FRAMEWORK}" "${DESTINATION_DIR}/"',
|
|
116
|
+
'',
|
|
117
|
+
'if [ "${CODE_SIGNING_ALLOWED:-NO}" = "YES" ] && [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" ]; then',
|
|
118
|
+
' /usr/bin/codesign --force --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements "${DESTINATION_DIR}/${FRAMEWORK_NAME}"',
|
|
119
|
+
'fi',
|
|
120
|
+
].join('\\n');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function addAndroidPermission(manifest, permission) {
|
|
124
|
+
const usesPermission = manifest['uses-permission'] || [];
|
|
125
|
+
const alreadyAdded = usesPermission.some(item => item.$?.['android:name'] === permission);
|
|
126
|
+
|
|
127
|
+
if (!alreadyAdded) {
|
|
128
|
+
usesPermission.push({ $: { 'android:name': permission } });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
manifest['uses-permission'] = usesPermission;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function setGradleProperty(properties, key, value) {
|
|
135
|
+
const property = properties.find(item => item.type === 'property' && item.key === key);
|
|
136
|
+
if (property) {
|
|
137
|
+
property.value = value;
|
|
138
|
+
} else {
|
|
139
|
+
properties.push({ type: 'property', key, value });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function addMuxMavenToSettingsGradle(contents) {
|
|
144
|
+
if (contents.includes(MUX_MAVEN_URL)) {
|
|
145
|
+
return contents;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const dependencyRepositories = /(dependencyResolutionManagement\s*\{[\s\S]*?repositories\s*\{\n)/m;
|
|
149
|
+
if (dependencyRepositories.test(contents)) {
|
|
150
|
+
return contents.replace(dependencyRepositories, `$1${MUX_MAVEN_LINE}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return `${contents.trimEnd()}
|
|
154
|
+
|
|
155
|
+
dependencyResolutionManagement {
|
|
156
|
+
repositories {
|
|
157
|
+
${MUX_MAVEN_LINE} google()
|
|
158
|
+
mavenCentral()
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function addMuxMavenToProjectBuildGradle(contents) {
|
|
165
|
+
if (contents.includes(MUX_MAVEN_URL)) {
|
|
166
|
+
return contents;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const allProjectsRepositories = /(allprojects\s*\{[\s\S]*?repositories\s*\{\n)/m;
|
|
170
|
+
if (allProjectsRepositories.test(contents)) {
|
|
171
|
+
return contents.replace(allProjectsRepositories, `$1${MUX_MAVEN_LINE}`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return `${contents.trimEnd()}
|
|
175
|
+
|
|
176
|
+
allprojects {
|
|
177
|
+
repositories {
|
|
178
|
+
${MUX_MAVEN_LINE} }
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function addAndroidToolchainOverrides(contents) {
|
|
184
|
+
const marker = '// Added by @mux/mux-react-native-player';
|
|
185
|
+
let nextContents = contents.replace(
|
|
186
|
+
/classpath\(['"]org\.jetbrains\.kotlin:kotlin-gradle-plugin['"]\)/,
|
|
187
|
+
`classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${KOTLIN_VERSION}")`
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (nextContents.includes(marker)) {
|
|
191
|
+
return nextContents;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return `${marker}
|
|
195
|
+
ext.kotlinVersion = '${KOTLIN_VERSION}'
|
|
196
|
+
ext.kspVersion = '${KSP_VERSION}'
|
|
197
|
+
|
|
198
|
+
${nextContents}`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = createRunOncePlugin(withMuxReactNativePlayer, pkg.name, pkg.version);
|
|
202
|
+
module.exports.withMuxReactNativePlayer = withMuxReactNativePlayer;
|
|
203
|
+
module.exports.default = module.exports;
|