Best Practices for Adapting Video Players to iPhone Duo

Updated at:

This topic describes the core principles, integration recommendations, and verification methods for adapting video players to iPhone Duo, based on the PlayerKit adaptation experience.

Overview

As iPhone Duo introduces inner/outer screen switching, fold postures, and dynamic display areas, the space available to an app changes dynamically with the device form and window layout. How to keep picture display, interactions, and playback continuity while adapting to different display spaces is the core problem that video player adaptation for iPhone Duo must solve.

Alibaba Cloud PlayerKit has completed iPhone Duo adaptation. Its built-in player UI adjusts layout dynamically based on available display space while preserving the original interaction experience for short video, long video, and live streaming scenarios, which reduces business adaptation costs.

This topic is intended for the following two types of customers:

  • PlayerKit customers: Understand the existing adaptation capabilities, complete the version upgrade, and adapt the host container and custom UI.

  • Player SDK customers: Refer to the relevant design principles to complete foldable-screen adaptation for a self-built player UI.

Why adaptation is needed

Starting in April 2027, Apple requires iOS apps submitted to App Store Connect to be built with the iOS 27 SDK or later, with a minimum deployment target of iOS 15. To ensure that your app displays and responds correctly on iPhone Duo, complete layout adaptation and compatibility verification in advance.

iPhone Duo can be used in various holding and fold postures, and apps need to adapt to changes in the available display space.

iPhone Duo postures

The core adaptation principle is to dynamically lay out based on actual available space rather than adapting for individual device models. According to the Apple iPhone Duo design guidelines, combine container size, Size Class, Safe Area, and Reserved Region for dynamic layout instead of designing interfaces separately for each device posture.

After PlayerKit completes adaptation, the host app still needs to check the compatibility of page layouts and custom components to ensure a correct overall experience.

PlayerKit adaptation support and boundaries

Clarify responsibilities by integration method

Integration method

Provided by PlayerKit / player SDK

Business side responsible

PlayerKit default UI

Automatically responds to container size changes, handles fold-area and control avoidance, and layout adjustments do not affect the player instance

Host container, page layout, navigation, and fullscreen strategy

PlayerKit custom UI

Slot UI foundation, unified layout management, and layout interfaces such as contentLayoutBounds

Layout and interaction of custom controls, subtitles, and business panels

Player SDK only

Decoding, rendering, and playback control capabilities

Player UI, Reserved Region avoidance, fullscreen, and page state management

The PlayerKit default UI uses different avoidance strategies for the video picture and interactive controls, keeping controls operable while preserving as much display space as possible for the picture.

The built-in UI adjusts layout with the available space but preserves the original core interaction patterns for short video, long video, and live streaming. Business-extended content such as comments and episode lists is still handled by the host page or custom slots, avoiding coupling business layout to the player component.

Version and environment requirements

Item

Version requirements and description

PlayerKit

7.19.0 and later (includes the underlying player SDK)

Development environment

Xcode 27.1 and later, macOS Tahoe 26.6 and later

Build SDK

iOS 27.1 and later

Runtime environment

iOS 27.1 and later enables the Reserved Region API; older systems use conventional layout and Safe Area handling

PlayerKit handles compile-time and runtime compatibility for the new APIs, so you do not need to uniformly raise the minimum deployment target to adapt to iPhone Duo. However, compiling successfully, running compatibly, and enabling full adaptation capabilities are different concepts. Upgrading only the device OS or the underlying player SDK cannot replace PlayerKit adaptation work.

In addition, although the core PlayerKit podspec declares iOS 9.0 as the minimum, this does not mean that the entire project and its dependencies still support iOS 9.0 as a deployment target. The actual minimum deployment target also depends on the support ranges of Xcode and dependencies. Refer to Apple Xcode version requirements for details.

UIKit and SwiftUI: different technical paths, same adaptation principles

Apple provides iPhone Duo adaptation capabilities for both UIKit and SwiftUI. Both emphasize dynamic layout based on container size and system Reserved Regions, without designing UIs separately for each device posture.

Framework

Adaptation method

PlayerKit support status

UIKit

Use Auto Layout, Safe Area, and the Reserved Region API to dynamically adjust layout based on available space

PlayerKit currently uses UIKit and handles fold areas and occlusion avoidance at the slot layout layer

SwiftUI

Use system layout containers and GeometryReader to obtain the container size, query Reserved Regions through GeometryProxy, and adjust layout based on available space

You can integrate the UIKit player view through UIViewRepresentable, but a native SwiftUI implementation is not provided currently

The two frameworks have different implementations but the same adaptation principles. Choose the appropriate solution based on your existing technology stack; you do not need to migrate UI frameworks just to adapt to iPhone Duo.

