Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

修复带音频的svga资源暂停失败的问题 svga音频播放可能出现段时间内相同帧重复调用播放音频,因此播放下一个之前需要将上一个暂停掉 #453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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)
}
}
}
Expand Down Expand Up @@ -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
}
}