本场景解决方案主要面向前台音频开发人员。指导开发者基于AudioRenderer开发音频播控功能。功能包括后台播放、和播控中心的交互、适配不同类型的焦点打断策略、切换路由发声设备、切换输出设备等基础音频常见功能。
| Files | Last commit | Last update |
|---|---|---|
| 9 months ago | ||
| 9 months ago | ||
| 2 years ago | ||
| 1 year ago | ||
| 9 months ago | ||
| 2 years ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 2 years ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 9 months ago | ||
| 2 years ago | ||
| 2 years ago | ||
| 9 months ago | ||
| 2 years ago |
Audio Playback Control Based on AudioRenderer
Overview
This sample demonstrates an audio app that implements audio playback control based on AudioRenderer. It provides the following features: background playback, interaction with the media controller, adaptation to different focus interruption policies, switching between routing sound devices, and switching between output devices.
Preview
| Home page | Lyrics page |
|---|---|
![]() |
![]() |
Project Directory
├──entry/src/main/ets/
│ ├──common
│ │ ├──constants // Constants
│ │ └──utils // Utils
│ ├──components // Module components
│ │ ├──ControlAreaComponent.ets // Components in the audio control area
│ │ ├──LyricsComponent.ets // Lyrics components
│ │ ├──MusicInfoComponent.ets // Music content components
│ │ ├──PlayerInfoComponent.ets // Components in the playback control content area
│ │ └──TopAreaComponent.ets // Top area components
│ ├──dataSource // Playlist data
│ │ ├──SongDataSource.ets // Song data
│ │ └──SongListData.ets // Song list data
│ ├──entryability
│ │ └──EntryAbility.ets // Entry ability lifecycle callbacks
│ ├──entrybackupability
│ │ └──EntryBackupAbility.ets // EntryBackupAbility lifecycle callbacks
│ ├──lyric // Lyrics
│ └──pages // Pages
├──MediaService/src/main/ets
│ ├──songDataController // Song information
│ │ ├──PlayerData.ets // Playback data
│ │ ├──SongData.ets // Song source data
│ │ └──SongItemBuilder.ets // Song combination data
│ └──utils
│ ├──AudioRendererController.ets // Audio playback control
│ ├──AVSessionController.ets // AVSession control
│ ├──BackgroundUtil.ets // Background playback
│ ├──Logger.ets // Log utility
│ ├──MediaTools.ets // Media data conversion utility class
│ └──PreferencesUtil.ets // Preferences storage
└──entry/src/main/resources // Static resources
Required Permissions
ohos.permission.KEEP_BACKGROUND_RUNNING: allows an app to run in the background.
Dependencies
N/A
Constraints
- The sample app is supported only on Huawei phones running the standard system.
- The HarmonyOS version must be HarmonyOS NEXT Beta1 or later.
- The DevEco Studio version must be DevEco Studio NEXT Beta1 or later.
- The HarmonyOS SDK version must be HarmonyOS NEXT Beta1 or later.
Introduction
本场景解决方案主要面向前台音频开发人员。指导开发者基于AudioRenderer开发音频播控功能。功能包括后台播放、和播控中心的交互、适配不同类型的焦点打断策略、切换路由发声设备、切换输出设备等基础音频常见功能。
Customize your domain
