|
@@ -1,6 +1,5 @@
|
|
|
package com.yingyangfly.game.dialog
|
|
|
|
|
|
-import android.media.MediaPlayer
|
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
|
import android.view.LayoutInflater
|
|
@@ -13,6 +12,7 @@ import androidx.fragment.app.DialogFragment
|
|
|
import com.bumptech.glide.Glide
|
|
|
import com.gyf.immersionbar.BarHide
|
|
|
import com.gyf.immersionbar.ktx.immersionBar
|
|
|
+import com.yingyangfly.baselib.player.VoicePlayer
|
|
|
import com.yingyangfly.baselib.utils.LiveEventBusUtil
|
|
|
import com.yingyangfly.baselib.utils.RxBusCodes
|
|
|
import com.yingyangfly.baselib.utils.RxTimer
|
|
@@ -105,64 +105,22 @@ class CountdownDialog : DialogFragment() {
|
|
|
"1" -> {
|
|
|
imageCountdown!!.setBackgroundResource(R.mipmap.icon_one)
|
|
|
imageCountdown!!.post {
|
|
|
- val mediaPlayer = MediaPlayer()
|
|
|
val wavFile = resources.assets.openFd("one.wav")
|
|
|
- mediaPlayer.setDataSource(
|
|
|
- wavFile.fileDescriptor,
|
|
|
- wavFile.startOffset,
|
|
|
- wavFile.length
|
|
|
- )
|
|
|
- mediaPlayer.prepareAsync()
|
|
|
- mediaPlayer.setOnPreparedListener {
|
|
|
- mediaPlayer.start()
|
|
|
- }
|
|
|
- mediaPlayer.setOnCompletionListener {
|
|
|
- mediaPlayer.stop()
|
|
|
- mediaPlayer.reset()
|
|
|
- mediaPlayer.release()
|
|
|
- }
|
|
|
+ VoicePlayer.getInstance(requireActivity()).playByLocation(wavFile)
|
|
|
}
|
|
|
}
|
|
|
"2" -> {
|
|
|
imageCountdown!!.setBackgroundResource(R.mipmap.icon_two)
|
|
|
imageCountdown!!.post {
|
|
|
- val mediaPlayer = MediaPlayer()
|
|
|
val wavFile = resources.assets.openFd("two.wav")
|
|
|
- mediaPlayer.setDataSource(
|
|
|
- wavFile.fileDescriptor,
|
|
|
- wavFile.startOffset,
|
|
|
- wavFile.length
|
|
|
- )
|
|
|
- mediaPlayer.prepareAsync()
|
|
|
- mediaPlayer.setOnPreparedListener {
|
|
|
- mediaPlayer.start()
|
|
|
- }
|
|
|
- mediaPlayer.setOnCompletionListener {
|
|
|
- mediaPlayer.stop()
|
|
|
- mediaPlayer.reset()
|
|
|
- mediaPlayer.release()
|
|
|
- }
|
|
|
+ VoicePlayer.getInstance(requireActivity()).playByLocation(wavFile)
|
|
|
}
|
|
|
}
|
|
|
"3" -> {
|
|
|
imageCountdown!!.setBackgroundResource(R.mipmap.icon_three)
|
|
|
imageCountdown!!.post {
|
|
|
- val mediaPlayer = MediaPlayer()
|
|
|
val wavFile = resources.assets.openFd("three.wav")
|
|
|
- mediaPlayer.setDataSource(
|
|
|
- wavFile.fileDescriptor,
|
|
|
- wavFile.startOffset,
|
|
|
- wavFile.length
|
|
|
- )
|
|
|
- mediaPlayer.prepareAsync()
|
|
|
- mediaPlayer.setOnPreparedListener {
|
|
|
- mediaPlayer.start()
|
|
|
- }
|
|
|
- mediaPlayer.setOnCompletionListener {
|
|
|
- mediaPlayer.stop()
|
|
|
- mediaPlayer.reset()
|
|
|
- mediaPlayer.release()
|
|
|
- }
|
|
|
+ VoicePlayer.getInstance(requireActivity()).playByLocation(wavFile)
|
|
|
}
|
|
|
}
|
|
|
}
|