1# Local AVSession Overview 2 3## Interaction Process 4 5For a local AVSession, the data sources are on the local device. The figure below illustrates the interaction process. 6 7![Local AVSession Interaction Process](figures/local-avsession-interaction-process.png) 8 9This process involves two roles: provider and controller. 10 11In the local AVSession, the provider exchanges information with the controller through AVSessionManager. 12 131. The provider creates an **AVSession** object through AVSessionManager. 14 152. Through the **AVSession** object, the provider sets session metadata (such as the asset ID, title, and duration) and playback attributes (such as the playback state, speed, and position). 16 173. The controller creates an **AVSessionController** object through AVSessionManager. 18 194. Through the **AVSessionController** object, the controller listens for changes of the session metadata and playback attributes. 20 215. Through the **AVSessionController** object, the controller sends control commands to the **AVSession** object. 22 236. Through the **AVSession** object, the provider listens for the control commands, for example, play, playNext, fastForward, and setSpeed, from the controller. 24 25## AVSessionManager 26 27AVSessionManager 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. 28 29Unlike the **AVSession** and **AVSessionController** objects, AVSessionManager is not a specific object, but the root namespace of AVSessions. You can import AVSessionManager as follows: 30 31```ts 32import AVSessionManager from '@ohos.multimedia.avsession'; 33``` 34 35All the APIs in the root namespace can be used as APIs of AVSessionManager. 36 37The code snippet below shows how the provider creates an **AVSession** object by using AVSessionManager: 38 39```ts 40// Create an AVSession object. 41async createSession() { 42 let session: AVSessionManager.AVSession = await AVSessionManager.createAVSession(this.context, 'SESSION_NAME', 'audio'); 43 console.info(`session create done : sessionId : ${session.sessionId}`); 44} 45``` 46 47The code snippet below shows how the controller creates an **AVSessionController** object by using AVSessionManager: 48 49```ts 50// Create an AVSessionController object. 51async createController() { 52 // Obtain the descriptors of all live AVSession objects. 53 let descriptorsArray: Array<Readonly<AVSessionManager.AVSessionDescriptor>> = await AVSessionManager.getAllSessionDescriptors(); 54 if (descriptorsArray.length > 0) { 55 // For demonstration, the session ID of the first descriptor is used to create the AVSessionController object. 56 let sessionId: string = descriptorsArray[0].sessionId; 57 let avSessionController: AVSessionManager.AVSessionController = await AVSessionManager.createController(sessionId); 58 console.info(`controller create done : sessionId : ${avSessionController.sessionId}`); 59 } 60} 61``` 62 63For more information about AVSessionManager APIs, see [API Reference](../reference/apis/js-apis-avsession.md). 64