Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move sample to expo #3880

Merged
merged 25 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d3fc4fd
perf: ensure we do not provide callback to native if no callback prov…
freeboub May 5, 2024
e1da32d
chore: rework bufferConfig to make it more generic and reduce ReactEx…
freeboub May 6, 2024
df3da43
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 8, 2024
0f33ad1
chore: improve issue template
freeboub May 8, 2024
17f2385
Merge branch 'TheWidlarzGroup:master' into master
freeboub May 10, 2024
1066898
fix(android): avoid video view flickering at playback startup
freeboub May 10, 2024
485f867
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 11, 2024
a5e10a3
Merge branch 'master' of github.com:freeboub/react-native-video into …
freeboub May 11, 2024
9ce1d95
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 15, 2024
fa27db7
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 17, 2024
be681d3
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 21, 2024
2fadb26
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 23, 2024
92df10d
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 24, 2024
aa61388
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 28, 2024
ceafc53
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 30, 2024
d30c5f5
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub May 30, 2024
f3f8663
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub Jun 3, 2024
5f8c461
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub Jun 4, 2024
0eba6da
fix: ensure player doesn't start when view is unmounted
freeboub Jun 4, 2024
0a2c9ac
chore: move basic sample to expo
freeboub Jun 6, 2024
f89b398
Merge branch 'master' of github.com:react-native-video/react-native-v…
freeboub Jun 14, 2024
2318870
Update examples/basic/package.json
freeboub Jun 14, 2024
f3c0192
chore: use last expo version
freeboub Jun 14, 2024
ce2dec5
Merge branch 'chore/moveSampleToExpo' of github.com:freeboub/react-na…
freeboub Jun 14, 2024
2be49aa
chore: fix podfile
freeboub Jun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ public class ReactExoplayerView extends FrameLayout implements
private long lastBufferDuration = -1;
private long lastDuration = -1;

