Skip to content

Commit

Permalink
feat: 增加静音接口
Browse files Browse the repository at this point in the history
  • Loading branch information
hexleo committed Nov 10, 2021
1 parent a48b793 commit cf7b3f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class AnimPlayer(val animView: IAnimView) {
var isSurfaceAvailable = false
var startRunnable: Runnable? = null
var isStartRunning = false // 启动时运行状态
var isMute = false // 是否静音

val configManager = AnimConfigManager(this)
val pluginManager = AnimPluginManager(this)
Expand Down Expand Up @@ -106,11 +107,13 @@ class AnimPlayer(val animView: IAnimView) {
if (isSurfaceAvailable) {
isStartRunning = false
decoder?.start(fileContainer)
audioPlayer?.start(fileContainer)
if (!isMute) {
audioPlayer?.start(fileContainer)
}
} else {
startRunnable = Runnable {
innerStartPlay(fileContainer)
}
}
animView.prepareTextureView()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ open class AnimView @JvmOverloads constructor(context: Context, attrs: Attribute
scaleTypeUtil.scaleTypeImpl = scaleType
}

/**
* @param isMute true 静音
*/
override fun setMute(isMute: Boolean) {
ALog.e(TAG, "set mute=$isMute")
player.isMute = isMute
}

override fun startPlay(file: File) {
try {
val fileContainer = FileContainer(file)
Expand Down Expand Up @@ -273,7 +281,7 @@ open class AnimView @JvmOverloads constructor(context: Context, attrs: Attribute
lastFile = fileContainer
player.startPlay(fileContainer)
} else {
ALog.i(TAG, "is running can not start")
ALog.e(TAG, "is running can not start")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ interface IAnimView {

fun setScaleType(scaleType: IScaleType)

fun setMute(isMute: Boolean)

fun startPlay(file: File)

fun startPlay(assetManager: AssetManager, assetsPath: String)
Expand Down

0 comments on commit cf7b3f5

Please sign in to comment.