本示例通过子窗口实现悬浮窗以及画中画功能实现视频小窗,介绍子窗口相关操作以及画中画功能。
Access rate limit exceeded. Please log in to continue.
Subwindow-based Floating Window
Overview
This sample shows how to use a subwindow to implement a floating window and use the PiP feature to implement a small video window.
Preview
| Home page |
|---|
![]() |
How to Use
- Touch the Subwindow - floating window button to go to the subwindow functional page.
- Touch the four buttons to view the four different operations in the subwindow.
- Touch the PiP - small video window to go to the PiP functional page.
- Touch enable PiP to create a small video window.
Project Directory
├──entry/src/main/ets/
│ ├──constants
│ │ └──CommonConstants.ets // Common constants
│ ├──entryability
│ │ └──EntryAbility.ets // Entry ability
│ ├──pages
│ │ ├──Index.ets // Home page
│ │ ├──MiniWindowPage.ets // Page for showing or hiding the subwindow
│ │ ├──NavigationRedirectPage.ets // Page for redirection from the subwindow to the PiP window through the Navigation component
│ │ ├──ResizeWindowPage.ets // Page for resizing the subwindow
│ │ ├──RouterRedirect.ets // Page for redirection from the subwindow to the home page through the router
│ │ └──RouterRedirectPage.ets // Redirection back to the home page through the router
│ ├──utils
│ │ └──Logger.ets // Log utility
│ ├──view
│ │ ├──MiniWindowComponent.ets // Custom components used to create, show, and hide the subwindow
│ │ ├──NavigationRedirectComponent.ets // Custom components used to redirect from the subwindow to the PiP window through the Navigation component
│ │ ├──PipWindowComponent.ets // Custom components for implementing the PiP feature
│ │ ├──ResizeWindowComponent.ets // Custom components used to resize the subwindow
│ │ └──SubWindowComponentRouter.ets // Custom components used to display routes in the floating window
│ └──viewmodel
│ ├──AVPlayerDemo.ets // Video playback control class
│ └──WindowPosition.ets // Subwindow position
└──entry/src/main/resources // Static resources
Required Permissions
N/A
Dependencies
N/A
Constraints
-
The sample app is supported only on Huawei phones running the standard system.
-
The HarmonyOS version must be HarmonyOS 5.0.5 Release or later.
-
The DevEco Studio version must be DevEco Studio 5.0.5 Release or later.
-
The HarmonyOS SDK version must be HarmonyOS 5.0.5 Release SDK or later.
