video stream bug disconnect fixes

video-stream-floating
mosazaid 5 years ago
parent a1ab1e4f43
commit adab2d47d3

@ -182,8 +182,13 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
} }
override fun onDestroy() { override fun onDestroy() {
mWindowManager?.removeView(floatingWidgetView) try {
// disconnectSession() mWindowManager?.removeView(floatingWidgetView)
} catch (e: Exception) {
Log.e("onDestroyService", "${e.localizedMessage}.")
}
// disconnectSession()
super.onDestroy() super.onDestroy()
} }
@ -193,7 +198,12 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
cmTimer.stop() cmTimer.stop()
stopForeground(true) stopForeground(true)
stopSelf() stopSelf()
videoCallResponseListener?.minimizeVideoEvent(false)
try {
mWindowManager?.removeView(floatingWidgetView)
} catch (e: Exception) {
Log.e("stopService", "${e.localizedMessage}.")
}
} }
/* Add Floating Widget View to Window Manager */ /* Add Floating Widget View to Window Manager */
@ -291,9 +301,20 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
arg0?.text = formattedCallTime arg0?.text = formattedCallTime
try { try {
notificationCompatBuilder.contentView.setChronometer(R.id.notify_timer, cmTimer.base, null, true) notificationCompatBuilder.contentView.setChronometer(
notificationCompatBuilder.bigContentView.setChronometer(R.id.notify_timer, cmTimer.base, null, true) R.id.notify_timer,
} catch (e : Exception){} cmTimer.base,
null,
true
)
notificationCompatBuilder.bigContentView.setChronometer(
R.id.notify_timer,
cmTimer.base,
null,
true
)
} catch (e: Exception) {
}
// for change notification timer // for change notification timer
if (mNotificationManagerCompat != null) { if (mNotificationManagerCompat != null) {
@ -321,6 +342,17 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
mSession = Session.Builder(this, apiKey, sessionId).build() mSession = Session.Builder(this, apiKey, sessionId).build()
mSession!!.setSessionListener(this) mSession!!.setSessionListener(this)
mSession!!.connect(token) mSession!!.connect(token)
mSession!!.setReconnectionListener(object : Session.ReconnectionListener {
override fun onReconnecting(session: Session?) {
}
override fun onReconnected(session: Session?) {
session?.connect(token)
session?.onResume()
}
})
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
@ -558,20 +590,26 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
} }
fun onMinimizedClicked() { fun onMinimizedClicked() {
if (isCircle){ if (isCircle) {
onMiniCircleClicked() onMiniCircleClicked()
} }
if (isFullScreen) { if (isFullScreen) {
windowManagerParams.width = 400 windowManagerParams.width = 400
windowManagerParams.height = 600 windowManagerParams.height = 600
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams) try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
recordContainer.visibility = View.GONE recordContainer.visibility = View.GONE
} else { } else {
windowManagerParams.width = WindowManager.LayoutParams.MATCH_PARENT windowManagerParams.width = WindowManager.LayoutParams.MATCH_PARENT
windowManagerParams.height = WindowManager.LayoutParams.MATCH_PARENT windowManagerParams.height = WindowManager.LayoutParams.MATCH_PARENT
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams) try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
if (isRecording) { if (isRecording) {
recordContainer.visibility = View.VISIBLE recordContainer.visibility = View.VISIBLE
@ -637,12 +675,18 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
windowManagerParams.width = 400 windowManagerParams.width = 400
windowManagerParams.height = 600 windowManagerParams.height = 600
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams) try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
} else { } else {
windowManagerParams.width = 300 windowManagerParams.width = 300
windowManagerParams.height = 300 windowManagerParams.height = 300
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams) try {
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
} catch (e: Exception) {
}
} }
isCircle = !isCircle isCircle = !isCircle
@ -728,10 +772,10 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
override fun onDisconnected(session: Session) { override fun onDisconnected(session: Session) {
Log.d(TAG, "onDisconnected: disconnected from session " + session.sessionId) Log.d(TAG, "onDisconnected: disconnected from session " + session.sessionId)
mSession = null // mSession = null
cmTimer.stop() // cmTimer.stop()
disconnectSession() // disconnectSession()
videoCallResponseListener?.minimizeVideoEvent(false) // videoCallResponseListener?.minimizeVideoEvent(false)
} }
override fun onError(session: Session, opentokError: OpentokError) { override fun onError(session: Session, opentokError: OpentokError) {
@ -1035,7 +1079,12 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
mRemoteViewsExpand.setTextViewText(R.id.notify_title, notificationData.mContentTitle) mRemoteViewsExpand.setTextViewText(R.id.notify_title, notificationData.mContentTitle)
mRemoteViewsExpand.setTextViewText(R.id.notify_content, notificationData.mContentText) mRemoteViewsExpand.setTextViewText(R.id.notify_content, notificationData.mContentText)
mRemoteViewsExpand.setOnClickPendingIntent(R.id.btn_end, endCallPendingIntent) mRemoteViewsExpand.setOnClickPendingIntent(R.id.btn_end, endCallPendingIntent)
mRemoteViewsExpand.setChronometer(R.id.notify_timer, SystemClock.elapsedRealtime(), null, false) mRemoteViewsExpand.setChronometer(
R.id.notify_timer,
SystemClock.elapsedRealtime(),
null,
false
)
notificationCompatBuilder notificationCompatBuilder
// BIG_TEXT_STYLE sets title and content for API 16 (4.1 and after). // BIG_TEXT_STYLE sets title and content for API 16 (4.1 and after).

@ -199,6 +199,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
} }
} }
fun setCallListener(videoCallResponseListener: VideoCallResponseListener) { fun setCallListener(videoCallResponseListener: VideoCallResponseListener) {
this.videoCallResponseListener = videoCallResponseListener this.videoCallResponseListener = videoCallResponseListener
} }
@ -354,6 +355,8 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
checkClientConnected() checkClientConnected()
handleVideoViewHeight(true) handleVideoViewHeight(true)
if (appLang == "ar") { if (appLang == "ar") {
progressBarLayout!!.layoutDirection = View.LAYOUT_DIRECTION_RTL progressBarLayout!!.layoutDirection = View.LAYOUT_DIRECTION_RTL
} }

