# AudioInteraction **Repository Path**: robbin0922/audio-interaction ## Basic Information - **Project Name**: AudioInteraction - **Description**: 本场景解决方案主要面向前台音频开发人员。指导开发者基于AudioRenderer开发音频播控功能。功能包括后台播放、和播控中心的交互、适配不同类型的焦点打断策略、切换路由发声设备、切换输出设备等基础音频常见功能。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 47 - **Created**: 2025-03-19 - **Last Updated**: 2025-03-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 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 | |-----------------------------------------|------------------------------------------| | ![](screenshots/device/MainPage.en.png) | ![](screenshots/device/LyricPage.en.png) | #### 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 1. The sample app is supported only on Huawei phones running the standard system. 2. The HarmonyOS version must be HarmonyOS NEXT Beta1 or later. 3. The DevEco Studio version must be DevEco Studio NEXT Beta1 or later. 4. The HarmonyOS SDK version must be HarmonyOS NEXT Beta1 or later.