How PlayerKit customers integrate

Make the host container respond to size changes

AliPlayerView internally adjusts layout automatically as its bounds change, but its position and size are still controlled by the host. Depending on your existing project, choose one of the following layout methods:

  • Autoresizing: Set UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight so that the player resizes with its parent container.

  • Auto Layout: Disable translatesAutoresizingMaskIntoConstraints and manage the player size through constraints.

  • Manual layout: In callbacks such as viewDidLayoutSubviews, update frame based on the container size instead of setting it only during initialization.

For embedded players, use the actual container size as the layout basis rather than directly using UIScreen.mainScreen.bounds. Also, do not equate landscape or fullscreen with sufficient space; you still must consider Safe Area, fold areas, and camera occlusion.

Custom slot adaptation for interactive areas

PlayerKit selects a continuous layout area for rendering and control slots that avoids fold areas based on current available space, and adjusts content layout according to each slot's avoidance strategy. The outer AliPlayerView size remains controlled by the host, and the actual video picture still depends on the scaling mode.

image

For custom UI, BaseSlot provides the read-only property contentLayoutBounds, which represents the content layout range after avoidance processing, in the slot's own coordinate system. Controls and content that need to avoid system Reserved Regions should be laid out within this range.

The following example shows how a BaseSlot subclass uses frame layout. It assumes that controlsView has already been created and added in setupContentView:

- (void)layoutSubviews {
2	    [super layoutSubviews];
3	    self.controlsView.frame = self.contentLayoutBounds;
4	}

contentLayoutBounds is updated as layout changes. Read it again in layoutSubviews; do not cache it or reapply the host's Safe Area Insets. The background can use bounds; interactive components should use contentLayoutBounds.

When you use Auto Layout, manage the content area through constraints and avoid mixing it with direct frame setting.

In addition, safeAreaEdges controls Safe Area avoidance at the slot root view, and avoidsOcclusion controls occlusion avoidance such as for the camera. Neither affects the basic fold-area avoidance rules.

Maintain fullscreen and playback state continuity

By default, PlayerKit completes fullscreen and rotation through an independent window within the same UIWindowScene. If the host already has a fullscreen container or orientation management strategy, you can customize the transition through playerView.fullscreenTransition to avoid conflicts with host layout and navigation logic.

Size changes caused by device folding, rotation, and so on only require UI layout updates. Do not call configure:, detach, or destroy again, and do not actively pause or re-prepare the video, so that playback progress, pause state, and playback speed remain continuous.

The handling of UI state and temporary interactions should follow the original business rules; see State continuity: decouple layout changes from playback lifecycle.

Page exit and foreground/background switching still follow the original lifecycle strategy. If autoLifecycleManagement is disabled, the host must manage playback pause and resume itself.

How customers using only the player SDK adapt

For customers who integrate the player SDK directly, iPhone Duo adaptation focuses on the player UI layer. You do not need to replace the playback kernel or introduce PlayerKit, but you still need to confirm compatibility between the existing SDK and the target system.

  1. Respond to dynamic layout. Make the video rendering container and control layer adjust layout with container size, Safe Area, and trait changes. Avoid using fixed screen sizes or device-model checks. Layout updates must not cause player instance reconstruction.

  2. Maintain the aspect ratio. Long videos usually use proportional fit with letterboxing allowed, and short videos can use proportional crop based on business requirements. Avoid direct stretching. The PlayerKit equivalents are ScaleModeFitCenter and ScaleModeCenterCrop. When you use the player SDK directly, choose the corresponding scaling mode.

  3. Handle system Reserved Regions. Prefer system adaptive layout and Safe Area. For scenes where fold areas, cameras, or other elements may occlude custom content, obtain the region information through the Reserved Region API and update the layout when the device form or window environment changes. Avoid hard-coding fold positions.

  4. Ensure interaction reachability. When space is insufficient, you can collapse secondary actions but should keep the operation entry and a reasonable touch area. Components such as progress bars, subtitles, comments, and pop-up panels also need adaptation; do not adjust only the video picture.

For UIKit customers who need fine-grained layout control, see UIView Reserved Region and query fold divisions and occlusion regions through the Objective-C interface reservedRegionsOfKind:.

For implementation details, see the layout and slot adaptation solution in PlayerKit-iOS and the Apple Reserved Region official documentation.

Core design and practical experience

When you integrate the player SDK directly, the business side is mainly responsible for adapting its self-built player UI. As a reusable UI component, PlayerKit must adapt its built-in UI and also provide a stable, reusable adaptation foundation for extended UIs built on top of it.