private boolean viewHasDropped = false;
private void updateProgress() {
if (player != null) {
if (playerControlView != null && isPlayingAd() && controls) {
Expand Down Expand Up @@ -375,6 +376,8 @@ protected void onDetachedFromWindow() {
public void cleanUpResources() {
stopPlayback();
themedReactContext.removeLifecycleEventListener(this);
releasePlayer();
viewHasDropped = true;
}

//BandwidthMeter.EventListener implementation
Expand Down Expand Up @@ -647,6 +650,9 @@ private void initializePlayer() {
Activity activity = themedReactContext.getCurrentActivity();
// This ensures all props have been settled, to avoid async racing conditions.
mainRunnable = () -> {
if (viewHasDropped) {
return;
}
try {
if (player == null) {
// Initialize core configuration and listeners
Expand All @@ -658,7 +664,9 @@ private void initializePlayer() {
ExecutorService es = Executors.newSingleThreadExecutor();
es.execute(() -> {
// DRM initialization must run on a different thread

if (viewHasDropped) {
return;
}
if (activity == null) {
DebugLog.e(TAG, "Failed to initialize Player!, null activity");
eventEmitter.error("Failed to initialize Player!", new Exception("Current Activity is null!"), "1001");
Expand All @@ -667,12 +675,15 @@ private void initializePlayer() {

// Initialize handler to run on the main thread
activity.runOnUiThread(() -> {
if (viewHasDropped) {
return;
}
try {
// Source initialization must run on the main thread
initializePlayerSource();
} catch (Exception ex) {
self.playerNeedsSource = true;
DebugLog.e(TAG, "Failed to initialize Player!");
DebugLog.e(TAG, "Failed to initialize Player! 1");
DebugLog.e(TAG, ex.toString());
ex.printStackTrace();
self.eventEmitter.error(ex.toString(), ex, "1001");
Expand All @@ -684,7 +695,7 @@ private void initializePlayer() {
}
} catch (Exception ex) {
self.playerNeedsSource = true;
DebugLog.e(TAG, "Failed to initialize Player!");
DebugLog.e(TAG, "Failed to initialize Player! 2");
DebugLog.e(TAG, ex.toString());
ex.printStackTrace();
eventEmitter.error(ex.toString(), ex, "1001");
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 @@ -15,7 +18,7 @@ import com.brentvatne.react.ReactVideoPackage
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 @@ -29,10 +32,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 @@ -41,5 +44,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 @@ -6,3 +6,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
69 changes: 66 additions & 3 deletions examples/basic/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
PODS:
- boost (1.83.0)
- DoubleConversion (1.1.6)
- EXConstants (16.0.2):
- ExpoModulesCore
- Expo (51.0.10):
- ExpoModulesCore
- ExpoAsset (10.0.7):
- ExpoModulesCore
- ExpoFileSystem (17.0.1):
- ExpoModulesCore
- ExpoFont (12.0.6):
- ExpoModulesCore
- ExpoKeepAwake (13.0.2):
- ExpoModulesCore
- ExpoModulesCore (1.12.13):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-jsinspector
- React-NativeModulesApple
- React-RCTAppDelegate
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- FBLazyVector (0.74.1)
- fmt (9.1.0)
- glog (0.3.5)
Expand Down Expand Up @@ -1215,6 +1250,13 @@ PODS:
DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- EXConstants (from `../node_modules/expo-constants/ios`)
- Expo (from `../node_modules/expo`)
- ExpoAsset (from `../node_modules/expo-asset/ios`)
- ExpoFileSystem (from `../node_modules/expo-file-system/ios`)
- ExpoFont (from `../node_modules/expo-font/ios`)
- ExpoKeepAwake (from `../node_modules/expo-keep-awake/ios`)
- ExpoModulesCore (from `../node_modules/expo-modules-core`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
Expand Down Expand Up @@ -1281,6 +1323,20 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/third-party-podspecs/boost.podspec"
DoubleConversion:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
EXConstants:
:path: "../node_modules/expo-constants/ios"
Expo:
:path: "../node_modules/expo"
ExpoAsset:
:path: "../node_modules/expo-asset/ios"
ExpoFileSystem:
:path: "../node_modules/expo-file-system/ios"
ExpoFont:
:path: "../node_modules/expo-font/ios"
ExpoKeepAwake:
:path: "../node_modules/expo-keep-awake/ios"
ExpoModulesCore:
:path: "../node_modules/expo-modules-core"
FBLazyVector:
:path: "../node_modules/react-native/Libraries/FBLazyVector"
fmt:
Expand Down Expand Up @@ -1394,11 +1450,18 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
EXConstants: 409690fbfd5afea964e5e9d6c4eb2c2b59222c59
Expo: 3bc69739da02780763c1fd66dde56f84fc46d0d8
ExpoAsset: 9605d71f50ff0554c618d415c991106f13df63f9
ExpoFileSystem: 80bfe850b1f9922c16905822ecbf97acd711dc51
ExpoFont: c84702079267ae51161c20bb8b925670907ffa2f
ExpoKeepAwake: 3b8815d9dd1d419ee474df004021c69fdd316d08
ExpoModulesCore: 3b890c52eb71ddab747a8dd1e215fafe7e5cd6c4
FBLazyVector: 898d14d17bf19e2435cafd9ea2a1033efe445709
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
hermes-engine: 16b8530de1b383cdada1476cf52d1b52f0692cbc
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df
RCTDeprecation: efb313d8126259e9294dc4ee0002f44a6f676aba
RCTRequired: f49ea29cece52aee20db633ae7edc4b271435562
RCTTypeSafety: a11979ff0570d230d74de9f604f7d19692157bc4
Expand Down Expand Up @@ -1450,6 +1513,6 @@ SPEC CHECKSUMS:
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: d02ee88821190d82b2daa5cd15640a82ffafaaab

PODFILE CHECKSUM: bbe1bd5f521b6b9366288dbaf8af1cec85c0a95a
PODFILE CHECKSUM: dfb9633fc816e568fd6d90dde654d15acd66faa9

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
Loading
Loading