React Native:带有JWPlayer的Native Android UI组件未显示视频图像 [英] React Native: Native Android UI component with JWPlayer shows no video image

查看:124
本文介绍了React Native:带有JWPlayer的Native Android UI组件未显示视频图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Android编写了一个本机UI组件,该组件主要由一个自定义视图(RelativeLayout)组成,该视图依次包含

I've written a native UI component for Android that basically consists of a custom view (RelativeLayout) which in turn contains JWPlayer. The component as well as the player itself are both rendered properly in my RN project (dimensions, colors, etc have the correct values) but when I start the playback I get sound without any image.

但是,当我旋转手机时,我也得到了视频图像,并且一切似乎都工作正常.我在Android项目中尝试了invalidate()requestLayout()之类的东西,但没有任何改变.我还尝试在包含本机组件且仍然没有运气的RN组件中再次调用render()(通过更新其状态).我用一个Activity创建了一个本地Android项目,其中包含与我编写的完全相同的自定义RelativeLayout,并且一切正常.因此问题似乎出在React Native项目方面.

However, when I rotate the phone I get video image as well and everything seems to be working fine. I tried things like invalidate() and requestLayout() in my Android project but nothing changed. I also tried calling render() again in the RN component (by updating its state) that contains the native component and still no luck. I created a native Android project with an Activity that contains the exact same custom RelativeLayout that I wrote and everything works fine. So the problem seems to be on the side of the React Native project.

由于旋转手机后一切正常,因此必须有一些生命周期方法可以重新渲染/重新布置RN组件.

Since everything works fine after rotating the phone, there must be some lifecycle method that re-renders/re-layouts the RN component.

所以我的问题是:有这种方法吗?

非常感谢.

PS. JWPlayer基于ExoPlayer.

PS. JWPlayer is based on ExoPlayer.

推荐答案

我发现实际的问题不是播放,而是呈现自定义视图的方式.如果有人遇到相同问题但找不到问题的真正根源,我在此处添加答案. 解决方案解决了我的问题.

I found that the actual problem is not the playback but how my custom view is rendered. I add the answer here in case someone runs into the same issue but cannot find the problem's real source. This solution solved my problem.

这篇关于React Native:带有JWPlayer的Native Android UI组件未显示视频图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