|
|
@@ -11,11 +11,13 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.alibaba.android.arouter.launcher.ARouter
|
|
|
import com.tencent.liteav.demo.superplayer.SuperPlayerModel
|
|
|
import com.yingyangfly.baselib.config.AccountConfig
|
|
|
+import com.yingyangfly.baselib.db.VoicePlayerBean
|
|
|
import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
import com.yingyangfly.baselib.ext.show
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
+import com.yingyangfly.baselib.player.VoicePlayer
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
import com.yingyangfly.baselib.utils.RxBusCodes
|
|
|
import com.yingyangfly.game.R
|
|
|
@@ -34,6 +36,7 @@ class GameIntroductionActivity :
|
|
|
BaseMVVMActivity<ActivityGameIntroductionBinding, GameIntroductionViewModel>(),
|
|
|
View.OnTouchListener {
|
|
|
|
|
|
+ private var desn = ""
|
|
|
private var videoUrl = ""
|
|
|
private var isEnterGame = false
|
|
|
private var gameCode: String = ""
|
|
|
@@ -42,7 +45,13 @@ class GameIntroductionActivity :
|
|
|
private var gameBackgroundImage: String = ""
|
|
|
private var gameBean: GameBean? = null
|
|
|
|
|
|
+ /**
|
|
|
+ * 语音合成
|
|
|
+ */
|
|
|
+ private var voicePlayer: VoicePlayer? = null
|
|
|
+
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ desn = intent.getStringExtra("desn") ?: ""
|
|
|
gameCode = intent.getStringExtra("gameCode") ?: ""
|
|
|
playClass = intent.getStringExtra("playClass") ?: ""
|
|
|
videoUrl = intent.getStringExtra("videoUrl") ?: ""
|
|
|
@@ -52,6 +61,7 @@ class GameIntroductionActivity :
|
|
|
}
|
|
|
|
|
|
override fun initViews() {
|
|
|
+ voicePlayer = VoicePlayer.getInstance(mContext)
|
|
|
if (TextUtils.isEmpty(gameInbetweenImage).not()) {
|
|
|
binding.image = gameInbetweenImage
|
|
|
}
|
|
|
@@ -84,6 +94,9 @@ class GameIntroductionActivity :
|
|
|
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
+ if (isEnterGame.not()) {
|
|
|
+ speak()
|
|
|
+ }
|
|
|
getGameDetailByCode()
|
|
|
}
|
|
|
|
|
|
@@ -94,6 +107,11 @@ class GameIntroductionActivity :
|
|
|
|
|
|
override fun onPause() {
|
|
|
binding.playTxCloudView.onPause()
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ if (voicePlayer!!.isPlaying) {
|
|
|
+ voicePlayer?.stop()
|
|
|
+ }
|
|
|
+ }
|
|
|
super.onPause()
|
|
|
}
|
|
|
|
|
|
@@ -193,7 +211,55 @@ class GameIntroductionActivity :
|
|
|
finish()
|
|
|
}
|
|
|
|
|
|
- override fun finish() {
|
|
|
- super.finish()
|
|
|
+ /**
|
|
|
+ * 语音合成
|
|
|
+ */
|
|
|
+ private fun speak() {
|
|
|
+ if (db != null) {
|
|
|
+ val voicePlayerDao = db?.getVoicePlayerDao()
|
|
|
+ if (voicePlayerDao != null) {
|
|
|
+ val voicePlayerBean = voicePlayerDao.getVoicePlayerBean(desn)
|
|
|
+ if (voicePlayerBean != null) {
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ voicePlayer?.play(voicePlayerBean.url) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ getVoiceUrl(desn)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ getVoiceUrl(desn)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ getVoiceUrl(desn)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取声音url
|
|
|
+ */
|
|
|
+ private fun getVoiceUrl(taskDesn: String) {
|
|
|
+ viewModel.getVoiceUrl(taskDesn, fail = {
|
|
|
+ it.toast()
|
|
|
+ }, success = {
|
|
|
+ if (TextUtils.isEmpty(it).not()) {
|
|
|
+ if (db != null) {
|
|
|
+ val voicePlayerDao = db?.getVoicePlayerDao()
|
|
|
+ if (voicePlayerDao != null) {
|
|
|
+ val voicePlayerBean = VoicePlayerBean().apply {
|
|
|
+ url = it
|
|
|
+ words = taskDesn
|
|
|
+ }
|
|
|
+ voicePlayerDao.insert(voicePlayerBean)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (voicePlayer != null) {
|
|
|
+ voicePlayer?.play(it) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|