@100mslive/react-native-hms 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -340
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +205 -75
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +127 -127
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +153 -115
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +147 -17
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +7 -7
- package/ios/HMSDecoder.swift +205 -129
- package/ios/HMSHelper.swift +3 -3
- package/ios/HMSManager.m +3 -0
- package/ios/HMSManager.swift +22 -1
- package/ios/HMSRNSDK.swift +228 -79
- package/ios/HMSView.m +2 -0
- package/ios/HMSView.swift +35 -3
- package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/yogesh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSChangeTrackStateRequest.js.map +1 -1
- package/lib/commonjs/classes/HMSEncoder.js +133 -84
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSHLSStreamingState.js.map +1 -1
- package/lib/commonjs/classes/HMSLocalVideoTrack.js +0 -2
- package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSMessageRecipient.js +1 -1
- package/lib/commonjs/classes/HMSMessageRecipient.js.map +1 -1
- package/lib/commonjs/classes/HMSNativeEventEmitter.js +106 -0
- package/lib/commonjs/classes/HMSNativeEventEmitter.js.map +1 -0
- package/lib/commonjs/classes/HMSPeer.js +4 -0
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPublishSettings.js +0 -6
- package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSRole.js +0 -6
- package/lib/commonjs/classes/HMSRole.js.map +1 -1
- package/lib/commonjs/classes/HMSRoleChangeRequest.js +3 -1
- package/lib/commonjs/classes/HMSRoleChangeRequest.js.map +1 -1
- package/lib/commonjs/classes/HMSRtmpStreamingState.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +465 -137
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSServerRecordingState.js.map +1 -1
- package/lib/commonjs/classes/HMSSubscribeSettings.js +0 -2
- package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/classes/HMSBrowserRecordingState.js.map +1 -1
- package/lib/module/classes/HMSChangeTrackStateRequest.js.map +1 -1
- package/lib/module/classes/HMSEncoder.js +133 -84
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSHLSStreamingState.js.map +1 -1
- package/lib/module/classes/HMSLocalVideoTrack.js +0 -2
- package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSMessageRecipient.js +1 -1
- package/lib/module/classes/HMSMessageRecipient.js.map +1 -1
- package/lib/module/classes/HMSNativeEventEmitter.js +99 -0
- package/lib/module/classes/HMSNativeEventEmitter.js.map +1 -0
- package/lib/module/classes/HMSPeer.js +4 -0
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPublishSettings.js +0 -6
- package/lib/module/classes/HMSPublishSettings.js.map +1 -1
- package/lib/module/classes/HMSRole.js +0 -6
- package/lib/module/classes/HMSRole.js.map +1 -1
- package/lib/module/classes/HMSRoleChangeRequest.js +3 -1
- package/lib/module/classes/HMSRoleChangeRequest.js.map +1 -1
- package/lib/module/classes/HMSRtmpStreamingState.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +466 -138
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSServerRecordingState.js.map +1 -1
- package/lib/module/classes/HMSSubscribeSettings.js +0 -2
- package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/classes/HMSBrowserRecordingState.d.ts +4 -4
- package/lib/typescript/classes/HMSChangeTrackStateRequest.d.ts +2 -2
- package/lib/typescript/classes/HMSEncoder.d.ts +3 -0
- package/lib/typescript/classes/HMSHLSStreamingState.d.ts +2 -2
- package/lib/typescript/classes/HMSLocalVideoTrack.d.ts +0 -2
- package/lib/typescript/classes/HMSMessageRecipient.d.ts +2 -2
- package/lib/typescript/classes/HMSNativeEventEmitter.d.ts +13 -0
- package/lib/typescript/classes/HMSPublishSettings.d.ts +8 -15
- package/lib/typescript/classes/HMSRole.d.ts +0 -6
- package/lib/typescript/classes/HMSRoleChangeRequest.d.ts +2 -2
- package/lib/typescript/classes/HMSRtmpStreamingState.d.ts +4 -4
- package/lib/typescript/classes/HMSSDK.d.ts +2 -12
- package/lib/typescript/classes/HMSServerRecordingState.d.ts +2 -2
- package/lib/typescript/classes/HMSSubscribeSettings.d.ts +0 -2
- package/lib/typescript/index.d.ts +1 -0
- package/package.json +6 -4
- package/react-native-hms.podspec +1 -1
- package/sdk-versions.json +5 -0
- package/src/classes/HMSBrowserRecordingState.ts +4 -4
- package/src/classes/HMSChangeTrackStateRequest.ts +2 -2
- package/src/classes/HMSEncoder.ts +186 -99
- package/src/classes/HMSHLSStreamingState.ts +2 -2
- package/src/classes/HMSLocalVideoTrack.ts +0 -2
- package/src/classes/HMSMessageRecipient.ts +3 -3
- package/src/classes/HMSNativeEventEmitter.ts +86 -0
- package/src/classes/HMSPeer.ts +4 -0
- package/src/classes/HMSPublishSettings.ts +8 -18
- package/src/classes/HMSRole.ts +0 -9
- package/src/classes/HMSRoleChangeRequest.ts +5 -3
- package/src/classes/HMSRtmpStreamingState.ts +4 -4
- package/src/classes/HMSSDK.tsx +629 -269
- package/src/classes/HMSServerRecordingState.ts +2 -2
- package/src/classes/HMSSubscribeSettings.ts +1 -7
- package/src/index.ts +1 -0
|
@@ -3,11 +3,8 @@ package com.reactnativehmssdk
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.app.Application
|
|
5
5
|
import android.app.PendingIntent
|
|
6
|
-
import android.app.PictureInPictureParams
|
|
7
|
-
import android.app.RemoteAction
|
|
8
6
|
import android.content.Intent
|
|
9
7
|
import android.content.pm.PackageManager
|
|
10
|
-
import android.graphics.drawable.Icon
|
|
11
8
|
import android.os.Build
|
|
12
9
|
import android.os.Bundle
|
|
13
10
|
import android.util.Rational
|
|
@@ -450,6 +447,27 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
450
447
|
hms?.getSessionMetaData(callback)
|
|
451
448
|
}
|
|
452
449
|
|
|
450
|
+
@ReactMethod
|
|
451
|
+
fun enableEvent(data: ReadableMap, promise: Promise?) {
|
|
452
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
453
|
+
|
|
454
|
+
hms?.enableEvent(data, promise)
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
@ReactMethod
|
|
458
|
+
fun disableEvent(data: ReadableMap, promise: Promise?) {
|
|
459
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
460
|
+
|
|
461
|
+
hms?.disableEvent(data, promise)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
@ReactMethod()
|
|
465
|
+
fun restrictData(data: ReadableMap, promise: Promise?) {
|
|
466
|
+
val hms = HMSHelper.getHms(data, hmsCollection)
|
|
467
|
+
|
|
468
|
+
hms?.restrictData(data, promise)
|
|
469
|
+
}
|
|
470
|
+
|
|
453
471
|
// region Person-In-Person Mode Action handing
|
|
454
472
|
private val pipReceiver by lazy {
|
|
455
473
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
@@ -471,10 +489,13 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
471
489
|
}
|
|
472
490
|
}
|
|
473
491
|
|
|
474
|
-
private var pipRemoteActionsList: MutableList<
|
|
492
|
+
private var pipRemoteActionsList: MutableList<Any> = mutableListOf()
|
|
475
493
|
|
|
476
494
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
477
495
|
private fun toggleLocalAudio() {
|
|
496
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
497
|
+
return
|
|
498
|
+
}
|
|
478
499
|
val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
|
|
479
500
|
|
|
480
501
|
val localAudioTrack = hmssdk?.getLocalPeer()?.audioTrack
|
|
@@ -487,6 +508,9 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
487
508
|
|
|
488
509
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
489
510
|
private fun toggleLocalVideo() {
|
|
511
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
512
|
+
return
|
|
513
|
+
}
|
|
490
514
|
val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
|
|
491
515
|
|
|
492
516
|
val localVideoTrack = hmssdk?.getLocalPeer()?.videoTrack
|
|
@@ -499,6 +523,9 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
499
523
|
|
|
500
524
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
501
525
|
private fun endMeeting() {
|
|
526
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
527
|
+
return
|
|
528
|
+
}
|
|
502
529
|
val hms = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]
|
|
503
530
|
|
|
504
531
|
hms?.leave(callback = null, fromPIP = true)
|
|
@@ -506,6 +533,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
506
533
|
|
|
507
534
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
508
535
|
private fun updatePIPRemoteActions(code: Int) {
|
|
536
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
537
|
+
return
|
|
538
|
+
}
|
|
539
|
+
|
|
509
540
|
val activity = currentActivity
|
|
510
541
|
|
|
511
542
|
if (activity !== null) {
|
|
@@ -513,10 +544,10 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
513
544
|
|
|
514
545
|
when (code) {
|
|
515
546
|
PipActionReceiver.PIPActions.localAudio.requestCode -> {
|
|
516
|
-
val audioActionIdx = pipRemoteActionsList.indexOfFirst { it.title == PipActionReceiver.PIPActions.localAudio.title }
|
|
547
|
+
val audioActionIdx = pipRemoteActionsList.indexOfFirst { it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localAudio.title }
|
|
517
548
|
if (audioActionIdx >= 0) {
|
|
518
|
-
pipRemoteActionsList[audioActionIdx] = RemoteAction(
|
|
519
|
-
Icon.createWithResource(
|
|
549
|
+
pipRemoteActionsList[audioActionIdx] = android.app.RemoteAction(
|
|
550
|
+
android.graphics.drawable.Icon.createWithResource(
|
|
520
551
|
reactApplicationContext,
|
|
521
552
|
if (hmssdk?.getLocalPeer()?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24
|
|
522
553
|
),
|
|
@@ -532,12 +563,14 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
532
563
|
}
|
|
533
564
|
}
|
|
534
565
|
PipActionReceiver.PIPActions.localVideo.requestCode -> {
|
|
535
|
-
val videoActionIdx = pipRemoteActionsList.indexOfFirst { it.title == PipActionReceiver.PIPActions.localVideo.title }
|
|
566
|
+
val videoActionIdx = pipRemoteActionsList.indexOfFirst { it is android.app.RemoteAction && it.title == PipActionReceiver.PIPActions.localVideo.title }
|
|
536
567
|
if (videoActionIdx >= 0) {
|
|
537
|
-
|
|
538
|
-
|
|
568
|
+
val isVideoMute = hmssdk?.getLocalPeer()?.videoTrack?.isMute
|
|
569
|
+
val updatedIcon = if (isVideoMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
|
|
570
|
+
pipRemoteActionsList[videoActionIdx] = android.app.RemoteAction(
|
|
571
|
+
android.graphics.drawable.Icon.createWithResource(
|
|
539
572
|
reactApplicationContext,
|
|
540
|
-
|
|
573
|
+
updatedIcon
|
|
541
574
|
),
|
|
542
575
|
PipActionReceiver.PIPActions.localVideo.title,
|
|
543
576
|
PipActionReceiver.PIPActions.localVideo.description,
|
|
@@ -552,8 +585,8 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
552
585
|
}
|
|
553
586
|
}
|
|
554
587
|
|
|
555
|
-
val pipParams = PictureInPictureParams.Builder().let {
|
|
556
|
-
it.setActions(pipRemoteActionsList)
|
|
588
|
+
val pipParams = android.app.PictureInPictureParams.Builder().let {
|
|
589
|
+
it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
|
|
557
590
|
it.build()
|
|
558
591
|
}
|
|
559
592
|
|
|
@@ -603,82 +636,15 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
603
636
|
}
|
|
604
637
|
}
|
|
605
638
|
|
|
639
|
+
// Builds and returns PictureInPictureParams as per given config
|
|
640
|
+
// `Any` type is used here to prevent crashes on "SDK < API level 26"
|
|
606
641
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
607
|
-
private fun
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
pipRemoteActionsList.clear()
|
|
611
|
-
|
|
612
|
-
val localPeer = hmssdk?.getLocalPeer()
|
|
613
|
-
val allowedPublishing = localPeer?.hmsRole?.publishParams?.allowed
|
|
614
|
-
|
|
615
|
-
if (audioAction && allowedPublishing?.contains("audio") === true) {
|
|
616
|
-
pipRemoteActionsList.add(
|
|
617
|
-
RemoteAction(
|
|
618
|
-
Icon.createWithResource(
|
|
619
|
-
reactApplicationContext,
|
|
620
|
-
if (localPeer?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24
|
|
621
|
-
),
|
|
622
|
-
PipActionReceiver.PIPActions.localAudio.title,
|
|
623
|
-
PipActionReceiver.PIPActions.localAudio.description,
|
|
624
|
-
PendingIntent.getBroadcast(
|
|
625
|
-
reactApplicationContext,
|
|
626
|
-
PipActionReceiver.PIPActions.localAudio.requestCode,
|
|
627
|
-
Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
|
|
628
|
-
PendingIntent.FLAG_IMMUTABLE
|
|
629
|
-
)
|
|
630
|
-
)
|
|
631
|
-
)
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
if (endAction) {
|
|
635
|
-
pipRemoteActionsList.add(
|
|
636
|
-
RemoteAction(
|
|
637
|
-
Icon.createWithResource(reactApplicationContext, R.drawable.ic_call_end_24),
|
|
638
|
-
PipActionReceiver.PIPActions.endMeet.title,
|
|
639
|
-
PipActionReceiver.PIPActions.endMeet.description,
|
|
640
|
-
PendingIntent.getBroadcast(
|
|
641
|
-
reactApplicationContext,
|
|
642
|
-
PipActionReceiver.PIPActions.endMeet.requestCode,
|
|
643
|
-
Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
|
|
644
|
-
PipActionReceiver.PIPActions.endMeet.title,
|
|
645
|
-
PipActionReceiver.PIPActions.endMeet.requestCode
|
|
646
|
-
),
|
|
647
|
-
PendingIntent.FLAG_IMMUTABLE
|
|
648
|
-
)
|
|
649
|
-
)
|
|
650
|
-
)
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
if (videoAction && allowedPublishing?.contains("video") === true) {
|
|
654
|
-
pipRemoteActionsList.add(
|
|
655
|
-
RemoteAction(
|
|
656
|
-
Icon.createWithResource(
|
|
657
|
-
reactApplicationContext,
|
|
658
|
-
if (localPeer?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
|
|
659
|
-
),
|
|
660
|
-
PipActionReceiver.PIPActions.localVideo.title,
|
|
661
|
-
PipActionReceiver.PIPActions.localVideo.description,
|
|
662
|
-
PendingIntent.getBroadcast(
|
|
663
|
-
reactApplicationContext,
|
|
664
|
-
PipActionReceiver.PIPActions.localVideo.requestCode,
|
|
665
|
-
Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
|
|
666
|
-
PipActionReceiver.PIPActions.localVideo.title,
|
|
667
|
-
PipActionReceiver.PIPActions.localVideo.requestCode
|
|
668
|
-
),
|
|
669
|
-
PendingIntent.FLAG_IMMUTABLE
|
|
670
|
-
)
|
|
671
|
-
)
|
|
672
|
-
)
|
|
642
|
+
private fun buildPipParams(config: PipParamConfig): Any? {
|
|
643
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
644
|
+
return null
|
|
673
645
|
}
|
|
674
646
|
|
|
675
|
-
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
// Builds and returns PictureInPictureParams as per given config
|
|
679
|
-
@RequiresApi(Build.VERSION_CODES.O)
|
|
680
|
-
private fun buildPipParams(config: PipParamConfig): PictureInPictureParams {
|
|
681
|
-
val pipParams = PictureInPictureParams.Builder().let {
|
|
647
|
+
val pipParams = android.app.PictureInPictureParams.Builder().let {
|
|
682
648
|
if (config.aspectRatio !== null) {
|
|
683
649
|
it.setAspectRatio(
|
|
684
650
|
Rational(
|
|
@@ -693,13 +659,76 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
693
659
|
// it.setAutoEnterEnabled(config.autoEnterEnabled)
|
|
694
660
|
// }
|
|
695
661
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
662
|
+
// region Setting RemoteActions on PictureInPictureParams
|
|
663
|
+
val hmssdk = getHmsInstance()[PipActionReceiver.sdkIdForPIP!!]?.hmsSDK
|
|
664
|
+
|
|
665
|
+
pipRemoteActionsList.clear()
|
|
666
|
+
|
|
667
|
+
val localPeer = hmssdk?.getLocalPeer()
|
|
668
|
+
val allowedPublishing = localPeer?.hmsRole?.publishParams?.allowed
|
|
669
|
+
|
|
670
|
+
if (config.showAudioButton && allowedPublishing?.contains("audio") === true) {
|
|
671
|
+
pipRemoteActionsList.add(
|
|
672
|
+
android.app.RemoteAction(
|
|
673
|
+
android.graphics.drawable.Icon.createWithResource(
|
|
674
|
+
reactApplicationContext,
|
|
675
|
+
if (localPeer?.audioTrack?.isMute === true) R.drawable.ic_mic_off_24 else R.drawable.ic_mic_24
|
|
676
|
+
),
|
|
677
|
+
PipActionReceiver.PIPActions.localAudio.title,
|
|
678
|
+
PipActionReceiver.PIPActions.localAudio.description,
|
|
679
|
+
PendingIntent.getBroadcast(
|
|
680
|
+
reactApplicationContext,
|
|
681
|
+
PipActionReceiver.PIPActions.localAudio.requestCode,
|
|
682
|
+
Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(PipActionReceiver.PIPActions.localAudio.title, PipActionReceiver.PIPActions.localAudio.requestCode),
|
|
683
|
+
PendingIntent.FLAG_IMMUTABLE
|
|
684
|
+
)
|
|
685
|
+
)
|
|
701
686
|
)
|
|
702
|
-
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (config.showEndButton) {
|
|
690
|
+
pipRemoteActionsList.add(
|
|
691
|
+
android.app.RemoteAction(
|
|
692
|
+
android.graphics.drawable.Icon.createWithResource(reactApplicationContext, R.drawable.ic_call_end_24),
|
|
693
|
+
PipActionReceiver.PIPActions.endMeet.title,
|
|
694
|
+
PipActionReceiver.PIPActions.endMeet.description,
|
|
695
|
+
PendingIntent.getBroadcast(
|
|
696
|
+
reactApplicationContext,
|
|
697
|
+
PipActionReceiver.PIPActions.endMeet.requestCode,
|
|
698
|
+
Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
|
|
699
|
+
PipActionReceiver.PIPActions.endMeet.title,
|
|
700
|
+
PipActionReceiver.PIPActions.endMeet.requestCode
|
|
701
|
+
),
|
|
702
|
+
PendingIntent.FLAG_IMMUTABLE
|
|
703
|
+
)
|
|
704
|
+
)
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (config.showVideoButton && allowedPublishing?.contains("video") === true) {
|
|
709
|
+
pipRemoteActionsList.add(
|
|
710
|
+
android.app.RemoteAction(
|
|
711
|
+
android.graphics.drawable.Icon.createWithResource(
|
|
712
|
+
reactApplicationContext,
|
|
713
|
+
if (localPeer?.videoTrack?.isMute === true) R.drawable.ic_camera_toggle_off else R.drawable.ic_camera_toggle_on
|
|
714
|
+
),
|
|
715
|
+
PipActionReceiver.PIPActions.localVideo.title,
|
|
716
|
+
PipActionReceiver.PIPActions.localVideo.description,
|
|
717
|
+
PendingIntent.getBroadcast(
|
|
718
|
+
reactApplicationContext,
|
|
719
|
+
PipActionReceiver.PIPActions.localVideo.requestCode,
|
|
720
|
+
Intent(PipActionReceiver.PIP_INTENT_ACTION).putExtra(
|
|
721
|
+
PipActionReceiver.PIPActions.localVideo.title,
|
|
722
|
+
PipActionReceiver.PIPActions.localVideo.requestCode
|
|
723
|
+
),
|
|
724
|
+
PendingIntent.FLAG_IMMUTABLE
|
|
725
|
+
)
|
|
726
|
+
)
|
|
727
|
+
)
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
it.setActions(pipRemoteActionsList.filterIsInstance<android.app.RemoteAction>())
|
|
731
|
+
// endregion
|
|
703
732
|
|
|
704
733
|
it.build()
|
|
705
734
|
}
|
|
@@ -708,7 +737,11 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
708
737
|
}
|
|
709
738
|
|
|
710
739
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
711
|
-
private fun readableMapToPipParamConfig(data: ReadableMap?): PipParamConfig {
|
|
740
|
+
private fun readableMapToPipParamConfig(data: ReadableMap?): PipParamConfig? {
|
|
741
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
742
|
+
return null
|
|
743
|
+
}
|
|
744
|
+
|
|
712
745
|
var aspectRatio: Pair<Int, Int> = Pair(16, 9)
|
|
713
746
|
var showEndButton = false
|
|
714
747
|
var showAudioButton = false
|
|
@@ -772,22 +805,23 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
772
805
|
|
|
773
806
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
774
807
|
private fun setPictureInPictureParams(data: ReadableMap): Boolean {
|
|
808
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
809
|
+
return false
|
|
810
|
+
}
|
|
775
811
|
try {
|
|
776
812
|
if (!isPipModeSupported()) {
|
|
777
813
|
throw Throwable(message = "PIP Mode is not supported!")
|
|
778
814
|
}
|
|
779
815
|
|
|
780
|
-
val activity = currentActivity
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
val pipParamConfig = readableMapToPipParamConfig(data)
|
|
784
|
-
val pipParams = buildPipParams(pipParamConfig)
|
|
816
|
+
val activity = currentActivity ?: return false
|
|
817
|
+
val pipParamConfig = readableMapToPipParamConfig(data) ?: return false
|
|
818
|
+
val pipParams = buildPipParams(pipParamConfig) ?: return false
|
|
785
819
|
|
|
786
|
-
|
|
787
|
-
return
|
|
820
|
+
if (pipParams !is android.app.PictureInPictureParams) {
|
|
821
|
+
return false
|
|
788
822
|
}
|
|
789
|
-
|
|
790
|
-
return
|
|
823
|
+
activity.setPictureInPictureParams(pipParams)
|
|
824
|
+
return true
|
|
791
825
|
} catch (e: Exception) {
|
|
792
826
|
throw e
|
|
793
827
|
}
|
|
@@ -795,31 +829,35 @@ class HMSManager(reactContext: ReactApplicationContext) :
|
|
|
795
829
|
|
|
796
830
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
797
831
|
private fun isPipModeSupported(): Boolean {
|
|
832
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
833
|
+
return false
|
|
834
|
+
}
|
|
798
835
|
return reactApplicationContext.packageManager.hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)
|
|
799
836
|
}
|
|
800
837
|
|
|
801
838
|
@RequiresApi(Build.VERSION_CODES.O)
|
|
802
839
|
private fun enablePipMode(data: ReadableMap): Boolean {
|
|
840
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
841
|
+
return false
|
|
842
|
+
}
|
|
803
843
|
try {
|
|
804
844
|
if (!isPipModeSupported()) {
|
|
805
845
|
throw Throwable(message = "PIP Mode is not supported!")
|
|
806
846
|
}
|
|
807
847
|
|
|
808
|
-
val activity = currentActivity
|
|
848
|
+
val activity = currentActivity ?: return false
|
|
849
|
+
val pipParamConfig = readableMapToPipParamConfig(data) ?: return false
|
|
850
|
+
val pipParams = buildPipParams(pipParamConfig) ?: return false
|
|
809
851
|
|
|
810
|
-
if (
|
|
811
|
-
|
|
812
|
-
val pipParams = buildPipParams(pipParamConfig)
|
|
813
|
-
|
|
814
|
-
pipReceiver?.register(activity)
|
|
815
|
-
val entered = activity.enterPictureInPictureMode(pipParams)
|
|
816
|
-
if (entered === false) {
|
|
817
|
-
pipReceiver?.unregister(activity)
|
|
818
|
-
}
|
|
819
|
-
return entered
|
|
852
|
+
if (pipParams !is android.app.PictureInPictureParams) {
|
|
853
|
+
return false
|
|
820
854
|
}
|
|
821
|
-
|
|
822
|
-
|
|
855
|
+
pipReceiver?.register(activity)
|
|
856
|
+
val entered = activity.enterPictureInPictureMode(pipParams)
|
|
857
|
+
if (entered === false) {
|
|
858
|
+
pipReceiver?.unregister(activity)
|
|
859
|
+
}
|
|
860
|
+
return entered
|
|
823
861
|
} catch (e: Exception) {
|
|
824
862
|
throw e
|
|
825
863
|
}
|