|
@@ -31,6 +31,7 @@ class GameResultDialog : DialogFragment() {
|
|
|
private var curLevelScore: String = ""
|
|
|
private var isPass: String = ""
|
|
|
private var totalScore: String = ""
|
|
|
+ private var voicePlayer: VoicePlayer? = null
|
|
|
|
|
|
/**
|
|
|
* 游戏失败
|
|
@@ -79,6 +80,7 @@ class GameResultDialog : DialogFragment() {
|
|
|
val rootView = ViewTool.inflateFragmentPixels(
|
|
|
activity, R.layout.dialog_game_result, container, 1194, 834
|
|
|
)
|
|
|
+ voicePlayer = VoicePlayer.getInstance(activity)
|
|
|
findId(rootView)
|
|
|
initData()
|
|
|
initListener()
|
|
@@ -106,15 +108,19 @@ class GameResultDialog : DialogFragment() {
|
|
|
imageType!!.setBackgroundResource(R.mipmap.icon_game_result_success)
|
|
|
imageGameResult!!.setBackgroundResource(R.mipmap.icon_gasme_result_type_sueecee)
|
|
|
btnContinueThisLevel!!.setBackgroundResource(R.mipmap.icon_game_result_next)
|
|
|
- val wavFile = resources.assets.openFd("three.wav")
|
|
|
- VoicePlayer.getInstance(requireActivity()).playByLocation(wavFile)
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ val wavFile = resources.assets.openFd("success.mp3")
|
|
|
+ voicePlayer?.playByLocation(wavFile)
|
|
|
+ }
|
|
|
}
|
|
|
"1" -> {
|
|
|
imageType!!.setBackgroundResource(R.mipmap.icon_gasme_result_type_failed)
|
|
|
imageGameResult!!.setBackgroundResource(R.mipmap.icon_game_result_failed)
|
|
|
btnContinueThisLevel!!.setBackgroundResource(R.mipmap.icon_game_result_continue)
|
|
|
- val wavFile = resources.assets.openFd("one.wav")
|
|
|
- VoicePlayer.getInstance(requireActivity()).playByLocation(wavFile)
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ val wavFile = resources.assets.openFd("success.mp3")
|
|
|
+ voicePlayer?.playByLocation(wavFile)
|
|
|
+ }
|
|
|
}
|
|
|
"2" -> {
|
|
|
}
|
|
@@ -124,8 +130,10 @@ class GameResultDialog : DialogFragment() {
|
|
|
imageType!!.setBackgroundResource(R.mipmap.icon_timeout)
|
|
|
imageGameResult!!.setBackgroundResource(R.mipmap.icon_timer_out)
|
|
|
btnContinueThisLevel!!.setBackgroundResource(R.mipmap.icon_game_result_continue)
|
|
|
- val wavFile = resources.assets.openFd("two.wav")
|
|
|
- VoicePlayer.getInstance(requireActivity()).playByLocation(wavFile)
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ val wavFile = resources.assets.openFd("success.mp3")
|
|
|
+ voicePlayer?.playByLocation(wavFile)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -140,4 +148,11 @@ class GameResultDialog : DialogFragment() {
|
|
|
dismiss()
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ override fun dismiss() {
|
|
|
+ if (voicePlayer != null && voicePlayer?.isPlaying == true) {
|
|
|
+ voicePlayer?.stop()
|
|
|
+ }
|
|
|
+ super.dismiss()
|
|
|
+ }
|
|
|
}
|