|
@@ -16,6 +16,7 @@ import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
import com.yingyangfly.baselib.utils.LiveEventBusUtil
|
|
|
import com.yingyangfly.baselib.utils.RxBusCodes
|
|
|
import com.yingyangfly.baselib.utils.ViewTool
|
|
|
+import com.yingyangfly.baselib.voice.PlayVoice
|
|
|
import com.yingyangfly.webview.databinding.ActivityBridgeWebBinding
|
|
|
|
|
|
/**
|
|
@@ -27,12 +28,15 @@ class BridgeWebActivity : AppCompatActivity() {
|
|
|
private lateinit var binding: ActivityBridgeWebBinding
|
|
|
private lateinit var webSettings: WebSettings
|
|
|
private var url: String = ""
|
|
|
+ private var playVoice: PlayVoice? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
url = intent.getStringExtra("url") ?: ""
|
|
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_bridge_web)
|
|
|
ViewTool.inflateLayoutPixels(this, binding.root, 1194, 834)
|
|
|
+ playVoice = PlayVoice()
|
|
|
+ playVoice?.setContext(this)
|
|
|
initWebView()
|
|
|
initView()
|
|
|
}
|
|
@@ -82,14 +86,30 @@ class BridgeWebActivity : AppCompatActivity() {
|
|
|
}
|
|
|
|
|
|
private fun initView() {
|
|
|
+ //结束页面
|
|
|
LiveEventBusUtil.observer<String>(this, RxBusCodes.FINISHWEBVIEW) {
|
|
|
finish()
|
|
|
}
|
|
|
+ //播放语音
|
|
|
+ LiveEventBusUtil.observer<String>(this, RxBusCodes.PLAYVOICE) {
|
|
|
+ if (it.isNullOrEmpty().not()) {
|
|
|
+ val msg = it.split("voice:")
|
|
|
+ if (msg.isNullOrEmpty().not()) {
|
|
|
+ if (msg[1].isNullOrEmpty().not()) {
|
|
|
+ playVoice?.speak(msg[1])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
destoryWebView()
|
|
|
super.onDestroy()
|
|
|
+ if (playVoice != null) {
|
|
|
+ playVoice?.stop()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|