From b1c3c548599238ea6442691d9c3c7b670151e6e8 Mon Sep 17 00:00:00 2001 From: tangxiaolu Date: Sat, 26 Nov 2022 16:57:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B8=A6=E9=9F=B3=E9=A2=91?= =?UTF-8?q?=E7=9A=84svga=E8=B5=84=E6=BA=90=E6=9A=82=E5=81=9C=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20=20svga=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E6=92=AD=E6=94=BE=E5=8F=AF=E8=83=BD=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=AE=B5=E6=97=B6=E9=97=B4=E5=86=85=E7=9B=B8=E5=90=8C=E5=B8=A7?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=B0=83=E7=94=A8=E6=92=AD=E6=94=BE=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=EF=BC=8C=E5=9B=A0=E6=AD=A4=E6=92=AD=E6=94=BE=E4=B8=8B?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E4=B9=8B=E5=89=8D=E9=9C=80=E8=A6=81=E5=B0=86?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E4=B8=AA=E6=9A=82=E5=81=9C=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svgaplayer/drawer/SVGACanvasDrawer.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/opensource/svgaplayer/drawer/SVGACanvasDrawer.kt b/library/src/main/java/com/opensource/svgaplayer/drawer/SVGACanvasDrawer.kt index 42a0fbd..da8656f 100644 --- a/library/src/main/java/com/opensource/svgaplayer/drawer/SVGACanvasDrawer.kt +++ b/library/src/main/java/com/opensource/svgaplayer/drawer/SVGACanvasDrawer.kt @@ -8,6 +8,7 @@ import android.widget.ImageView import com.opensource.svgaplayer.SVGADynamicEntity import com.opensource.svgaplayer.SVGASoundManager import com.opensource.svgaplayer.SVGAVideoEntity +import com.opensource.svgaplayer.entities.SVGAAudioEntity import com.opensource.svgaplayer.entities.SVGAVideoShapeEntity /** @@ -159,12 +160,14 @@ internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVG if (audio.startFrame == frameIndex) { if (SVGASoundManager.isInit()) { audio.soundID?.let { soundID -> - audio.playID = SVGASoundManager.play(soundID) + val playID = SVGASoundManager.play(soundID) + setPlayId(audio,playID) } } else { this.videoItem.soundPool?.let { soundPool -> audio.soundID?.let { soundID -> - audio.playID = soundPool.play(soundID, 1.0f, 1.0f, 1, 0, 1.0f) + val playID = soundPool.play(soundID, 1.0f, 1.0f, 1, 0, 1.0f) + setPlayId(audio,playID) } } } @@ -556,4 +559,10 @@ internal class SVGACanvasDrawer(videoItem: SVGAVideoEntity, val dynamicItem: SVG } + private fun setPlayId(audio: SVGAAudioEntity, playID: Int) { + audio.playID?.let { + SVGASoundManager.stop(audio.playID!!) + } + audio.playID = playID + } }