This change follows the existing slot architecture. While preserving the existing UI and business behavior, it centralizes available-area calculation, fold-area avoidance, and layout updates in the framework so that the default UI and custom slots that follow the layout contract can reuse them. How components are composed, what visual style is used, and which business interactions are provided are still decided by the upper layer. The value of the slot architecture is to solve common problems centrally, not to take over more business UI.

Dynamic layout: from device posture to available space

image

Device posture alone does not determine player layout. Under the same posture, the player may be in a fullscreen, card, or split-view container. Therefore, the six iPhone Duo form factors and landscape/portrait combinations should be included in the verification matrix, but this does not mean that layout logic needs to be implemented separately for each. A more reasonable approach is to use actual container size, Safe Area, and Reserved Region as the layout basis.

This principle is implemented through the existing PlayerKit slot architecture: the host manages the outer container size, AliPlayerView manages internal layout, and SlotHostLayout uniformly computes the continuous available area. Each slot then determines its content layout range based on its own avoidance strategy; the arrangement and interaction inside custom components are still the business side's responsibility.

Here you need to distinguish presentation state from layout capacity: fullscreen indicates how the player is presented and does not necessarily mean that space is sufficient. For example, whether the exit fullscreen button is displayed depends on the fullscreen state, while how many actions the control bar can hold depends on the actual available width. Even in fullscreen, a fold area may narrow the control area.

Adaptation does not mean that all controls must scale proportionally with the screen either. Button sizes and component spacing can keep their original design; the important thing is to avoid hard-coding the screen width or assuming that a given orientation always has sufficient space. When space is insufficient, adjust the arrangement of components or collapse secondary actions first while keeping the necessary operation entries, instead of shrinking the entire UI until it becomes hard to tap.

The following figure uses the same 16:9 video in aspect-fit full display as an example to show the player layout under different available spaces. The combination of primary and secondary content is chosen by the host, not an automatic result of switching the default UI.

Player layouts under different postures and optional host combinations

Layout principle illustration, not a screenshot of a real device. Blue indicates the rendering container, and the green dashed line indicates the safe layout range for controls. The actual layout is subject to the system Reserved Region and the current available space.

Practical experience: Presentation state determines the meaning of operations, and available space determines layout capacity. When space changes, adjust how the UI is organized first, instead of designing an interface for every posture or shrinking all controls proportionally.

Fold-area adaptation: trade-offs between picture continuity and control reachability

image

A foldable screen does not mean a better playback experience just because the display area is larger. For fold areas, the player must balance picture integrity, operability of control components, and layout requirements of different business scenarios.

Layout approach

Applicable scenario

Main trade-off

Cross-fold display

Large picture or immersive background

Makes full use of display space, but the fold area may affect picture continuity

Split-area composition

Video paired with comments, episode list, or information area

Makes full use of both sides, but requires reorganizing content and interaction

Continuous-region layout (default)

Keep existing player UI

Guarantees picture and control integrity, but some space may be underutilized

Short video, long video, and live streaming have different requirements for content composition and interaction, and PlayerKit should not force a unified layout or add extra business panels just because the screen is unfolded. Therefore, the default choice is the largest continuous available area that avoids the fold area, so that the picture is not divided by the fold area and the original interaction patterns are preserved.

If a business needs to display the video together with comments, episode lists, or other primary and secondary content, the host can organize a two-area layout and consider UIKit's UIArrangementViewController or SwiftUI's ArrangementView for cross-area composition.

In the default layout, the rendering area and the control layout range use different avoidance strategies:

image

Layout principle illustration: blue indicates the rendering container with controls overlaid on it. The actual video picture range is determined by the scaling mode.

  • Rendering area: Prioritizes picture continuity and can extend to system occlusion regions such as the camera based on business requirements, but part of the picture in this area may be physically occluded, and the actual display effect also depends on the video scaling mode.

  • Interactive area: Buttons, progress bars, and other key controls must remain visible and operable; this area requires additional consideration of Safe Area and camera occlusion.

The Reserved Region provided by UIKit can distinguish between fold divisions (Division) and occlusion regions (Occlusion). PlayerKit first unifies the coordinate system, computes the continuous available area that avoids the fold area based on Division, and then combines Safe Area, Occlusion, and each slot's avoidance strategy to determine the final layout range.

Note the following when calculating: the frame returned by the Reserved Region is in the coordinate system of the current UIView and already includes the corresponding margins, so it must not be added again.