@ -33,8 +33,8 @@ class VideoCallService extends BaseService {
// kToken: startCallRes.openTokenID, // kToken: startCallRes.openTokenID,
// kSessionId: startCallRes.openSessionID, // kSessionId: startCallRes.openSessionID,
// kApiKey:'46209962', // kApiKey:'46209962',
kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGIyZDljOTY3YjFiNWU1YzUzNzFmMjIyNjJmNmEzY2Y5NzZjOTdlYzpzZXNzaW9uX2lkPTFfTVg0ME56STBOemsxTkg1LU1UWXlNekEyTlRRMU9EVXhObjVrVFRoMFlVdFJXaXRYTWpadFZGZHFhSGxZVGpOdE1UVi1mZyZjcmVhdGVfdGltZT0xNjIzMDY1NDk1Jm5vbmNlPTAuMjM2Mjk0NTIwMTkyOTA4OTcmcm9sZT1wdWJsaXNoZXImZXhwaXJlX3RpbWU9MTYyNTY1NzQ5NCZpbml0aWFsX2xheW91dF9jbGFzc19saXN0PQ==", kToken: "T1==cGFydG5lcl9pZD00NzI0Nzk1NCZzaWc9NGUyZjgxMjFlYTFkNzU5NjcxNDY2ZTM2ZjM3YTVhNTI2NGY0NTI2NzpzZXNzaW9uX2lkPTJfTVg0ME56STBOemsxTkg1LU1UWXlOVGN5TmpnMk5qZzNOMzQ1YUhCcGRtcDFXbVpDTDFkNE1qbDRkWFY2TTA4cmIySi1mZyZjcmVhdGVfdGltZT0xNjI1NzI2ODg5Jm5vbmNlPTAuNjc2Nzc4OTQxNjA1MTMxNSZyb2xlPXB1Ymxpc2hlciZleHBpcmVfdGltZT0xNjI4MzE4ODg4JmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9",
kSessionId: "1_MX40NzI0Nzk1NH5-MTYyMzA2NTQ1ODUxNn5kTTh0YUtRWitXMjZtVFdqaHlYTjNtMTV-fg", kSessionId: "2_MX40NzI0Nzk1NH5-MTYyNTcyNjg2Njg3N345aHBpdmp1WmZCL1d4Mjl4dXV6M08rb2J-fg",
kApiKey:'47247954', kApiKey:'47247954',
vcId: patient.vcId, vcId: patient.vcId,
isRecording: isRecording, isRecording: isRecording,

Loading…
Cancel
Save