| Files | Last commit | Last update |
|---|---|---|
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 8 months ago | ||
| 8 months ago | ||
| 1 year ago | ||
| 1 year ago | ||
| 1 year ago |
Video Player
Overview
This sample demonstrates how to develop a video app using the AVPlayer and AVSession capabilities provided by HarmonyOS.
Preview

How to Use
-
After the app is launched, the video playlist is displayed and the first video is automatically played.
-
Touch the button on the screen to switch between portrait and landscape modes.
-
Swipe up or down to switch between videos, and view historical playback records.
-
Drag the progress bar or swipe in full-screen mode to adjust the playback progress.
-
When the app is switched to the background, the playback can continue. You can control the playback in the Media Controller.
Project Directory
├──entry/src/main/ets
│ ├──entryability
│ │ └──EntryAbility.ets // Entry ability
│ ├──model
│ │ ├──BasicDataSource.ets // Lazy loading data sources
│ │ └──DataModel.ets // Data classes
│ ├──pages
│ │ └──IndexPage.ets // Home page
│ ├──utils
│ │ ├──WindowUtil.ets // Window utility class
│ │ └──BreakpointSystem.ets // Breakpoint utility class
│ └──view
│ ├──AVPlayer.ets // Video component
│ ├──VideoList.ets // Video list on the home page
│ ├──VideoSide.ets // Video swiper components
│ └──VideoDetails.ets // Video details components
├──entry/src/main/resources // Static resources
└──MediaService/src/main/ets
│ ├──common
│ │ └──CommonConstants.ets // Common constants
│ ├──controller
│ │ ├──AvPlayerController.ets // Video playback control
│ │ ├──AvSessionController.ets // AVSession control
│ │ └──AvSessionControllerPCode.ets // AVSession control pseudocode
│ ├──model
│ │ └──VideoData.ets // Video data class
│ └──utils
│ ├──BackgroundTaskManager.etss // Background playback
│ ├──CommUtils.ets // Utility class
│ └──Logger.ets // Image pixel processing class
└──MediaService/src/main/resources // Log utility
Required Permissions
-
ohos.permission.KEEP_BACKGROUND_RUNNING: allows an app to run in the background.
-
ohos.permission.INTERNET: allows an app to access the Internet.
Constraints
-
The sample is only supported on Huawei phones with standard systems.
-
The HarmonyOS version must be HarmonyOS 6.0.0 Release or later.
-
The DevEco Studio version must be DevEco Studio 6.0.0 Release or later.
-
The HarmonyOS SDK version must be HarmonyOS 6.0.0 Release SDK or later.