Comments (11)
No, I've missed it! Great find! Renaming components might be an easier way. Although, RCTEventEmitter was deprecated long time ago.
The modern way to dispatch events is to inherit Event
, override getEventData
and then use UIManagerHelper.getEventDispatcherForReactTag(...).dispatch(new CustomEvent(...))
. Thats how RN native components like TextInput do that.
from react-native-video.
I have the same issue. However, in my case, it has nothing to do with the end of the video.
Here is the stacktrace:
01-25 14:12:50.649 26629 26629 E AndroidRuntime: com.facebook.react.uimanager.IllegalViewOperationException: Event: you must return a valid, non-null value from `getEventData`, or override `dispatch` and `dispatchModern`. Event: onVideoIdle
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.facebook.react.uimanager.events.Event.dispatch(Event.java:165)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.facebook.react.uimanager.events.Event.dispatchModern(Event.java:212)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.facebook.react.uimanager.events.FabricEventDispatcher.dispatchEvent(FabricEventDispatcher.java:41)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.facebook.react.fabric.interop.InteropEventEmitter.receiveEvent(InteropEventEmitter.java:50)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.brentvatne.common.react.VideoEventEmitter.receiveEvent(VideoEventEmitter.java:452)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.brentvatne.common.react.VideoEventEmitter.idle(VideoEventEmitter.java:330)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.brentvatne.exoplayer.ReactExoplayerView.onEvents(ReactExoplayerView.java:1092)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at androidx.media3.exoplayer.ExoPlayerImpl.lambda$new$0$androidx-media3-exoplayer-ExoPlayerImpl(ExoPlayerImpl.java:281)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at androidx.media3.exoplayer.ExoPlayerImpl$$ExternalSyntheticLambda12.invoke(Unknown Source:4)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at androidx.media3.common.util.ListenerSet$ListenerHolder.iterationFinished(ListenerSet.java:350)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at androidx.media3.common.util.ListenerSet.handleMessage(ListenerSet.java:294)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at androidx.media3.common.util.ListenerSet.$r8$lambda$bio3pd12v5B_9b5UeFaPn9XBQ90(Unknown Source:0)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at androidx.media3.common.util.ListenerSet$$ExternalSyntheticLambda0.handleMessage(Unknown Source:2)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6669)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
01-25 14:12:50.649 26629 26629 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Here is the patch that fixes it:
patches/react-native-video+6.0.0-beta.4.patch
diff --git a/node_modules/react-native-video/android/src/main/java/com/brentvatne/common/react/VideoEventEmitter.java b/node_modules/react-native-video/android/src/main/java/com/brentvatne/common/react/VideoEventEmitter.java
index 31cbc27..a9267de 100644
--- a/node_modules/react-native-video/android/src/main/java/com/brentvatne/common/react/VideoEventEmitter.java
+++ b/node_modules/react-native-video/android/src/main/java/com/brentvatne/common/react/VideoEventEmitter.java
@@ -9,9 +9,11 @@ import com.brentvatne.common.api.Track;
import com.brentvatne.common.api.VideoTrack;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.bridge.UIManager;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.uimanager.events.RCTEventEmitter;
+import com.facebook.react.uimanager.UIManagerHelper;
+import com.facebook.react.uimanager.common.ViewUtil;
import com.google.ads.interactivemedia.v3.api.AdError;
import java.io.PrintWriter;
@@ -23,12 +25,12 @@ import java.util.Map;
public class VideoEventEmitter {
- private final RCTEventEmitter eventEmitter;
+ private final ReactContext reactContext;
private int viewId = View.NO_ID;
public VideoEventEmitter(ReactContext reactContext) {
- this.eventEmitter = reactContext.getJSModule(RCTEventEmitter.class);
+ this.reactContext = reactContext;
}
private static final String EVENT_LOAD_START = "onVideoLoadStart";
@@ -449,6 +451,10 @@ public class VideoEventEmitter {
}
private void receiveEvent(@VideoEvents String type, WritableMap event) {
- eventEmitter.receiveEvent(viewId, type, event);
+ UIManager uiManager = UIManagerHelper.getUIManager(reactContext, ViewUtil.getUIManagerType(viewId));
+
+ if (uiManager != null) {
+ uiManager.receiveEvent(UIManagerHelper.getSurfaceId(reactContext), viewId, type, event);
+ }
}
}
- I haven't had a chance to test this properly. It looks like it is working fine and this is a typical issue for the old react-native libraries.
- It might be a good idea to cache uiManager, but I am not 100% comfortable with that due to the dynamic nature of RN.
from react-native-video.
@ddiachkov we discuss with @freeboub and we will apply your patch to update android event emitter 🙌
from react-native-video.
Doc is for the v6 version which is still beta.
Regarding fabric this is not yet supported, another ticket exist to follow that point
from react-native-video.
This isn't about Fabric, I am using the interop layer to ignore the package. Please reopen.
from react-native-video.
(see new renderer interop layer info: reactwg/react-native-new-architecture#135)
from react-native-video.
Maybe I am wrong, but unstable_reactLegacyComponentNames enables the interoperability layer. In the past I tested it also with react native fast image unsuccessfully. My conclusion was that this layer doesn't correctly support callbacks.
from react-native-video.
It allows react-native-video to work in a project with fabric enabled. I have used it for a few other packages that don't support fabric either.
from react-native-video.
Did you see comments in following thread reactwg/react-native-new-architecture#135
A guy made it work on the 5.2 version by doing some renaming!
(Notice that the patch proposed looks good to me)
from react-native-video.
Yeah, we should update this one day 😅
btw @ddiachkov I think there is one line fix for current RCTEventEmitter
implementation
just do in receiveEvent
method and it should also work
- eventEmitter.receiveEvent(viewId, type, event);
+ eventEmitter.receiveEvent(viewId, type, event == null ? Arguments.createMap() : event);
from react-native-video.
One-liner is better than my patch. I'll test it later today.
from react-native-video.
Related Issues (20)
- In iOS, playing a video in m3u8 format only has sound but no picture HOT 4
- onLoad() never get called for exoplayer but if I use default player then only black screen with sound. HOT 3
- [BUG] Live video issue HOT 3
- In Android, ReactExoplayerView instance doesn't eliminate after JS component unmount. HOT 3
- Video error on Android 11 HOT 7
- Android Lint warning: Using private resources
- Video is choppy on Android 12 HOT 1
- `RNVUseExoplayerIMA = false` - includes non-FOSS `androidx.media3 » media3-exoplayer-ima` lib HOT 4
- onPictureInPictureStatusChanged isActive called twice
- iOS - Picture in picture preventing video instances being released after unmount, eventually crashes HOT 4
- google promises install issue HOT 3
- Property 'play' does not exist on type 'VideoRef' HOT 1
- IOS 返回上个页面,video组件无法被销毁,后台还有声音, HOT 2
- How to customize the method of getting data from server HOT 1
- Error while changing video source (with DRM) HOT 1
- [BUG]: TVOS - fullscreen prop and ref.presentFullscreenPlayer() not working, not able to put player in fullscreen HOT 4
- [BUG]: souce params not loading network resource, but local resource can be loaded HOT 3
- [BUG]: with cropStart and cropEnd is set, audio plays from the original start position (0ms) when repeat is set to true HOT 2
- Controlbar misplaced when video list get scrolled HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-video.