1e41f4b71Sopenharmony_ci# Introduction to AVSession Kit 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciAudio and Video Session (AVSession) Kit provides the audio and video management service, which manages the playback behavior of all audio and video applications in the system in a unified manner. You can use the kit to quickly build unified audio and video display and control capabilities. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci## Capability Scope 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci- Unified audio and video management: Audio and video applications access AVSession and send it application data (for example, the song that is being played and the playback state). Through a controller, the user can choose another application or device for playback. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci- Restricted audio background playback: After an audio application accesses AVSession, it can continue audio playback in the background. To use this feature, the application must also request a background task. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Highlights 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci- Consistent user experience 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci Audio and video applications access AVSession and send it application data (for example, the song that is being played and the playback state). 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci Through a controller, the user can choose another application or device for playback. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci- Standardize background playback management 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci Through the controller, the background playback of applications is visible and controllable. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci The system forcibly controls background playback. When an application that does not access AVSession switches to the background, its audio playback is forcibly paused. This prevents malicious applications from playing audio in the background. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci## Basic Concepts 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ciBe familiar with the following basic concepts before development: 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci- AVSession 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci For AVSession, one end is the audio and video applications under control, and the other end is a controller (for example, Media Controller or AI Voice). AVSession provides a channel for information exchange between the application and controller. 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci- Provider 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci An audio and video application that accesses the AVSession service. After accessing AVSession, the audio and video application must provide the media information, for example, the name of the item to play and the playback state, to AVSession. Through AVSession, the application also receives control commands from the controller and responds accordingly. 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci- Controller 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci A system application that accesses AVSession to provide global control on audio and video playback behavior. Typical controllers are Media Controller and AI Voice. The following sections use Media Controller as an example of the controller. After accessing AVSession, the controller obtains the latest media information and sends control commands to the audio and video applications through AVSession. 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci- AVSessionController 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci An object that controls the playback behavior of the provider. It obtains the playback information of the audio and video application and listens for the application playback changes to synchronize the AVSession information between the application and controller. The controller is the holder of an **AVSessionController** object. 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci- AVSessionManager 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci An object that provides the capability of managing sessions. It can create an **AVSession** object, create an **AVSessionController** object, send control commands, and listen for session state changes. 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci## AVSession Interaction Process 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ciAVSessions are classified into local AVSessions and distributed AVSessions. 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci- Local AVSession 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci Local AVSession establishes a connection between the provider and controller in the local device, so as to implement unified playback control and media information display for audio and video applications in the system. 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci- Distributed AVSession 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci Distributed AVSession establishes a connection between the provider and controller in the cross-device scenario, so as to implement cross-device playback control and media information display for audio and video applications in the system. For example, you can project the content played on device A to device B and perform playback control on device B. 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ci## Constraints 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ciAll audio and video applications that need to be played in the background must be connected to AVSession and background task management. Otherwise, audio playback is forcibly paused when such an application switches to the background. 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci## Relationship with Related Kits 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ciTo implement background playback, an application must use [Background Tasks Kit](../../task-management/background-task-overview.md) to request a continuous task to avoid being suspended. 70