From 22cfd6cead7c7182c0d23a6c897698526bd3d6de Mon Sep 17 00:00:00 2001 From: Mickael Lecoq Date: Fri, 2 Aug 2024 10:50:27 +0200 Subject: [PATCH] fix(android): viewType is ignored when its value is ViewType.TEXTURE (#4031) --- src/Video.tsx | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/Video.tsx b/src/Video.tsx index da24b567..98b96b64 100644 --- a/src/Video.tsx +++ b/src/Video.tsx @@ -595,28 +595,32 @@ const Video = forwardRef( const shallForceViewType = hasValidDrmProp && (viewType === ViewType.TEXTURE || useTextureView); - if (shallForceViewType) { - console.warn( - 'cannot use DRM on texture view. please set useTextureView={false}', - ); - } if (useSecureView && useTextureView) { console.warn( 'cannot use SecureView on texture view. please set useTextureView={false}', ); } - return shallForceViewType - ? useSecureView - ? ViewType.SURFACE_SECURE - : ViewType.SURFACE // check if we should force the type to Surface due to DRM - : viewType - ? viewType // else use ViewType from source - : useSecureView // else infer view type from useSecureView and useTextureView - ? ViewType.SURFACE_SECURE - : useTextureView - ? ViewType.TEXTURE - : ViewType.SURFACE; + if (shallForceViewType) { + console.warn( + 'cannot use DRM on texture view. please set useTextureView={false}', + ); + return useSecureView ? ViewType.SURFACE_SECURE : ViewType.SURFACE; + } + + if (viewType !== undefined && viewType !== null) { + return viewType; + } + + if (useSecureView) { + return ViewType.SURFACE_SECURE; + } + + if (useTextureView) { + return ViewType.TEXTURE; + } + + return ViewType.SURFACE; }, [drm, useSecureView, useTextureView, viewType]); const _renderPoster = useCallback(() => {