How Hema Achieved Seamless Cross‑Page Video Playback on iOS

This article explains how Hema implemented a seamless, cross‑page short‑video playback experience on iOS by reusing player views, handling size‑change animations, mode transitions, active recycling, and state isolation to deliver uninterrupted video immersion.

Alibaba Terminal Technology
Alibaba Terminal Technology
Alibaba Terminal Technology
How Hema Achieved Seamless Cross‑Page Video Playback on iOS

In today’s video‑centric mobile world, short video is a key engagement point, and Hema has added a “seamless cross‑page playback” feature to improve user experience on iOS.

Goals:

Simple integration – only one extra parameter is needed.

Good adaptability, supporting cut‑mode switching.

Video and audio transition without any pause.

Playback state isolation between pages.

Implementation approach:

Hema chose the third option – reusing a playerView. The process includes:

User taps a link from page A to page B, adding a reusedPlayerView parameter (e.g., domain/path?reusedPlayerView=0xyyyyyy).

Page B instantiates HMTBPlayerView, either creating a new instance or reusing the one from page A.

Calculate size and position changes to drive the transition animation.

When returning from page B to page A, play the exit animation and return the playerView.

Size‑change animation:

Because the internal player overrides setFrame, a simple frame animation does not work. Instead, the final frame is set first, the scale ratio is computed, and

playerView.transform = CGAffineTransformMakeScale(ratio, ratio)

is applied, then animated.

Render mode switching:

When the source page uses ScaleAspectFill (square) and the destination page uses ScaleAspectFit (9:16), a mask view is used to transition smoothly. The mask view’s scale is calculated and applied via playerView.maskView.transform.

CGAffineTransformMakeScale(originalRect.size.width/(destRect.size.width*ratio), originalRect.size.height/(destRect.size.height*ratio))

Active recycling and return strategy:

If a reusable playerView exists, borrow it.

When the borrowed view is no longer needed, return it promptly.

If the owner needs the view while it is still borrowed, actively reclaim it.

State isolation:

Even though the same playerView is shared, its playback state and settings must be isolated per page (e.g., pause on page A, play on page B; mute on A, sound on B). Hema wraps the third‑party player inside a custom HMTBPlayerView so that page‑specific settings are reapplied after each reuse.

Summary:

Hema implemented a player‑view reuse mechanism that handles window transition, mode switching, active recycling, and state isolation, providing an almost invisible seamless playback experience. The solution can also be extended to global player reuse across the app.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Mobile DevelopmentanimationiOSvideo playbackplayer view reuseseamless
Alibaba Terminal Technology
Written by

Alibaba Terminal Technology

Official public account of Alibaba Terminal

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.