feat(android): allow building exoplayer from source (#3932)
* feat(android): allow to build from source code * fix(android): allow to build plugin from source
This commit is contained in:
parent
91d27a6009
commit
a7d834a80a
@ -43,6 +43,7 @@ def ExoplayerDependenciesList = [
|
|||||||
"useExoplayerHls",
|
"useExoplayerHls",
|
||||||
"useExoplayerRtsp",
|
"useExoplayerRtsp",
|
||||||
]
|
]
|
||||||
|
def media3_buildFromSource = safeExtGet('buildFromMedia3Source').toBoolean() ?: false
|
||||||
|
|
||||||
def ExoplayerDependencies = ExoplayerDependenciesList.collectEntries { property ->
|
def ExoplayerDependencies = ExoplayerDependenciesList.collectEntries { property ->
|
||||||
[(property): safeExtGet(property)?.toBoolean() ?: false]
|
[(property): safeExtGet(property)?.toBoolean() ?: false]
|
||||||
@ -52,14 +53,17 @@ ExoplayerDependenciesList.each { propertyName ->
|
|||||||
def propertyValue = ExoplayerDependencies[propertyName]
|
def propertyValue = ExoplayerDependencies[propertyName]
|
||||||
println "$propertyName: $propertyValue"
|
println "$propertyName: $propertyValue"
|
||||||
}
|
}
|
||||||
|
println "buildFromSource: $media3_buildFromSource"
|
||||||
|
|
||||||
// This string is used to define build path.
|
// This string is used to define build path.
|
||||||
// As react native build output directory is react-native path of the module.
|
// As react native build output directory is react-native path of the module.
|
||||||
// We need to force a new path on each configuration change.
|
// We need to force a new path on each configuration change.
|
||||||
// If you add a new build parameter, please add the new value in this string
|
// If you add a new build parameter, please add the new value in this string
|
||||||
def configStringPath = ExoplayerDependencies.collect { property, value ->
|
def configStringPath = ExoplayerDependencies
|
||||||
property + value
|
.collect { property, value -> property + value}
|
||||||
}.join('').md5()
|
.join('')
|
||||||
|
.concat("buildFromSource:$media3_buildFromSource")
|
||||||
|
.md5()
|
||||||
|
|
||||||
if (isNewArchitectureEnabled()) {
|
if (isNewArchitectureEnabled()) {
|
||||||
apply plugin: "com.facebook.react"
|
apply plugin: "com.facebook.react"
|
||||||
@ -191,33 +195,73 @@ dependencies {
|
|||||||
implementation "androidx.activity:activity-ktx:$androidxActivity_version"
|
implementation "androidx.activity:activity-ktx:$androidxActivity_version"
|
||||||
|
|
||||||
// For media playback using ExoPlayer
|
// For media playback using ExoPlayer
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
||||||
|
}
|
||||||
|
|
||||||
if (ExoplayerDependencies["useExoplayerSmoothStreaming"]) {
|
if (ExoplayerDependencies["useExoplayerSmoothStreaming"]) {
|
||||||
// For Smooth Streaming playback support with ExoPlayer
|
// For Smooth Streaming playback support with ExoPlayer
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer-smoothstreaming"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer-smoothstreaming:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-smoothstreaming:$media3_version"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ExoplayerDependencies["useExoplayerDash"]) {
|
if (ExoplayerDependencies["useExoplayerDash"]) {
|
||||||
// For DASH playback support with ExoPlayer
|
// For DASH playback support with ExoPlayer
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer-dash"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer-dash:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-dash:$media3_version"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ExoplayerDependencies["useExoplayerHls"]) {
|
if (ExoplayerDependencies["useExoplayerHls"]) {
|
||||||
// For HLS playback support with ExoPlayer
|
// For HLS playback support with ExoPlayer
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer-hls"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-hls:$media3_version"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For RTSP playback support with ExoPlayer
|
// For RTSP playback support with ExoPlayer
|
||||||
if (ExoplayerDependencies["useExoplayerRtsp"]) {
|
if (ExoplayerDependencies["useExoplayerRtsp"]) {
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer-rtsp"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer-rtsp:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-rtsp:$media3_version"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// For ad insertion using the Interactive Media Ads SDK with ExoPlayer
|
// For ad insertion using the Interactive Media Ads SDK with ExoPlayer
|
||||||
if (ExoplayerDependencies["useExoplayerIMA"]) {
|
if (ExoplayerDependencies["useExoplayerIMA"]) {
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer-ima"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer-ima:$media3_version"
|
implementation "androidx.media3:media3-exoplayer-ima:$media3_version"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
// For loading data using the OkHttp network stack
|
||||||
|
implementation(project(":media-lib-datasource-okhttp"))
|
||||||
|
|
||||||
|
// For building media playback UIs
|
||||||
|
implementation(project(":media-lib-ui"))
|
||||||
|
|
||||||
|
// For exposing and controlling media sessions
|
||||||
|
implementation(project(":media-lib-session"))
|
||||||
|
|
||||||
|
// Common functionality for loading data
|
||||||
|
implementation(project(":media-lib-datasource"))
|
||||||
|
|
||||||
|
// Common functionality used across multiple media libraries
|
||||||
|
implementation(project(":media-lib-common"))
|
||||||
|
} else {
|
||||||
// For loading data using the OkHttp network stack
|
// For loading data using the OkHttp network stack
|
||||||
implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
|
implementation "androidx.media3:media3-datasource-okhttp:$media3_version"
|
||||||
|
|
||||||
@ -229,8 +273,9 @@ dependencies {
|
|||||||
|
|
||||||
// Common functionality for loading data
|
// Common functionality for loading data
|
||||||
implementation "androidx.media3:media3-datasource:$media3_version"
|
implementation "androidx.media3:media3-datasource:$media3_version"
|
||||||
|
|
||||||
// Common functionality used across multiple media libraries
|
// Common functionality used across multiple media libraries
|
||||||
implementation "androidx.media3:media3-common:$media3_version"
|
implementation "androidx.media3:media3-common:$media3_version"
|
||||||
|
}
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
@ -12,3 +12,4 @@ RNVideo_useExoplayerDash=true
|
|||||||
RNVideo_useExoplayerHls=true
|
RNVideo_useExoplayerHls=true
|
||||||
RNVideo_androidxCoreVersion=1.9.0
|
RNVideo_androidxCoreVersion=1.9.0
|
||||||
RNVideo_androidxActivityVersion=1.7.0
|
RNVideo_androidxActivityVersion=1.7.0
|
||||||
|
RNVideo_buildFromMedia3Source=false
|
||||||
|
@ -56,6 +56,41 @@ With these tool you should be able to analyze what is going on with network. You
|
|||||||
|
|
||||||
Then try to compare exchanges with previous tests you made.
|
Then try to compare exchanges with previous tests you made.
|
||||||
|
|
||||||
|
## Debug media3: build from media3 source
|
||||||
|
|
||||||
|
If you need to use a specific exoplayer version or patch default behavior, you may want to build from media3 source code.
|
||||||
|
|
||||||
|
Building from media3 source is possible. You need to add 2 or 3 things in your app:
|
||||||
|
|
||||||
|
### Configure player path
|
||||||
|
|
||||||
|
You need to add following lines in settings.gradle to configure your media3 source path:
|
||||||
|
|
||||||
|
```gradle
|
||||||
|
gradle.ext.androidxMediaModulePrefix = 'media-'
|
||||||
|
apply from: file("../../../../media3/core_settings.gradle")
|
||||||
|
````
|
||||||
|
|
||||||
|
Of course, you should replace with media3 source path. Be carefull, you need to use the same version (or version with compatible api) that the package support.
|
||||||
|
|
||||||
|
### Enable building from source
|
||||||
|
In your build.gradle file, add following setting:
|
||||||
|
|
||||||
|
```gradle
|
||||||
|
buildscript {
|
||||||
|
ext {
|
||||||
|
...
|
||||||
|
buildFromMedia3Source = true
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Desugaring
|
||||||
|
to be able to link you may also need to enable coreLibraryDesugaringEnabled in your app.
|
||||||
|
|
||||||
|
See: https://developer.android.com/studio/write/java8-support?hl=fr#library-desugaring for more informations.
|
||||||
|
|
||||||
## It's still not working
|
## It's still not working
|
||||||
|
|
||||||
You can try to open a ticket now !
|
You can try to open a ticket now !
|
||||||
|
@ -81,12 +81,20 @@ android {
|
|||||||
compileSdkVersion rootProject.ext.compileSdkVersion
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||||
|
|
||||||
namespace "com.videoplayer"
|
namespace "com.videoplayer"
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
// These options are necessary to be able to build fro source
|
||||||
|
coreLibraryDesugaringEnabled true
|
||||||
|
sourceCompatibility JavaVersion.VERSION_11
|
||||||
|
targetCompatibility JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.videoplayer"
|
applicationId "com.videoplayer"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
debug {
|
debug {
|
||||||
@ -147,6 +155,8 @@ dependencies {
|
|||||||
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
|
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// coreLibraryDesugaring is mandatory to be able to build exoplayer from source
|
||||||
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
|
||||||
}
|
}
|
||||||
|
|
||||||
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
||||||
|
@ -16,6 +16,9 @@ buildscript {
|
|||||||
// useExoplayerSmoothStreaming = false
|
// useExoplayerSmoothStreaming = false
|
||||||
// useExoplayerDash = false
|
// useExoplayerDash = false
|
||||||
// useExoplayerHls = false
|
// useExoplayerHls = false
|
||||||
|
|
||||||
|
// uncomment this line to be able to build from media3 source code
|
||||||
|
// buildFromMedia3Source = true
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
@ -8,6 +8,10 @@ project (':react-native-video-plugin-sample').projectDir = new File(rootProject.
|
|||||||
include ':react-native-video'
|
include ':react-native-video'
|
||||||
project (':react-native-video').projectDir = new File(rootProject.projectDir, '../../../android')
|
project (':react-native-video').projectDir = new File(rootProject.projectDir, '../../../android')
|
||||||
|
|
||||||
|
// uncomment these lines to be able to build from media3 source code
|
||||||
|
// gradle.ext.androidxMediaModulePrefix = 'media-'
|
||||||
|
// apply from: file("../../../../media3/core_settings.gradle")
|
||||||
|
|
||||||
includeBuild('../node_modules/@react-native/gradle-plugin')
|
includeBuild('../node_modules/@react-native/gradle-plugin')
|
||||||
|
|
||||||
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
|
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
|
||||||
|
@ -100,7 +100,15 @@ dependencies {
|
|||||||
//noinspection GradleDynamicVersion
|
//noinspection GradleDynamicVersion
|
||||||
implementation "com.facebook.react:react-native:+"
|
implementation "com.facebook.react:react-native:+"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
|
||||||
|
def media3_buildFromSource = safeExtGet('buildFromMedia3Source')?.toBoolean() ?: false
|
||||||
|
if (media3_buildFromSource) {
|
||||||
|
implementation(project(":media-lib-exoplayer"))
|
||||||
|
implementation(project(":media-lib-exoplayer-dash"))
|
||||||
|
} else {
|
||||||
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
implementation "androidx.media3:media3-exoplayer:$media3_version"
|
||||||
|
implementation "androidx.media3:media3-exoplayer-dash:$media3_version"
|
||||||
|
}
|
||||||
implementation project(':react-native-video')
|
implementation project(':react-native-video')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user