From 50c796e6ebfbf446f0f6067f77db5416dcecbb0c Mon Sep 17 00:00:00 2001 From: cjand <1747143535@qq.com> Date: Fri, 18 Oct 2024 17:15:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9pixelMap=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cjand <1747143535@qq.com> --- .../components/videoplayer/VideoPlayerApiImpl.ets | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayerApiImpl.ets b/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayerApiImpl.ets index d5061d265..b73524cb3 100644 --- a/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayerApiImpl.ets +++ b/packages/video_player/video_player_ohos/ohos/src/main/ets/components/videoplayer/VideoPlayerApiImpl.ets @@ -46,7 +46,7 @@ export class VideoPlayerApiImpl { private flutterState: FlutterState | null = null; private binding: AbilityPluginBinding | null = null; private AudioFocus: Boolean = false; - private pixelMap: image.PixelMap | null = null; + private pixelMaps: HashMap = new HashMap(); constructor(flutterState: FlutterState | null, binding: AbilityPluginBinding | null) { this.flutterState = flutterState; @@ -87,23 +87,25 @@ export class VideoPlayerApiImpl { if (asset != null) { let avImageGenerator = await media.createAVImageGenerator(); avImageGenerator.fdSrc = await this.getContext().resourceManager.getRawFd("flutter_assets/" + asset); - this.pixelMap = await avImageGenerator.fetchFrameByTime(0, media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC, { + let pixelMap = await avImageGenerator.fetchFrameByTime(0, media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC, { width: -1, height: -1 }); + this.pixelMaps.set(JSON.stringify(arg), pixelMap); avImageGenerator.release(); - flutterRenderer.setTextureBackGroundPixelMap(textureId, this.pixelMap); + flutterRenderer.setTextureBackGroundPixelMap(textureId, this.pixelMaps.get(JSON.stringify(arg))); } else if (uri != null && uri.startsWith("fd://")) { let avImageGenerator = await media.createAVImageGenerator(); avImageGenerator.fdSrc = { fd: Number.parseInt(uri.replace("fd://", "")) }; - this.pixelMap = await avImageGenerator.fetchFrameByTime(0, media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC, { + let pixelMap = await avImageGenerator.fetchFrameByTime(0, media.AVImageQueryOptions.AV_IMAGE_QUERY_NEXT_SYNC, { width: -1, height: -1 }); + this.pixelMaps.set(JSON.stringify(arg), pixelMap); avImageGenerator.release(); - flutterRenderer.setTextureBackGroundPixelMap(textureId, this.pixelMap); + flutterRenderer.setTextureBackGroundPixelMap(textureId, this.pixelMaps.get(JSON.stringify(arg))); } let eventChannel: EventChannel = new EventChannel(this.flutterState.getBinaryMessenger(), "flutter.io/videoPlayer/videoEvents" + textureId.toString()); if (asset != null) { -- Gitee