Region calculation is also not a one-off. Reserved Region changes do not necessarily accompany container size changes: for example, camera on/off may change the occlusion region while bounds remains unchanged. Therefore, PlayerKit reads the Reserved Region in updateConstraints, uses UIKit's automatic tracking mechanism to respond to changes, and recomputes layout combined with window migration and Safe Area updates.

With a unified region calculation and update mechanism, custom slots can reuse the contentLayoutBounds described in Custom slot adaptation for interactive areas without handling low-level region calculation themselves. However, a correct layout for a single component does not mean that multiple components will reliably work together. For example, the bottom bar and subtitles may overlap, and a new overlay may intercept existing gestures. Therefore, custom slots also need to pay attention to three aspects:

  • Space collaboration: Organize component layout and view hierarchy properly to avoid mutual occlusion between different slots.

  • Event collaboration: Dispatch touch events correctly so that overlays do not unexpectedly intercept interactions with underlying components.

  • Lifecycle collaboration: Follow the slot lifecycle conventions to avoid state residue after components are dynamically added, removed, or updated.

Practical experience: Unify the calculation and update of the available area, and ensure the reliability of the overall player layout and interaction through clear component collaboration rules.

State continuity: decouple layout changes from playback lifecycle

Device folding, unfolding, or rotation is essentially a change in display space and should not trigger player reinitialization. Otherwise, even if the final layout is correct, playback may be interrupted, progress may be lost, or UI state may be reset. Therefore, adaptation must check not only screenshots after the change, but also whether playback and interaction behave as expected during the change.

image

PlayerKit limits layout adjustments to the UI layer, adapting to the new display space by updating container and slot layouts without reconfiguring or rebuilding the player instance, thereby keeping the playback source, progress, pause state, and playback speed continuous. UI states such as control bar visibility and panel state are retained or adjusted according to the original business logic.

State continuity does not mean that all states are preserved as they are. Playback state should not be reset because of layout changes; temporary states such as drag start points and gesture displacement depend on old coordinates and need to be recalculated, or the interaction should be explicitly ended or canceled.

For example, after the progress bar width changes, you should not continue to convert gesture displacement into playback progress using the old width. After a layout change, interactions such as long-press speed change should determine whether they can continue; if they cannot, they should be ended or canceled. When an interaction ends or is canceled, restore the playback speed according to the original rules.

Compatibility means not only that public APIs remain unchanged, but also that the meaning of existing operations and behavioral conventions remain unchanged. Control positions can be adjusted, but the meaning of playback operations should not change; back navigation and fullscreen restoration should still follow the host's original strategy.

Layout adaptation should not change the host's lifecycle and fullscreen management strategy. Page exit and foreground/background switching continue to follow the existing rules; when navigation, orientation management, or parent-view constraints are involved, the host coordinates through custom fullscreen transitions.

Practical experience: The same playback session should continuously adapt to new display space. Playback state remains continuous, UI state follows business logic, and temporary interactions have clear rules for continuing, ending, and canceling, instead of refreshing the interface by rebuilding the player.

Adaptation verification and testing recommendations

We recommend using a physical iPhone Duo device for adaptation and debugging, and turning the six device postures and landscape/portrait combinations into twelve basic verification scenarios. In addition to checking the layout in each scenario, also cover posture switching, container scaling, and Reserved Region changes to verify playback continuity and interaction stability.

Verification item

Acceptance criteria

Inner/outer screen switching, continuous folding/unfolding, and container scaling

Aspect ratio is normal, no layout misalignment or old-size residue remains, and the player does not reinitialize due to layout changes

Partial folding, camera on/off, and Safe Area changes

Controls avoid fold areas and occlusion, layout updates promptly when the Reserved Region changes, and the layout can recover

Progress dragging, long-press speed change, and panel display while changing device form

Gestures end or cancel normally, no temporary state remains, and menus and operation entries remain available

Play, pause, buffering, and playback completion while switching device form

The video does not unexpectedly replay or resume after being paused; progress, speed, and UI state remain consistent

Fullscreen switching, page navigation, and foreground/background switching

The player correctly recovers its layout without affecting host navigation, orientation strategy, or other player instances

Dynamic composition of custom slots and overlay display and removal

No unexpected occlusion between components, touch events are dispatched correctly, and no state remains after dynamic addition or removal

Test materials should cover horizontal, vertical, and non-standard aspect-ratio videos, and verify short video, long video, and live streaming scenarios separately. Functions such as custom subtitles, audio track selection, and business panels can be supplemented based on actual integration.

Important

The ApsaraVideo Player SDK currently does not support running on a simulator and does not provide XCFramework integration yet, so we recommend completing full player verification on a physical device. For independent UI layout that does not depend on the player SDK, you can also refer to Apple's Device Hub for auxiliary testing.