react-native-unified-player 0.4.0 → 0.4.1
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.
|
@@ -429,10 +429,15 @@ class UnifiedPlayerView(context: Context) : FrameLayout(context) {
|
|
|
429
429
|
val reactContext = context as? ReactContext ?: return
|
|
430
430
|
val activity = reactContext.currentActivity ?: return
|
|
431
431
|
|
|
432
|
+
// Alternative approach: Override the manifest setting temporarily
|
|
432
433
|
if (fullscreen) {
|
|
434
|
+
// Clear any portrait lock from manifest before entering fullscreen
|
|
435
|
+
overrideOrientationRestrictions(activity, true)
|
|
433
436
|
enterFullscreen(activity)
|
|
434
437
|
} else {
|
|
435
438
|
exitFullscreen(activity)
|
|
439
|
+
// Restore portrait lock after exiting fullscreen
|
|
440
|
+
overrideOrientationRestrictions(activity, false)
|
|
436
441
|
}
|
|
437
442
|
|
|
438
443
|
// Send event about fullscreen state change
|
|
@@ -441,14 +446,37 @@ class UnifiedPlayerView(context: Context) : FrameLayout(context) {
|
|
|
441
446
|
sendEvent(EVENT_FULLSCREEN_CHANGED, event)
|
|
442
447
|
}
|
|
443
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Override orientation restrictions from manifest
|
|
451
|
+
* This is a workaround for when android:screenOrientation="portrait" is set in manifest
|
|
452
|
+
*/
|
|
453
|
+
private fun overrideOrientationRestrictions(activity: Activity, enableLandscape: Boolean) {
|
|
454
|
+
try {
|
|
455
|
+
if (enableLandscape) {
|
|
456
|
+
// First set to unspecified to clear any manifest restrictions
|
|
457
|
+
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
|
458
|
+
// Small delay to ensure the change takes effect
|
|
459
|
+
Handler(Looper.getMainLooper()).postDelayed({
|
|
460
|
+
// Then set to sensor landscape
|
|
461
|
+
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
|
462
|
+
}, 50)
|
|
463
|
+
} else {
|
|
464
|
+
// Restore portrait orientation
|
|
465
|
+
activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
|
466
|
+
}
|
|
467
|
+
} catch (e: Exception) {
|
|
468
|
+
Log.e(TAG, "Failed to override orientation restrictions: ${e.message}")
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
444
472
|
private fun enterFullscreen(activity: Activity) {
|
|
445
473
|
Log.d(TAG, "Entering fullscreen mode")
|
|
446
474
|
|
|
447
475
|
// Save current orientation
|
|
448
476
|
originalOrientation = activity.requestedOrientation
|
|
449
477
|
|
|
450
|
-
//
|
|
451
|
-
|
|
478
|
+
// Note: Orientation change is already handled by overrideOrientationRestrictions()
|
|
479
|
+
// in setIsFullscreen() before this method is called
|
|
452
480
|
|
|
453
481
|
// Hide system UI for fullscreen
|
|
454
482
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
@@ -482,8 +510,8 @@ class UnifiedPlayerView(context: Context) : FrameLayout(context) {
|
|
|
482
510
|
private fun exitFullscreen(activity: Activity) {
|
|
483
511
|
Log.d(TAG, "Exiting fullscreen mode")
|
|
484
512
|
|
|
485
|
-
//
|
|
486
|
-
|
|
513
|
+
// Note: Orientation restoration is already handled by overrideOrientationRestrictions()
|
|
514
|
+
// in setIsFullscreen() after this method is called
|
|
487
515
|
|
|
488
516
|
// Restore system UI
|
|
489
517
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|