Skip to content

Commit

Permalink
Merge branch 'master' of github.com:react-native-video/react-native-v…
Browse files Browse the repository at this point in the history
…ideo into feat/addAnalyticsPlugManagement

# Conflicts:
#	examples/basic/ios/Podfile.lock
#	examples/basic/ios/videoplayer.xcodeproj/project.pbxproj
#	examples/basic/tsconfig.json
  • Loading branch information
freeboub committed Jun 21, 2024
2 parents 0e62c5a + c1c7a05 commit 9ee8ea0
Show file tree
Hide file tree
Showing 22 changed files with 3,525 additions and 514 deletions.
8 changes: 4 additions & 4 deletions android/src/main/java/com/brentvatne/common/api/Source.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Source {
/** http header list */
val headers: MutableMap<String, String> = HashMap()

/** enable chunckless preparation for HLS
/** enable chunkless preparation for HLS
* see:
*/
var textTracksAllowChuncklessPreparation: Boolean = false
var textTracksAllowChunklessPreparation: Boolean = false

override fun hashCode(): Int = Objects.hash(uriString, uri, startPositionMs, cropStartMs, cropEndMs, extension, metadata, headers)

Expand Down Expand Up @@ -123,7 +123,7 @@ class Source {
private const val PROP_SRC_TYPE = "type"
private const val PROP_SRC_METADATA = "metadata"
private const val PROP_SRC_HEADERS = "requestHeaders"
private const val PROP_SRC_TEXT_TRACKS_ALLOW_CHUNCKLESS_PREPARATION = "textTracksAllowChunklessPreparation"
private const val PROP_SRC_TEXT_TRACKS_ALLOW_CHUNKLESS_PREPARATION = "textTracksAllowChunklessPreparation"

@SuppressLint("DiscouragedApi")
private fun getUriFromAssetId(context: Context, uriString: String): Uri? {
Expand Down Expand Up @@ -180,7 +180,7 @@ class Source {
source.cropStartMs = safeGetInt(src, PROP_SRC_CROP_START, -1)
source.cropEndMs = safeGetInt(src, PROP_SRC_CROP_END, -1)
source.extension = safeGetString(src, PROP_SRC_TYPE, null)
source.textTracksAllowChuncklessPreparation = safeGetBool(src, PROP_SRC_TEXT_TRACKS_ALLOW_CHUNCKLESS_PREPARATION, true)
source.textTracksAllowChunklessPreparation = safeGetBool(src, PROP_SRC_TEXT_TRACKS_ALLOW_CHUNKLESS_PREPARATION, true)

val propSrcHeadersArray = safeGetArray(src, PROP_SRC_HEADERS)
if (propSrcHeadersArray != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ private MediaSource buildMediaSource(Uri uri, String overrideExtension, DrmSessi

mediaSourceFactory = new HlsMediaSource.Factory(
mediaDataSourceFactory
).setAllowChunklessPreparation(source.getTextTracksAllowChuncklessPreparation());
).setAllowChunklessPreparation(source.getTextTracksAllowChunklessPreparation());
break;
case CONTENT_TYPE_OTHER:
if ("asset".equals(uri.getScheme())) {
Expand Down Expand Up @@ -1178,12 +1178,16 @@ private OnAudioFocusChangedListener(ReactExoplayerView view, ThemedReactContext

@Override
public void onAudioFocusChange(int focusChange) {
Activity activity = themedReactContext.getCurrentActivity();

switch (focusChange) {
case AudioManager.AUDIOFOCUS_LOSS:
view.hasAudioFocus = false;
view.eventEmitter.audioFocusChanged(false);
// FIXME this pause can cause issue if content doesn't have pause capability (can happen on live channel)
view.pausePlayback();
if (activity != null) {
activity.runOnUiThread(view::pausePlayback);
}
view.audioManager.abandonAudioFocus(this);
break;
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:
Expand All @@ -1197,7 +1201,6 @@ public void onAudioFocusChange(int focusChange) {
break;
}

Activity activity = themedReactContext.getCurrentActivity();
if (view.player != null && activity != null) {
if (focusChange == AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK) {
// Lower the volume
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ buildscript {
}
```

See [sample app](https://github.com/TheWidlarzGroup/react-native-videoo/blob/9c669a2d8a53df36773fd82ff0917280d0659bc7/examples/basic/android/build.gradle#L14C5-L14C5)
See [sample app](https://github.com/TheWidlarzGroup/react-native-video/blob/9c669a2d8a53df36773fd82ff0917280d0659bc7/examples/basic/android/build.gradle#L14C5-L14C5)

</details>
<details>
Expand Down
5 changes: 5 additions & 0 deletions examples/basic/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ buck-out/
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Expo
.expo
dist/
web-build/
5 changes: 5 additions & 0 deletions examples/basic/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
//
// Added by install-expo-modules
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.videoplayer
import expo.modules.ReactActivityDelegateWrapper

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
Expand All @@ -18,5 +19,5 @@ class MainActivity : ReactActivity() {
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled))
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.videoplayer
import android.content.res.Configuration
import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ReactNativeHostWrapper

import android.app.Application
import com.facebook.react.PackageList
Expand All @@ -16,7 +19,7 @@ import com.videopluginsample.VideoPluginSamplePackage
class MainApplication : Application(), ReactApplication {

override val reactNativeHost: ReactNativeHost =
object : DefaultReactNativeHost(this) {
ReactNativeHostWrapper(this, object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
Expand All @@ -31,10 +34,10 @@ class MainApplication : Application(), ReactApplication {

override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
}
})

override val reactHost: ReactHost
get() = getDefaultReactHost(applicationContext, reactNativeHost)
get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)

override fun onCreate() {
super.onCreate()
Expand All @@ -43,5 +46,11 @@ class MainApplication : Application(), ReactApplication {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ApplicationLifecycleDispatcher.onApplicationCreate(this)
}

override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
}
}
3 changes: 3 additions & 0 deletions examples/basic/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ include ':react-native-video'
project (':react-native-video').projectDir = new File(rootProject.projectDir, '../../../android')

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")
useExpoModules()
1 change: 1 addition & 0 deletions examples/basic/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
{
alias: {
[pak.name]: path.join(__dirname, '../..', pak.source),
extensions: ['.tsx', '.ts', '.js', '.json'],
},
},
],
Expand Down
9 changes: 9 additions & 0 deletions examples/basic/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
Expand All @@ -16,6 +17,14 @@ if linkage != nil
end

target 'videoplayer' do
use_expo_modules!
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
config = use_native_modules!

use_frameworks! :linkage => :static
Expand Down
Loading

0 comments on commit 9ee8ea0

Please sign in to comment.