|
|
@@ -2,13 +2,10 @@ package com.yingyang.livebroadcast.activity.detail
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.os.Bundle
|
|
|
-import android.text.TextUtils
|
|
|
-import android.util.Log
|
|
|
import android.view.MotionEvent
|
|
|
import android.view.View
|
|
|
import com.alibaba.android.arouter.facade.annotation.Route
|
|
|
import com.tencent.bugly.crashreport.CrashReport
|
|
|
-import com.tencent.imsdk.v2.*
|
|
|
import com.tencent.live2.V2TXLivePlayer
|
|
|
import com.tencent.live2.V2TXLivePlayerObserver
|
|
|
import com.tencent.live2.impl.V2TXLivePlayerImpl
|
|
|
@@ -16,7 +13,6 @@ import com.yingyang.livebroadcast.R
|
|
|
import com.yingyang.livebroadcast.databinding.ActivityLiveBroadcastBinding
|
|
|
import com.yingyangfly.baselib.ext.getEndAnimation
|
|
|
import com.yingyangfly.baselib.ext.getScaleAnimation
|
|
|
-import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
|
|
|
import com.yingyangfly.baselib.router.RouterUrlCommon
|
|
|
import com.yingyangfly.baselib.utils.User
|
|
|
@@ -47,8 +43,6 @@ class LiveBroadcastActivity :
|
|
|
initPlayer()
|
|
|
//上报直播间心跳
|
|
|
initTask()
|
|
|
- //初始化IM
|
|
|
- getUserSign()
|
|
|
}
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
@@ -79,47 +73,8 @@ class LiveBroadcastActivity :
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取腾讯IM密钥
|
|
|
- */
|
|
|
- private fun getUserSign() {
|
|
|
- viewModel.getUserSign(User.getUserId(), fail = {
|
|
|
- it.toast()
|
|
|
- }, success = {
|
|
|
- if (TextUtils.isEmpty(it).not()) {
|
|
|
- loginIm(it!!)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 登录IM
|
|
|
- */
|
|
|
- private fun loginIm(sign: String) {
|
|
|
- V2TIMManager.getInstance().login(User.getUserId(), sign, object : V2TIMCallback {
|
|
|
- override fun onError(p0: Int, p1: String?) {
|
|
|
- //用户登录IM失败
|
|
|
- CrashReport.postCatchedException(Throwable(User.getName() + "用户登录IM失败,错误码:" + p0 + " ,错误信息:" + p1))
|
|
|
- }
|
|
|
-
|
|
|
- override fun onSuccess() {
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
override fun onDestroy() {
|
|
|
runOnUiThread {
|
|
|
- V2TIMManager.getInstance().logout(object : V2TIMCallback {
|
|
|
- override fun onError(p0: Int, p1: String?) {
|
|
|
- //用户登录IM失败
|
|
|
- CrashReport.postCatchedException(Throwable(User.getName() + "用户退出IM失败,错误码:" + p0 + " ,错误信息:" + p1))
|
|
|
- }
|
|
|
-
|
|
|
- override fun onSuccess() {
|
|
|
- Log.e("wpp", "IM退出成功")
|
|
|
- }
|
|
|
- })
|
|
|
if (mLivePlayer != null) {
|
|
|
if (mPlayFlag) {
|
|
|
mLivePlayer!!.stopPlay()
|