1/* 2* Copyright (c) 2022-2023 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16/** 17 * @file 18 * @kit AVSessionKit 19 */ 20 21import type { ErrorCallback, AsyncCallback, Callback } from './@ohos.base'; 22import { WantAgent } from './@ohos.wantAgent'; 23import { KeyEvent } from './@ohos.multimodalInput.keyEvent'; 24import { ElementName } from './bundleManager/ElementName'; 25import image from './@ohos.multimedia.image'; 26import audio from './@ohos.multimedia.audio'; 27import type media from './@ohos.multimedia.media'; 28import type Context from './application/BaseContext'; 29 30/** 31 * @namespace avSession 32 * @syscap SystemCapability.Multimedia.AVSession.Core 33 * @since 9 34 */ 35/** 36 * @namespace avSession 37 * @syscap SystemCapability.Multimedia.AVSession.Core 38 * @atomicservice 39 * @since 12 40 */ 41 42declare namespace avSession { 43 /** 44 * Create an AVSession instance. An ability can only create one AVSession 45 * @param { Context } context - The context of application 46 * @param { string } tag - A user-defined name for this session 47 * @param { AVSessionType } type - The type of session {@link AVSessionType} 48 * @param { AsyncCallback<AVSession> } callback - async callback for AVSession. 49 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 50 * 2.Parameter verification failed. 51 * @throws { BusinessError } 6600101 - Session service exception. 52 * @syscap SystemCapability.Multimedia.AVSession.Core 53 * @since 10 54 */ 55 function createAVSession(context: Context, tag: string, type: AVSessionType, callback: AsyncCallback<AVSession>): void; 56 57 /** 58 * Create an AVSession instance. An ability can only create one AVSession 59 * @param { Context } context - The context of application 60 * @param { string } tag - A user-defined name for this session 61 * @param { AVSessionType } type - The type of session {@link AVSessionType} 62 * @returns { Promise<AVSession> } Promise for AVSession 63 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 64 * 2.Parameter verification failed. 65 * @throws { BusinessError } 6600101 - Session service exception. 66 * @syscap SystemCapability.Multimedia.AVSession.Core 67 * @since 10 68 */ 69 /** 70 * Create an AVSession instance. An ability can only create one AVSession 71 * @param { Context } context - The context of application 72 * @param { string } tag - A user-defined name for this session 73 * @param { AVSessionType } type - The type of session {@link AVSessionType} 74 * @returns { Promise<AVSession> } Promise for AVSession 75 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 76 * 2.Parameter verification failed. 77 * @throws { BusinessError } 6600101 - Session service exception. 78 * @syscap SystemCapability.Multimedia.AVSession.Core 79 * @atomicservice 80 * @since 12 81 */ 82 function createAVSession(context: Context, tag: string, type: AVSessionType): Promise<AVSession>; 83 84 /** 85 * Get all avsession descriptors of the system 86 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 87 * @param { AsyncCallback<Array<Readonly<AVSessionDescriptor>>> } callback - async callback for an array of AVSessionDescriptors. 88 * @throws { BusinessError } 201 - permission denied 89 * @throws { BusinessError } 6600101 - Session service exception. 90 * @syscap SystemCapability.Multimedia.AVSession.Manager 91 * @systemapi 92 * @since 9 93 */ 94 function getAllSessionDescriptors(callback: AsyncCallback<Array<Readonly<AVSessionDescriptor>>>): void; 95 96 /** 97 * Get all avsession descriptors of the system 98 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 99 * @returns { Promise<Array<Readonly<AVSessionDescriptor>>> } Promise for an array of AVSessionDescriptors 100 * @throws { BusinessError } 201 - permission denied 101 * @throws { BusinessError } 6600101 - Session service exception. 102 * @syscap SystemCapability.Multimedia.AVSession.Manager 103 * @systemapi 104 * @since 9 105 */ 106 function getAllSessionDescriptors(): Promise<Array<Readonly<AVSessionDescriptor>>>; 107 108 /** 109 * Get history avsession records. These sessions have been destroyed. 110 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 111 * @param { number } maxSize - Specifies the maximum size of the returned value array. 112 * @param { AsyncCallback<Array<Readonly<AVSessionDescriptor>>> } callback - async callback for an array of AVSessionDescriptors. 113 * If provided '0' or not provided, the maximum value is determined by the system. 114 * @throws { BusinessError } 401 - parameter check failed. Possible causes: 1.Mandatory parameters are left unspecified. 115 * 2.Incorrect parameter types. 116 * @throws { BusinessError } 6600101 - Session service exception. 117 * @syscap SystemCapability.Multimedia.AVSession.Manager 118 * @systemapi Hide this for inner system use 119 * @since 10 120 */ 121 function getHistoricalSessionDescriptors(maxSize: number, callback: AsyncCallback<Array<Readonly<AVSessionDescriptor>>>): void; 122 123 /** 124 * Get history avsession records. These sessions have been destroyed. 125 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 126 * @param { number } maxSize - Specifies the maximum size of the returned value array. 127 * If provided '0' or not provided, the maximum value is determined by the system. 128 * @returns { Promise<Array<Readonly<AVSessionDescriptor>>> } Promise for an array of AVSessionDescriptors 129 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 130 * 2.Incorrect parameter types. 131 * @throws { BusinessError } 6600101 - Session service exception. 132 * @syscap SystemCapability.Multimedia.AVSession.Manager 133 * @systemapi Hide this for inner system use 134 * @since 10 135 */ 136 function getHistoricalSessionDescriptors(maxSize?: number): Promise<Array<Readonly<AVSessionDescriptor>>>; 137 138 /** 139 * Get history play list information records. 140 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 141 * @param { number } maxSize - Specifies the maximum size of the returned value array. 142 * @param { number } maxAppSize - Specifies the maximum app size of the returned value array. 143 * @param { AsyncCallback<Array<Readonly<AVQueueInfo>>> } callback - async callback for an array of AVQueueInfo. 144 * If provided '0' or not provided, the maximum value is determined by the system. 145 * @throws { BusinessError } 201 - permission denied 146 * @throws { BusinessError } 202 - Not System App. 147 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 148 * 2.Incorrect parameter types. 149 * @throws { BusinessError } 6600101 - Session service exception. 150 * @syscap SystemCapability.Multimedia.AVSession.Manager 151 * @systemapi Hide this for inner system use 152 * @since 11 153 */ 154 function getHistoricalAVQueueInfos(maxSize: number, maxAppSize: number, callback: AsyncCallback<Array<Readonly<AVQueueInfo>>>): void; 155 156 /** 157 * Get history play list information records. 158 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 159 * @param { number } maxSize - Specifies the maximum size of the returned value array. 160 * @param { number } maxAppSize - Specifies the maximum app size of the returned value array. 161 * @returns { Promise<Array<Readonly<AVQueueInfo>>> } Promise for an array of AVQueueInfo 162 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 163 * 2.Incorrect parameter types. 164 * @throws { BusinessError } 6600101 - Session service exception. 165 * @syscap SystemCapability.Multimedia.AVSession.Manager 166 * @systemapi Hide this for inner system use 167 * @since 11 168 */ 169 function getHistoricalAVQueueInfos(maxSize: number, maxAppSize: number): Promise<Array<Readonly<AVQueueInfo>>>; 170 171 /** 172 * Create an avsession controller 173 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 174 * @param { string } sessionId - Specifies the sessionId to create the controller. 175 * @param { AsyncCallback<AVSessionController> } callback - async callback for AVSessionController. 176 * If provided 'default', the system will create a default controller, Used to control the system default session 177 * @throws { BusinessError } 201 - permission denied 178 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 179 * 2.Parameter verification failed. 180 * @throws { BusinessError } 6600101 - Session service exception. 181 * @throws { BusinessError } 6600102 - The session does not exist. 182 * @syscap SystemCapability.Multimedia.AVSession.Manager 183 * @systemapi 184 * @since 9 185 */ 186 function createController(sessionId: string, callback: AsyncCallback<AVSessionController>): void; 187 188 /** 189 * Create an avsession controller 190 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 191 * @param { string } sessionId - Specifies the sessionId to create the controller. 192 * If provided 'default', the system will create a default controller, Used to control the system default session 193 * @returns { Promise<AVSessionController> } Promise for AVSessionController 194 * @throws { BusinessError } 201 - permission denied 195 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 196 * 2.Parameter verification failed. 197 * @throws { BusinessError } 6600101 - Session service exception. 198 * @throws { BusinessError } 6600102 - The session does not exist. 199 * @syscap SystemCapability.Multimedia.AVSession.Manager 200 * @systemapi 201 * @since 9 202 */ 203 function createController(sessionId: string): Promise<AVSessionController>; 204 205 /** 206 * Cast Audio to the remote devices or cast back local device 207 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 208 * @param { SessionToken | 'all' } session - Specifies the sessionId which to send to remote. 209 * @param { Array<audio.AudioDeviceDescriptor> } audioDevices - Specifies the audio devices to cast. 210 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 211 * 'all' means cast all the media audio of this device to remote. 212 * @throws { BusinessError } 201 - permission denied 213 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 214 * 2.Parameter verification failed. 215 * @throws { BusinessError } 6600101 - Session service exception. 216 * @throws { BusinessError } 6600102 - The session does not exist. 217 * @throws { BusinessError } 6600104 - The remote session connection failed. 218 * @syscap SystemCapability.Multimedia.AVSession.Manager 219 * @systemapi 220 * @since 9 221 */ 222 function castAudio(session: SessionToken | 'all', audioDevices: Array<audio.AudioDeviceDescriptor>, callback: AsyncCallback<void>): void; 223 224 /** 225 * Cast Audio to the remote devices or cast back local device 226 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 227 * @param { SessionToken | 'all' } session - Specifies the sessionId which to send to remote. 228 * @param { Array<audio.AudioDeviceDescriptor> } audioDevices - Specifies the audio devices to cast. 229 * @returns { Promise<void> } void promise when executed successfully 230 * 'all' means cast all the media audio of this device to remote. 231 * @throws { BusinessError } 201 - permission denied 232 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 233 * 2.Parameter verification failed. 234 * @throws { BusinessError } 6600101 - Session service exception. 235 * @throws { BusinessError } 6600102 - The session does not exist. 236 * @throws { BusinessError } 6600104 - The remote session connection failed. 237 * @syscap SystemCapability.Multimedia.AVSession.Manager 238 * @systemapi 239 * @since 9 240 */ 241 function castAudio(session: SessionToken | 'all', audioDevices: Array<audio.AudioDeviceDescriptor>): Promise<void>; 242 243 /** 244 * Start an application for media playback. 245 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 246 * @param { string } bundleName - Specifies the bundleName which to be started. 247 * @param { string } assetId - Specifies the assetId to be started. 248 * @returns { Promise<void> } void promise when executed successfully 249 * @throws { BusinessError } 201 - permission denied 250 * @throws { BusinessError } 202 - Not System App. Interface caller is not a system app. 251 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 252 * 2.Incorrect parameter types. 3.Parameter verification failed. 253 * @throws { BusinessError } 6600101 - Session service exception. 254 * @syscap SystemCapability.Multimedia.AVSession.Manager 255 * @systemapi 256 * @since 11 257 */ 258 function startAVPlayback(bundleName: string, assetId: string): Promise<void>; 259 260 /** 261 * Session token. Used to judge the legitimacy of the session. 262 * @typedef SessionToken 263 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 264 * @syscap SystemCapability.Multimedia.AVSession.Manager 265 * @systemapi 266 * @since 9 267 */ 268 interface SessionToken { 269 /** 270 * The unique session id of the avsession object 271 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 272 * @type { string } 273 * @syscap SystemCapability.Multimedia.AVSession.Manager 274 * @systemapi 275 * @since 9 276 */ 277 sessionId: string; 278 279 /** 280 * Process id of session 281 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 282 * @type { ?number } 283 * @syscap SystemCapability.Multimedia.AVSession.Manager 284 * @systemapi 285 * @since 9 286 */ 287 pid?: number; 288 289 /** 290 * User id 291 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 292 * @type { ?number } 293 * @syscap SystemCapability.Multimedia.AVSession.Manager 294 * @systemapi 295 * @since 9 296 */ 297 uid?: number; 298 } 299 300 /** 301 * Register session create callback 302 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 303 * @param { 'sessionCreate' } type - Registration Type, 'sessionCreate' 304 * @param { function } callback - Used to handle ('sessionCreate' command) 305 * @throws { BusinessError } 201 - permission denied 306 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 307 * 2.Incorrect parameter types. 308 * @throws { BusinessError } 6600101 - Session service exception. 309 * @syscap SystemCapability.Multimedia.AVSession.Manager 310 * @systemapi 311 * @since 9 312 */ 313 function on(type: 'sessionCreate', callback: (session: AVSessionDescriptor) => void): void; 314 315 /** 316 * Register session destroy callback 317 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 318 * @param { 'sessionDestroy' } type - Registration Type, 'sessionDestroy' 319 * @param { function } callback - Used to handle ('sessionDestroy' command) 320 * @throws { BusinessError } 201 - permission denied 321 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 322 * 2.Incorrect parameter types. 323 * @throws { BusinessError } 6600101 - Session service exception. 324 * @syscap SystemCapability.Multimedia.AVSession.Manager 325 * @systemapi 326 * @since 9 327 */ 328 function on(type: 'sessionDestroy', callback: (session: AVSessionDescriptor) => void): void; 329 330 /** 331 * Register top session changed callback 332 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 333 * @param { 'topSessionChange' } type - Registration Type, top priority session change, 'topSessionChange' 334 * @param { function } callback - Used to handle ('topSessionChange' command) 335 * @throws { BusinessError } 201 - permission denied 336 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 337 * 2.Incorrect parameter types. 338 * @throws { BusinessError } 6600101 - Session service exception. 339 * @syscap SystemCapability.Multimedia.AVSession.Manager 340 * @systemapi 341 * @since 9 342 */ 343 function on(type: 'topSessionChange', callback: (session: AVSessionDescriptor) => void): void; 344 345 /** 346 * Unregister session create callback 347 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 348 * @param { 'sessionCreate' } type - Registration Type, session creation, 'sessionCreate' 349 * @param { function } callback - Used to unregister listener for ('sessionCreate') command 350 * @throws { BusinessError } 201 - permission denied 351 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 352 * 2.Incorrect parameter types. 353 * @throws { BusinessError } 6600101 - Session service exception. 354 * @syscap SystemCapability.Multimedia.AVSession.Manager 355 * @systemapi 356 * @since 9 357 */ 358 function off(type: 'sessionCreate', callback?: (session: AVSessionDescriptor) => void): void; 359 360 /** 361 * Unregister session destroy callback 362 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 363 * @param { 'sessionDestroy' } type - Registration Type, session deletion, 'sessionDestroy' 364 * @param { function } callback - Used to unregister listener for ('sessionDestroy') command 365 * @throws { BusinessError } 201 - permission denied 366 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 367 * 2.Incorrect parameter types. 368 * @throws { BusinessError } 6600101 - Session service exception. 369 * @syscap SystemCapability.Multimedia.AVSession.Manager 370 * @systemapi 371 * @since 9 372 */ 373 function off(type: 'sessionDestroy', callback?: (session: AVSessionDescriptor) => void): void; 374 375 /** 376 * Unregister top session changed callback 377 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 378 * @param { 'topSessionChange' } type - Registration Type, top priority session change, 'topSessionChange' 379 * @param { function } callback - Used to unregister listener for ('topSessionChange') command 380 * @throws { BusinessError } 201 - permission denied 381 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 382 * 2.Incorrect parameter types. 383 * @throws { BusinessError } 6600101 - Session service exception. 384 * @syscap SystemCapability.Multimedia.AVSession.Manager 385 * @systemapi 386 * @since 9 387 */ 388 function off(type: 'topSessionChange', callback?: (session: AVSessionDescriptor) => void): void; 389 390 /** 391 * Register Session service death callback, notifying the application to clean up resources. 392 * @param { 'sessionServiceDie' } type - Registration Type, 'sessionServiceDie' 393 * @param { function } callback - Used to handle ('sessionServiceDie') command. 394 * @throws { BusinessError } 201 - permission denied 395 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 396 * 2.Incorrect parameter types. 397 * @throws { BusinessError } 6600101 - Session service exception. 398 * @syscap SystemCapability.Multimedia.AVSession.Core 399 * @systemapi 400 * @since 9 401 */ 402 function on(type: 'sessionServiceDie', callback: () => void): void; 403 404 /** 405 * Unregister Session service death callback, notifying the application to clean up resources. 406 * @param { 'sessionServiceDie' } type - Registration Type, 'sessionServiceDie' 407 * @param { function } callback - Used to unregister listener for ('sessionServiceDie') command. 408 * @throws { BusinessError } 201 - permission denied 409 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 410 * 2.Incorrect parameter types. 411 * @throws { BusinessError } 6600101 - Session service exception. 412 * @syscap SystemCapability.Multimedia.AVSession.Core 413 * @systemapi 414 * @since 9 415 */ 416 function off(type: 'sessionServiceDie', callback?: () => void): void; 417 418 /** 419 * Send system media key event.The system automatically selects the recipient. 420 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 421 * @param { KeyEvent } event - The key event to be sent 422 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 423 * @throws { BusinessError } 201 - permission denied 424 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 425 * 2.Parameter verification failed. 426 * @throws { BusinessError } 6600101 - Session service exception. 427 * @throws { BusinessError } 6600105 - Invalid session command. 428 * @syscap SystemCapability.Multimedia.AVSession.Manager 429 * @systemapi 430 * @since 9 431 */ 432 function sendSystemAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void; 433 434 /** 435 * Send system media key event.The system automatically selects the recipient. 436 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 437 * @param { KeyEvent } event - The key event to be sent 438 * @returns { Promise<void> } void promise when executed successfully 439 * @throws { BusinessError } 201 - permission denied 440 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 441 * 2.Parameter verification failed. 442 * @throws { BusinessError } 6600101 - Session service exception. 443 * @throws { BusinessError } 6600105 - Invalid session command. 444 * @syscap SystemCapability.Multimedia.AVSession.Manager 445 * @systemapi 446 * @since 9 447 */ 448 function sendSystemAVKeyEvent(event: KeyEvent): Promise<void>; 449 450 /** 451 * Send system control command.The system automatically selects the recipient. 452 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 453 * @param { AVControlCommand } command - The command to be sent. See {@link AVControlCommand} 454 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 455 * @throws { BusinessError } 201 - permission denied 456 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 457 * 2.Parameter verification failed. 458 * @throws { BusinessError } 6600101 - Session service exception. 459 * @throws { BusinessError } 6600105 - Invalid session command. 460 * @throws { BusinessError } 6600107 - Too many commands or events. 461 * @syscap SystemCapability.Multimedia.AVSession.Manager 462 * @systemapi 463 * @since 9 464 */ 465 function sendSystemControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void; 466 467 /** 468 * Send system control command.The system automatically selects the recipient. 469 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 470 * @param { AVControlCommand } command - The command to be sent. See {@link AVControlCommand} 471 * @returns { Promise<void> } void promise when executed successfully 472 * @throws { BusinessError } 201 - permission denied 473 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 474 * 2.Parameter verification failed. 475 * @throws { BusinessError } 6600101 - Session service exception. 476 * @throws { BusinessError } 6600105 - Invalid session command. 477 * @throws { BusinessError } 6600107 - Too many commands or events. 478 * @syscap SystemCapability.Multimedia.AVSession.Manager 479 * @systemapi 480 * @since 9 481 */ 482 function sendSystemControlCommand(command: AVControlCommand): Promise<void>; 483 484 /** 485 * Define different protocol capability 486 * @enum { number } 487 * @syscap SystemCapability.Multimedia.AVSession.AVCast 488 * @since 11 489 */ 490 /** 491 * Define different protocol capability 492 * @enum { number } 493 * @syscap SystemCapability.Multimedia.AVSession.AVCast 494 * @atomicservice 495 * @since 12 496 */ 497 enum ProtocolType { 498 /** 499 * The default cast type "local", media can be routed on the same device, 500 * including internal speakers or audio jack on the device itself, A2DP devices. 501 * @syscap SystemCapability.Multimedia.AVSession.AVCast 502 * @since 11 503 */ 504 /** 505 * The default cast type "local", media can be routed on the same device, 506 * including internal speakers or audio jack on the device itself, A2DP devices. 507 * @syscap SystemCapability.Multimedia.AVSession.AVCast 508 * @atomicservice 509 * @since 12 510 */ 511 TYPE_LOCAL = 0, 512 513 /** 514 * Cast+ mirror capability 515 * @syscap SystemCapability.Multimedia.AVSession.AVCast 516 * @systemapi 517 * @since 10 518 */ 519 TYPE_CAST_PLUS_MIRROR = 1, 520 521 /** 522 * The Cast+ Stream indicating the media is presenting on a different device 523 * the application need get an AVCastController to control remote playback. 524 * @syscap SystemCapability.Multimedia.AVSession.AVCast 525 * @since 11 526 */ 527 /** 528 * The Cast+ Stream indicating the media is presenting on a different device 529 * the application need get an AVCastController to control remote playback. 530 * @syscap SystemCapability.Multimedia.AVSession.AVCast 531 * @atomicservice 532 * @since 12 533 */ 534 TYPE_CAST_PLUS_STREAM = 2, 535 536 /** 537 * The DLNA type indicates the device supports DLNA protocol, 538 * the application needs to get an AVCastController to control remote playback. 539 * @syscap SystemCapability.Multimedia.AVSession.AVCast 540 * @atomicservice 541 * @since 12 542 */ 543 TYPE_DLNA = 4, 544 } 545 546 /** 547 * Start device discovery. 548 * @param { AsyncCallback<void> } callback a callback function 549 * @syscap SystemCapability.Multimedia.AVSession.AVCast 550 * @systemapi 551 * @since 10 552 */ 553 function startCastDeviceDiscovery(callback: AsyncCallback<void>): void; 554 555 /** 556 * Start device discovery. 557 * @param { number } filter device filter when discovering, can be an union of {@link ProtocolType} 558 * @param { AsyncCallback<void> } callback a callback function 559 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 560 * 2.Parameter verification failed. 561 * @syscap SystemCapability.Multimedia.AVSession.AVCast 562 * @systemapi 563 * @since 10 564 */ 565 function startCastDeviceDiscovery(filter: number, callback: AsyncCallback<void>): void; 566 567 /** 568 * Start device discovery. 569 * @param { number } filter device filter when discovering, can be an union of {@link ProtocolType} 570 * @returns { Promise<void> } Promise for the result 571 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 572 * 2.Parameter verification failed. 573 * @syscap SystemCapability.Multimedia.AVSession.AVCast 574 * @systemapi 575 * @since 10 576 */ 577 /** 578 * Start device discovery. 579 * @param { number } [filter] - device filter when discovering, can be an union of {@link ProtocolType} 580 * @param { Array<string> } [drmSchemes] - filter drm-enabled devices which are represented by uuid. 581 * It is effective when protocol type is TYPE_CAST_PLUS_STREAM. 582 * @returns { Promise<void> } Promise for the result 583 * @throws { BusinessError } 202 - Not System App. 584 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 585 * 2.Incorrect parameter types. 3.Parameter verification failed. 586 * @syscap SystemCapability.Multimedia.AVSession.AVCast 587 * @systemapi 588 * @since 12 589 */ 590 function startCastDeviceDiscovery(filter?: number, drmSchemes?: Array<string>): Promise<void>; 591 592 /** 593 * Stop device discovery. 594 * @param { AsyncCallback<void> } callback a callback function 595 * @syscap SystemCapability.Multimedia.AVSession.AVCast 596 * @systemapi 597 * @since 10 598 */ 599 function stopCastDeviceDiscovery(callback: AsyncCallback<void>): void; 600 601 /** 602 * Stop device discovery. 603 * @returns { Promise<void> } Promise for the result 604 * @syscap SystemCapability.Multimedia.AVSession.AVCast 605 * @systemapi 606 * @since 10 607 */ 608 function stopCastDeviceDiscovery(): Promise<void>; 609 610 /** 611 * Enable or disable device to be discoverable, used at sink side. 612 * @param { boolean } enable true: can be discoverable, false: cannot be discoverable. 613 * @param { AsyncCallback<void> } callback a callback function 614 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 615 * 2.Parameter verification failed. 616 * @syscap SystemCapability.Multimedia.AVSession.AVCast 617 * @systemapi 618 * @since 10 619 */ 620 function setDiscoverable(enable: boolean, callback: AsyncCallback<void>): void; 621 622 /** 623 * Enable or disable device to be discoverable, used at sink side. 624 * @param { boolean } enable true: can be discoverable, false: cannot be discoverable. 625 * @returns { Promise<void> } Promise for the result 626 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 627 * 2.Parameter verification failed. 628 * @syscap SystemCapability.Multimedia.AVSession.AVCast 629 * @systemapi 630 * @since 10 631 */ 632 function setDiscoverable(enable: boolean): Promise<void>; 633 634 /** 635 * Register device discovery callback 636 * @param { 'deviceAvailable' } type Registration Type 637 * @param { function } callback Used to returns the device info 638 * @throws {BusinessError} 201 - permission denied 639 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 640 * 2.Incorrect parameter types. 641 * @syscap SystemCapability.Multimedia.AVSession.AVCast 642 * @systemapi 643 * @since 10 644 */ 645 function on(type: 'deviceAvailable', callback: (device: OutputDeviceInfo) => void): void; 646 647 /** 648 * Unregister device discovery callback 649 * @param { 'deviceAvailable' } type Registration Type 650 * @param { function } callback Used to returns the device info 651 * @throws {BusinessError} 201 - permission denied 652 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 653 * 2.Incorrect parameter types. 654 * @syscap SystemCapability.Multimedia.AVSession.AVCast 655 * @systemapi 656 * @since 10 657 */ 658 function off(type: 'deviceAvailable', callback?: (device: OutputDeviceInfo) => void): void; 659 660 /** 661 * Register device offline callback 662 * @param { 'deviceOffline' } type - Registration Type 663 * @param { function } callback - Used to returns the device info 664 * @throws {BusinessError} 201 - permission denied 665 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 666 * 2.Incorrect parameter types. 667 * @syscap SystemCapability.Multimedia.AVSession.AVCast 668 * @systemapi 669 * @since 11 670 */ 671 function on(type: 'deviceOffline', callback: (deviceId: string) => void): void; 672 673 /** 674 * Unregister device offline callback 675 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 676 * @param { 'deviceOffline' } type - Registration Type 677 * @param { function } callback - Used to returns the device info 678 * @throws {BusinessError} 201 - permission denied 679 * @throws {BusinessError} 202 - Not System App. 680 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 681 * 2.Incorrect parameter types. 682 * @syscap SystemCapability.Multimedia.AVSession.AVCast 683 * @systemapi 684 * @since 11 685 */ 686 function off(type: 'deviceOffline', callback?: (deviceId: string) => void): void; 687 688 /** 689 * Register a callback to retrieve an avsession cast controller. 690 * This function can be used at both side to get the same controller to do the playback control. 691 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 692 * @param { string } sessionId Specifies the sessionId to get controller. 693 * @param { AsyncCallback<AVCastController> } callback - async callback for the AVCastController. 694 * @throws {BusinessError} 201 - permission denied 695 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 696 * 2.Parameter verification failed. 697 * @throws {BusinessError} 6600101 - Session service exception 698 * @throws {BusinessError} 6600102 - session does not exist 699 * @syscap SystemCapability.Multimedia.AVSession.AVCast 700 * @systemapi 701 * @since 10 702 */ 703 function getAVCastController(sessionId: string, callback: AsyncCallback<AVCastController>): void; 704 705 /** 706 * Get the current session's remote controller client. 707 * If the avsession is not under casting state, the controller will return null. 708 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 709 * @param { string } sessionId Specifies the sessionId to get controller. 710 * @returns { Promise<AVCastController> } Promise for the AVCastController 711 * @throws {BusinessError} 201 - permission denied 712 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 713 * 2.Parameter verification failed. 714 * @throws {BusinessError} 6600101 - server exception 715 * @throws {BusinessError} 6600102 - session does not exist 716 * @syscap SystemCapability.Multimedia.AVSession.AVCast 717 * @systemapi 718 * @since 10 719 */ 720 function getAVCastController(sessionId: string): Promise<AVCastController>; 721 722 /** 723 * Cast resource to remote device. 724 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 725 * @param { SessionToken } session Specifies the sessionId which is to be casted. 726 * @param { OutputDeviceInfo } device Specifies the device to cast. 727 * @param { AsyncCallback<void> } callback A callback instance used to return when start casting. 728 * @throws {BusinessError} 201 - permission denied 729 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 730 * 2.Incorrect parameter types. 3.Parameter verification failed. 731 * @throws {BusinessError} 6600101 - Session service exception 732 * @throws {BusinessError} 6600108 - Device connecting failed 733 * @syscap SystemCapability.Multimedia.AVSession.AVCast 734 * @systemapi 735 * @since 10 736 */ 737 function startCasting(session: SessionToken, device: OutputDeviceInfo, callback: AsyncCallback<void>): void; 738 739 /** 740 * Cast resource to remote device. 741 * @permission ohos.permission.MANAGE_MEDIA_RESOURCES 742 * @param { SessionToken } session Specifies the sessionId which is to be casted. 743 * @param { OutputDeviceInfo } device Specifies the device to cast. 744 * @returns { Promise<void> } Promise for the result 745 * @throws {BusinessError} 201 - permission denied 746 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 747 * 2.Incorrect parameter types. 3.Parameter verification failed. 748 * @throws {BusinessError} 6600101 - Session service exception 749 * @throws {BusinessError} 6600108 - Device connecting failed 750 * @syscap SystemCapability.Multimedia.AVSession.AVCast 751 * @systemapi 752 * @since 10 753 */ 754 function startCasting(session: SessionToken, device: OutputDeviceInfo): Promise<void>; 755 756 /** 757 * Stop current cast and disconnect device connection. 758 * @param { SessionToken } session Specifies the sessionId which is to be stopped. 759 * @param { AsyncCallback<void> } callback A callback instance used to return when cast stopped completed. 760 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 761 * 2.Incorrect parameter types. 3.Parameter verification failed. 762 * @throws { BusinessError } 6600109 - The remote connection is not established 763 * @syscap SystemCapability.Multimedia.AVSession.AVCast 764 * @systemapi 765 * @since 10 766 */ 767 function stopCasting(session: SessionToken, callback: AsyncCallback<void>): void; 768 769 /** 770 * Stop current cast and disconnect device connection. 771 * @param { SessionToken } session Specifies the sessionId which is to be stopped. 772 * @returns { Promise<void> } Promise for the result 773 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 774 * 2.Incorrect parameter types. 3.Parameter verification failed. 775 * @throws { BusinessError } 6600109 - The remote connection is not established 776 * @syscap SystemCapability.Multimedia.AVSession.AVCast 777 * @systemapi 778 * @since 10 779 */ 780 function stopCasting(session: SessionToken): Promise<void>; 781 782 /** 783 * Session type, support audio & video 784 * @syscap SystemCapability.Multimedia.AVSession.Core 785 * @since 10 786 */ 787 /** 788 * Session type, support audio & video, voice_call 789 * @syscap SystemCapability.Multimedia.AVSession.Core 790 * @since 11 791 */ 792 /** 793 * Session type supports audio & video, voice_call, video_call 794 * @syscap SystemCapability.Multimedia.AVSession.Core 795 * @atomicservice 796 * @since 12 797 */ 798 type AVSessionType = 'audio' | 'video' | 'voice_call' | 'video_call'; 799 800 /** 801 * AVSession object. 802 * @interface AVSession 803 * @syscap SystemCapability.Multimedia.AVSession.Core 804 * @since 10 805 */ 806 /** 807 * AVSession object. 808 * @interface AVSession 809 * @syscap SystemCapability.Multimedia.AVSession.Core 810 * @atomicservice 811 * @since 12 812 */ 813 interface AVSession { 814 /** 815 * unique session Id 816 * @syscap SystemCapability.Multimedia.AVSession.Core 817 * @since 10 818 */ 819 /** 820 * unique session Id 821 * @syscap SystemCapability.Multimedia.AVSession.Core 822 * @atomicservice 823 * @since 12 824 */ 825 readonly sessionId: string; 826 827 /** 828 * Get current session type 829 * @syscap SystemCapability.Multimedia.AVSession.Core 830 * @since 10 831 */ 832 /** 833 * Get current session type 834 * @syscap SystemCapability.Multimedia.AVSession.Core 835 * @atomicservice 836 * @since 12 837 */ 838 readonly sessionType: AVSessionType; 839 840 /** 841 * Set the metadata of this session. 842 * In addition to the required properties, users can fill in partially supported properties 843 * @param { AVMetadata } data {@link AVMetadata} 844 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 845 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 846 * 2.Parameter verification failed. 847 * @throws { BusinessError } 6600101 - Session service exception. 848 * @throws { BusinessError } 6600102 - The session does not exist. 849 * @syscap SystemCapability.Multimedia.AVSession.Core 850 * @since 10 851 */ 852 setAVMetadata(data: AVMetadata, callback: AsyncCallback<void>): void; 853 854 /** 855 * Set the metadata of this session. 856 * In addition to the required properties, users can fill in partially supported properties 857 * @param { AVMetadata } data {@link AVMetadata} 858 * @returns { Promise<void> } void promise when executed successfully 859 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 860 * 2.Parameter verification failed. 861 * @throws { BusinessError } 6600101 - Session service exception. 862 * @throws { BusinessError } 6600102 - The session does not exist. 863 * @syscap SystemCapability.Multimedia.AVSession.Core 864 * @since 10 865 */ 866 /** 867 * Set the metadata of this session. 868 * In addition to the required properties, users can fill in partially supported properties 869 * @param { AVMetadata } data {@link AVMetadata} 870 * @returns { Promise<void> } void promise when executed successfully 871 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 872 * 2.Parameter verification failed. 873 * @throws { BusinessError } 6600101 - Session service exception. 874 * @throws { BusinessError } 6600102 - The session does not exist. 875 * @syscap SystemCapability.Multimedia.AVSession.Core 876 * @atomicservice 877 * @since 12 878 */ 879 setAVMetadata(data: AVMetadata): Promise<void>; 880 881 /** 882 * Set the metadata related with current call. 883 * @param { CallMetadata } data - {@link CallMetadata} 884 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 885 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 886 * 2.Incorrect parameter types. 3.Parameter verification failed. 887 * @throws { BusinessError } 6600101 - Session service exception. 888 * @throws { BusinessError } 6600102 - The session does not exist. 889 * @syscap SystemCapability.Multimedia.AVSession.Core 890 * @since 11 891 */ 892 setCallMetadata(data: CallMetadata, callback: AsyncCallback<void>): void; 893 894 /** 895 * Set the metadata related with current call. 896 * @param { CallMetadata } data - {@link CallMetadata} 897 * @returns { Promise<void> } void promise when executed successfully 898 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 899 * 2.Incorrect parameter types. 3.Parameter verification failed. 900 * @throws { BusinessError } 6600101 - Session service exception. 901 * @throws { BusinessError } 6600102 - The session does not exist. 902 * @syscap SystemCapability.Multimedia.AVSession.Core 903 * @since 11 904 */ 905 setCallMetadata(data: CallMetadata): Promise<void>; 906 907 /** 908 * Set the playback state of this session. 909 * @param { AVPlaybackState } state {@link AVPlaybackState} 910 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 911 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 912 * 2.Parameter verification failed. 913 * @throws { BusinessError } 6600101 - Session service exception. 914 * @throws { BusinessError } 6600102 - The session does not exist. 915 * @syscap SystemCapability.Multimedia.AVSession.Core 916 * @since 10 917 */ 918 setAVPlaybackState(state: AVPlaybackState, callback: AsyncCallback<void>): void; 919 920 /** 921 * Set the playback state of this session. 922 * @param { AVPlaybackState } state {@link AVPlaybackState} 923 * @returns { Promise<void> } void promise when executed successfully 924 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 925 * 2.Parameter verification failed. 926 * @throws { BusinessError } 6600101 - Session service exception. 927 * @throws { BusinessError } 6600102 - The session does not exist. 928 * @syscap SystemCapability.Multimedia.AVSession.Core 929 * @since 10 930 */ 931 /** 932 * Set the playback state of this session. 933 * @param { AVPlaybackState } state {@link AVPlaybackState} 934 * @returns { Promise<void> } void promise when executed successfully 935 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 936 * 2.Parameter verification failed. 937 * @throws { BusinessError } 6600101 - Session service exception. 938 * @throws { BusinessError } 6600102 - The session does not exist. 939 * @syscap SystemCapability.Multimedia.AVSession.Core 940 * @atomicservice 941 * @since 12 942 */ 943 setAVPlaybackState(state: AVPlaybackState): Promise<void>; 944 945 /** 946 * Set the call state of this session. 947 * @param { AVCallState } state - {@link AVCallState} 948 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 949 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 950 * 2.Parameter verification failed. 951 * @throws { BusinessError } 6600101 - Session service exception. 952 * @throws { BusinessError } 6600102 - The session does not exist. 953 * @syscap SystemCapability.Multimedia.AVSession.Core 954 * @since 11 955 */ 956 setAVCallState(state: AVCallState, callback: AsyncCallback<void>): void; 957 958 /** 959 * Set the call state of this session. 960 * @param { AVCallState } state - {@link AVCallState} 961 * @returns { Promise<void> } void promise when executed successfully 962 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 963 * 2.Parameter verification failed. 964 * @throws { BusinessError } 6600101 - Session service exception. 965 * @throws { BusinessError } 6600102 - The session does not exist. 966 * @syscap SystemCapability.Multimedia.AVSession.Core 967 * @since 11 968 */ 969 setAVCallState(state: AVCallState): Promise<void>; 970 971 /** 972 * Set the ability to start the session corresponding to 973 * @param { WantAgent } ability - The WantAgent for launch the ability 974 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 975 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 976 * 2.Parameter verification failed. 977 * @throws { BusinessError } 6600101 - Session service exception. 978 * @throws { BusinessError } 6600102 - The session does not exist. 979 * @syscap SystemCapability.Multimedia.AVSession.Core 980 * @since 10 981 */ 982 setLaunchAbility(ability: WantAgent, callback: AsyncCallback<void>): void; 983 984 /** 985 * Set the ability to start the session corresponding to 986 * @param { WantAgent } ability - The WantAgent for launch the ability 987 * @returns { Promise<void> } void promise when executed successfully 988 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 989 * 2.Parameter verification failed. 990 * @throws { BusinessError } 6600101 - Session service exception. 991 * @throws { BusinessError } 6600102 - The session does not exist. 992 * @syscap SystemCapability.Multimedia.AVSession.Core 993 * @since 10 994 */ 995 setLaunchAbility(ability: WantAgent): Promise<void>; 996 997 /** 998 * Dispatch the session event of this session. 999 * @param { string } event - Session event name to dispatch 1000 * @param { object } args - The parameters of session event 1001 * @param { AsyncCallback<void>} callback - The asyncCallback triggered when the command is executed successfully 1002 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1003 * 2.Incorrect parameter types. 3.Parameter verification failed. 1004 * @throws { BusinessError } 6600101 - Session service exception. 1005 * @throws { BusinessError } 6600102 - The session does not exist. 1006 * @syscap SystemCapability.Multimedia.AVSession.Core 1007 * @since 10 1008 */ 1009 dispatchSessionEvent(event: string, args: {[key: string]: Object}, callback: AsyncCallback<void>): void; 1010 1011 /** 1012 * Dispatch the session event of this session. 1013 * @param { string } event - Session event name to dispatch 1014 * @param { object } args - The parameters of session event 1015 * @returns { Promise<void> } void promise when executed successfully 1016 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1017 * 2.Incorrect parameter types. 3.Parameter verification failed. 1018 * @throws { BusinessError } 6600101 - Session service exception. 1019 * @throws { BusinessError } 6600102 - The session does not exist. 1020 * @syscap SystemCapability.Multimedia.AVSession.Core 1021 * @since 10 1022 */ 1023 dispatchSessionEvent(event: string, args: {[key: string]: Object}): Promise<void>; 1024 1025 /** 1026 * Set the playlist of queueItem. Identifies the content of the playlist presented by this session. 1027 * @param { Array<AVQueueItem> } items - An array of the AVQueueItem 1028 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 1029 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1030 * 2.Parameter verification failed. 1031 * @throws { BusinessError } 6600101 - Session service exception. 1032 * @throws { BusinessError } 6600102 - The session does not exist. 1033 * @syscap SystemCapability.Multimedia.AVSession.Core 1034 * @since 10 1035 */ 1036 setAVQueueItems(items: Array<AVQueueItem>, callback: AsyncCallback<void>): void; 1037 1038 /** 1039 * Set the playlist of queueItem. Identifies the content of the playlist presented by this session. 1040 * @param { Array<AVQueueItem> } items - An array of the AVQueueItem 1041 * @returns { Promise<void> } void promise when executed successfully 1042 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1043 * 2.Parameter verification failed. 1044 * @throws { BusinessError } 6600101 - Session service exception. 1045 * @throws { BusinessError } 6600102 - The session does not exist. 1046 * @syscap SystemCapability.Multimedia.AVSession.Core 1047 * @since 10 1048 */ 1049 setAVQueueItems(items: Array<AVQueueItem>): Promise<void>; 1050 1051 /** 1052 * Set the name of the playlist presented by this session. 1053 * @param { string } title - The name of the playlist 1054 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 1055 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1056 * 2.Parameter verification failed. 1057 * @throws { BusinessError } 6600101 - Session service exception. 1058 * @throws { BusinessError } 6600102 - The session does not exist. 1059 * @syscap SystemCapability.Multimedia.AVSession.Core 1060 * @since 10 1061 */ 1062 setAVQueueTitle(title: string, callback: AsyncCallback<void>): void; 1063 1064 /** 1065 * Set the name of the playlist presented by this session. 1066 * @param { string } title - The name of the playlist 1067 * @returns { Promise<void> } void promise when executed successfully 1068 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1069 * 2.Parameter verification failed. 1070 * @throws { BusinessError } 6600101 - Session service exception. 1071 * @throws { BusinessError } 6600102 - The session does not exist. 1072 * @syscap SystemCapability.Multimedia.AVSession.Core 1073 * @since 10 1074 */ 1075 setAVQueueTitle(title: string): Promise<void>; 1076 1077 /** 1078 * Set the custom media packets for this session. 1079 * @param { object } extras - The custom media packets 1080 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 1081 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1082 * 2.Parameter verification failed. 1083 * @throws { BusinessError } 6600101 - Session service exception. 1084 * @throws { BusinessError } 6600102 - The session does not exist. 1085 * @syscap SystemCapability.Multimedia.AVSession.Core 1086 * @since 10 1087 */ 1088 setExtras(extras: {[key: string]: Object}, callback: AsyncCallback<void>): void; 1089 1090 /** 1091 * Set the custom media packets for this session. 1092 * @param { object } extras - The custom media packets 1093 * @returns { Promise<void> } void promise when executed successfully 1094 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1095 * 2.Parameter verification failed. 1096 * @throws { BusinessError } 6600101 - Session service exception. 1097 * @throws { BusinessError } 6600102 - The session does not exist. 1098 * @syscap SystemCapability.Multimedia.AVSession.Core 1099 * @since 10 1100 */ 1101 setExtras(extras: {[key: string]: Object}): Promise<void>; 1102 1103 /** 1104 * Get the current session's own controller 1105 * @param { AsyncCallback<AVSessionController> } callback - async callback for the AVSessionController. 1106 * @throws { BusinessError } 6600101 - Session service exception. 1107 * @throws { BusinessError } 6600102 - The session does not exist. 1108 * @syscap SystemCapability.Multimedia.AVSession.Core 1109 * @since 10 1110 */ 1111 getController(callback: AsyncCallback<AVSessionController>): void; 1112 1113 /** 1114 * Get the current session's own controller 1115 * @returns { Promise<AVSessionController> } Promise for the AVSessionController 1116 * @throws { BusinessError } 6600101 - Session service exception. 1117 * @throws { BusinessError } 6600102 - The session does not exist. 1118 * @syscap SystemCapability.Multimedia.AVSession.Core 1119 * @since 10 1120 */ 1121 getController(): Promise<AVSessionController>; 1122 1123 /** 1124 * Get the cast controller when the session is casted to remote device. 1125 * If the avsession is not under casting state, the controller will return null. 1126 * @param { AsyncCallback<AVCastController> } callback - async callback for the AVCastController. 1127 * @throws {BusinessError} 6600102 - {@link #ERR_CODE_SESSION_NOT_EXIST} - session does not exist 1128 * @throws {BusinessError} 6600110 - 6600109 - remote connection does not exist 1129 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1130 * @since 10 1131 */ 1132 getAVCastController(callback: AsyncCallback<AVCastController>): void; 1133 1134 /** 1135 * Get the cast controller when the session is casted to remote device. 1136 * If the avsession is not under casting state, the controller will return null. 1137 * @returns { Promise<AVCastController> } Promise for the AVCastController 1138 * @throws {BusinessError} 6600102 - {@link #ERR_CODE_SESSION_NOT_EXIST} session does not exist 1139 * @throws {BusinessError} 6600110 - 6600109 - remote connection does not exist 1140 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1141 * @since 10 1142 */ 1143 /** 1144 * Get the cast controller when the session is casted to remote device. 1145 * If the avsession is not under casting state, the controller will return null. 1146 * @returns { Promise<AVCastController> } Promise for the AVCastController 1147 * @throws {BusinessError} 6600102 - {@link #ERR_CODE_SESSION_NOT_EXIST} session does not exist 1148 * @throws {BusinessError} 6600110 - 6600109 - remote connection does not exist 1149 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1150 * @atomicservice 1151 * @since 12 1152 */ 1153 getAVCastController(): Promise<AVCastController>; 1154 1155 /** 1156 * Get output device information 1157 * @param { AsyncCallback<OutputDeviceInfo> } callback - async callback for the OutputDeviceInfo. 1158 * @throws { BusinessError } 6600101 - Session service exception. 1159 * @throws { BusinessError } 6600102 - The session does not exist. 1160 * @syscap SystemCapability.Multimedia.AVSession.Core 1161 * @since 10 1162 */ 1163 getOutputDevice(callback: AsyncCallback<OutputDeviceInfo>): void; 1164 1165 /** 1166 * Get output device information 1167 * @returns { Promise<OutputDeviceInfo> } Promise for the OutputDeviceInfo 1168 * @throws { BusinessError } 6600101 - Session service exception. 1169 * @throws { BusinessError } 6600102 - The session does not exist. 1170 * @syscap SystemCapability.Multimedia.AVSession.Core 1171 * @since 10 1172 */ 1173 /** 1174 * Get output device information 1175 * @returns { Promise<OutputDeviceInfo> } Promise for the OutputDeviceInfo 1176 * @throws { BusinessError } 6600101 - Session service exception. 1177 * @throws { BusinessError } 6600102 - The session does not exist. 1178 * @syscap SystemCapability.Multimedia.AVSession.Core 1179 * @atomicservice 1180 * @since 12 1181 */ 1182 getOutputDevice(): Promise<OutputDeviceInfo>; 1183 1184 /** 1185 * Get output device information 1186 * @returns { OutputDeviceInfo } the OutputDeviceInfo 1187 * @throws { BusinessError } 6600101 - Session service exception. 1188 * @throws { BusinessError } 6600102 - The session does not exist. 1189 * @syscap SystemCapability.Multimedia.AVSession.Core 1190 * @since 10 1191 */ 1192 getOutputDeviceSync(): OutputDeviceInfo; 1193 1194 /** 1195 * Get all the current virtual display information for extended display. 1196 * @returns { Promise<Array<CastDisplayInfo>> } Promise for the CastDisplayInfo 1197 * @throws { BusinessError } 6600101 - Session service exception. 1198 * @throws { BusinessError } 6600102 - The session does not exist. 1199 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 1200 * @since 12 1201 */ 1202 getAllCastDisplays(): Promise<Array<CastDisplayInfo>>; 1203 1204 /** 1205 * Register play command callback. 1206 * As long as it is registered, it means that the ability supports this command. 1207 * If you cancel the callback, you need to call off {@link off} 1208 * When canceling the callback, need to update the supported commands list. 1209 * Each playback command only supports registering one callback, 1210 * and the new callback will replace the previous one. 1211 * @param { 'play' } type - Command to register 'play'. 1212 * @param { function } callback - Used to handle ('play') command 1213 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1214 * 2.Incorrect parameter types. 1215 * @throws { BusinessError } 6600101 - Session service exception. 1216 * @throws { BusinessError } 6600102 - The session does not exist. 1217 * @syscap SystemCapability.Multimedia.AVSession.Core 1218 * @since 10 1219 */ 1220 on(type: 'play', callback: () => void): void; 1221 1222 /** 1223 * Register pause command callback. 1224 * As long as it is registered, it means that the ability supports this command. 1225 * If you cancel the callback, you need to call off {@link off} 1226 * When canceling the callback, need to update the supported commands list. 1227 * Each playback command only supports registering one callback, 1228 * and the new callback will replace the previous one. 1229 * @param { 'pause' } type - Command to register 'pause'. 1230 * @param { function } callback - Used to handle ('pause') command 1231 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1232 * 2.Incorrect parameter types. 1233 * @throws { BusinessError } 6600101 - Session service exception. 1234 * @throws { BusinessError } 6600102 - The session does not exist. 1235 * @syscap SystemCapability.Multimedia.AVSession.Core 1236 * @since 10 1237 */ 1238 on(type: 'pause', callback: () => void): void; 1239 1240 /** 1241 * Register stop command callback. 1242 * As long as it is registered, it means that the ability supports this command. 1243 * If you cancel the callback, you need to call off {@link off} 1244 * When canceling the callback, need to update the supported commands list. 1245 * Each playback command only supports registering one callback, 1246 * and the new callback will replace the previous one. 1247 * @param { 'stop' } type - Command to register 'stop'. 1248 * @param { function } callback - Used to handle ('stop') command 1249 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1250 * 2.Incorrect parameter types. 1251 * @throws { BusinessError } 6600101 - Session service exception. 1252 * @throws { BusinessError } 6600102 - The session does not exist. 1253 * @syscap SystemCapability.Multimedia.AVSession.Core 1254 * @since 10 1255 */ 1256 on(type: 'stop', callback: () => void): void; 1257 1258 /** 1259 * Register playNext command callback. 1260 * As long as it is registered, it means that the ability supports this command. 1261 * If you cancel the callback, you need to call off {@link off} 1262 * When canceling the callback, need to update the supported commands list. 1263 * Each playback command only supports registering one callback, 1264 * and the new callback will replace the previous one. 1265 * @param { 'playNext' } type - Command to register 'playNext'. 1266 * @param { function } callback - Used to handle ('playNext') command 1267 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1268 * 2.Incorrect parameter types. 1269 * @throws { BusinessError } 6600101 - Session service exception. 1270 * @throws { BusinessError } 6600102 - The session does not exist. 1271 * @syscap SystemCapability.Multimedia.AVSession.Core 1272 * @since 10 1273 */ 1274 on(type: 'playNext', callback: () => void): void; 1275 1276 /** 1277 * Register playPrevious command callback. 1278 * As long as it is registered, it means that the ability supports this command. 1279 * If you cancel the callback, you need to call off {@link off} 1280 * When canceling the callback, need to update the supported commands list. 1281 * Each playback command only supports registering one callback, 1282 * and the new callback will replace the previous one. 1283 * @param { 'playPrevious' } type - Command to register 'playPrevious'. 1284 * @param { function } callback - Used to handle ('playPrevious') command 1285 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1286 * 2.Incorrect parameter types. 1287 * @throws { BusinessError } 6600101 - Session service exception. 1288 * @throws { BusinessError } 6600102 - The session does not exist. 1289 * @syscap SystemCapability.Multimedia.AVSession.Core 1290 * @since 10 1291 */ 1292 on(type: 'playPrevious', callback: () => void): void; 1293 1294 /** 1295 * Register fastForward command callback. 1296 * As long as it is registered, it means that the ability supports this command. 1297 * If you cancel the callback, you need to call off {@link off} 1298 * When canceling the callback, need to update the supported commands list. 1299 * Each playback command only supports registering one callback, 1300 * and the new callback will replace the previous one. 1301 * @param { 'fastForward' } type - Command to register 'fastForward'. 1302 * @param { function } callback - Used to handle ('fastForward') command 1303 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1304 * 2.Incorrect parameter types. 1305 * @throws { BusinessError } 6600101 - Session service exception. 1306 * @throws { BusinessError } 6600102 - The session does not exist. 1307 * @syscap SystemCapability.Multimedia.AVSession.Core 1308 * @since 10 1309 */ 1310 on(type: 'fastForward', callback: (time ?: number) => void): void; 1311 1312 /** 1313 * Register rewind command callback. 1314 * As long as it is registered, it means that the ability supports this command. 1315 * If you cancel the callback, you need to call off {@link off} 1316 * When canceling the callback, need to update the supported commands list. 1317 * Each playback command only supports registering one callback, 1318 * and the new callback will replace the previous one. 1319 * @param { 'rewind' } type - Command to register 'rewind'. 1320 * @param { function } callback - Used to handle ('rewind') command 1321 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1322 * 2.Incorrect parameter types. 1323 * @throws { BusinessError } 6600101 - Session service exception. 1324 * @throws { BusinessError } 6600102 - The session does not exist. 1325 * @syscap SystemCapability.Multimedia.AVSession.Core 1326 * @since 10 1327 */ 1328 on(type: 'rewind', callback: (time ?: number) => void): void; 1329 1330 /** 1331 * Unregister play command callback. 1332 * When canceling the callback, need to update the supported commands list. 1333 * @param { 'play' } type - Command to register 'play'. 1334 * @param { function } callback - Used to handle ('play') command 1335 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1336 * 2.Incorrect parameter types. 1337 * @throws { BusinessError } 6600101 - Session service exception. 1338 * @throws { BusinessError } 6600102 - The session does not exist. 1339 * @syscap SystemCapability.Multimedia.AVSession.Core 1340 * @since 10 1341 */ 1342 off(type: 'play', callback?: () => void): void; 1343 1344 /** 1345 * Unregister pause command callback. 1346 * When canceling the callback, need to update the supported commands list. 1347 * @param { 'pause' } type - Command to register 'pause'. 1348 * @param { function } callback - Used to handle ('pause') command 1349 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1350 * 2.Incorrect parameter types. 1351 * @throws { BusinessError } 6600101 - Session service exception. 1352 * @throws { BusinessError } 6600102 - The session does not exist. 1353 * @syscap SystemCapability.Multimedia.AVSession.Core 1354 * @since 10 1355 */ 1356 off(type: 'pause', callback?: () => void): void; 1357 1358 /** 1359 * Unregister stop command callback. 1360 * When canceling the callback, need to update the supported commands list. 1361 * @param { 'stop' } type - Command to register 'stop'. 1362 * @param { function } callback - Used to handle ('stop') command 1363 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1364 * 2.Incorrect parameter types. 1365 * @throws { BusinessError } 6600101 - Session service exception. 1366 * @throws { BusinessError } 6600102 - The session does not exist. 1367 * @syscap SystemCapability.Multimedia.AVSession.Core 1368 * @since 10 1369 */ 1370 off(type: 'stop', callback?: () => void): void; 1371 1372 /** 1373 * Unregister playNext command callback. 1374 * When canceling the callback, need to update the supported commands list. 1375 * @param { 'playNext' } type - Command to register 'playNext'. 1376 * @param { function } callback - Used to handle ('playNext') command 1377 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1378 * 2.Incorrect parameter types. 1379 * @throws { BusinessError } 6600101 - Session service exception. 1380 * @throws { BusinessError } 6600102 - The session does not exist. 1381 * @syscap SystemCapability.Multimedia.AVSession.Core 1382 * @since 10 1383 */ 1384 off(type: 'playNext', callback?: () => void): void; 1385 1386 /** 1387 * Unregister playPrevious command callback. 1388 * When canceling the callback, need to update the supported commands list. 1389 * @param { 'playPrevious' } type - Command to register 'playPrevious'. 1390 * @param { function } callback - Used to handle ('playPrevious') command 1391 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1392 * 2.Incorrect parameter types. 1393 * @throws { BusinessError } 6600101 - Session service exception. 1394 * @throws { BusinessError } 6600102 - The session does not exist. 1395 * @syscap SystemCapability.Multimedia.AVSession.Core 1396 * @since 10 1397 */ 1398 off(type: 'playPrevious', callback?: () => void): void; 1399 1400 /** 1401 * Unregister fastForward command callback. 1402 * When canceling the callback, need to update the supported commands list. 1403 * @param { 'fastForward' } type - Command to register 'fastForward'. 1404 * @param { function } callback - Used to handle ('fastForward') command 1405 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1406 * 2.Incorrect parameter types. 1407 * @throws { BusinessError } 6600101 - Session service exception. 1408 * @throws { BusinessError } 6600102 - The session does not exist. 1409 * @syscap SystemCapability.Multimedia.AVSession.Core 1410 * @since 10 1411 */ 1412 off(type: 'fastForward', callback?: () => void): void; 1413 1414 /** 1415 * Unregister rewind command callback. 1416 * When canceling the callback, need to update the supported commands list. 1417 * @param { 'rewind' } type - Command to register 'rewind'. 1418 * @param { function } callback - Used to handle ('rewind') command 1419 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1420 * 2.Incorrect parameter types. 1421 * @throws { BusinessError } 6600101 - Session service exception. 1422 * @throws { BusinessError } 6600102 - The session does not exist. 1423 * @syscap SystemCapability.Multimedia.AVSession.Core 1424 * @since 10 1425 */ 1426 off(type: 'rewind', callback?: () => void): void; 1427 1428 /** 1429 * Register playFromAssetId command callback. 1430 * As long as it is registered, it means that the ability supports this command. 1431 * If you cancel the callback, you need to call off {@link off} 1432 * When canceling the callback, need to update the supported commands list. 1433 * Each playback command only supports registering one callback, 1434 * and the new callback will replace the previous one. 1435 * @param { 'playFromAssetId' } type - Command to register 'playFromAssetId'. 1436 * @param { function } callback - Used to handle ('playFromAssetId') command 1437 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1438 * 2.Incorrect parameter types. 1439 * @throws { BusinessError } 6600101 - Session service exception. 1440 * @throws { BusinessError } 6600102 - The session does not exist. 1441 * @syscap SystemCapability.Multimedia.AVSession.Core 1442 * @since 11 1443 */ 1444 on(type: 'playFromAssetId', callback: (assetId: number) => void): void; 1445 1446 /** 1447 * Unregister playFromAssetId command callback. 1448 * @param { 'playFromAssetId' } type - Command to register 'playFromAssetId'. 1449 * @param { function } callback - Used to handle ('playFromAssetId') command 1450 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1451 * 2.Incorrect parameter types. 1452 * @throws { BusinessError } 6600101 - Session service exception. 1453 * @throws { BusinessError } 6600102 - The session does not exist. 1454 * @syscap SystemCapability.Multimedia.AVSession.Core 1455 * @since 11 1456 */ 1457 off(type: 'playFromAssetId', callback?: (assetId: number) => void): void; 1458 1459 /** 1460 * Register seek command callback 1461 * @param { 'seek' } type - Registration Type 'seek' 1462 * @param { function } callback - Used to handle seek command.The callback provides the seek time(ms) 1463 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1464 * 2.Incorrect parameter types. 1465 * @throws { BusinessError } 6600101 - Session service exception. 1466 * @throws { BusinessError } 6600102 - The session does not exist. 1467 * @syscap SystemCapability.Multimedia.AVSession.Core 1468 * @since 10 1469 */ 1470 on(type: 'seek', callback: (time: number) => void): void; 1471 1472 /** 1473 * Unregister seek command callback 1474 * @param { 'seek' } type - Registration Type 'seek' 1475 * @param { function } callback - Used to handle seek command.The callback provides the seek time(ms) 1476 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1477 * 2.Incorrect parameter types. 1478 * @throws { BusinessError } 6600101 - Session service exception. 1479 * @throws { BusinessError } 6600102 - The session does not exist. 1480 * @syscap SystemCapability.Multimedia.AVSession.Core 1481 * @since 10 1482 */ 1483 off(type: 'seek', callback?: (time: number) => void): void; 1484 1485 /** 1486 * Register setSpeed command callback 1487 * @param { 'setSpeed' } type - Registration Type 'setSpeed' 1488 * @param { function } callback - Used to handle setSpeed command.The callback provides the speed value 1489 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1490 * 2.Incorrect parameter types. 1491 * @throws { BusinessError } 6600101 - Session service exception. 1492 * @throws { BusinessError } 6600102 - The session does not exist. 1493 * @syscap SystemCapability.Multimedia.AVSession.Core 1494 * @since 10 1495 */ 1496 on(type: 'setSpeed', callback: (speed: number) => void): void; 1497 1498 /** 1499 * Unregister setSpeed command callback 1500 * @param { 'setSpeed' } type - Registration Type 'setSpeed' 1501 * @param { function } callback - Used to handle setSpeed command.The callback provides the speed value 1502 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1503 * 2.Incorrect parameter types. 1504 * @throws { BusinessError } 6600101 - Session service exception. 1505 * @throws { BusinessError } 6600102 - The session does not exist. 1506 * @syscap SystemCapability.Multimedia.AVSession.Core 1507 * @since 10 1508 */ 1509 off(type: 'setSpeed', callback?: (speed: number) => void): void; 1510 1511 /** 1512 * Register setLoopMode command callback 1513 * @param { 'setLoopMode' } type - Registration Type 'setLoopMode' 1514 * @param { function } callback - Used to handle setLoopMode command.The callback provides the {@link LoopMode} 1515 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1516 * 2.Incorrect parameter types. 1517 * @throws { BusinessError } 6600101 - Session service exception. 1518 * @throws { BusinessError } 6600102 - The session does not exist. 1519 * @syscap SystemCapability.Multimedia.AVSession.Core 1520 * @since 10 1521 */ 1522 on(type: 'setLoopMode', callback: (mode: LoopMode) => void): void; 1523 1524 /** 1525 * Unregister setLoopMode command callback 1526 * @param { 'setLoopMode' } type - Registration Type 'setLoopMode' 1527 * @param { function } callback - Used to handle setLoopMode command.The callback provides the {@link LoopMode} 1528 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1529 * 2.Incorrect parameter types. 1530 * @throws { BusinessError } 6600101 - Session service exception. 1531 * @throws { BusinessError } 6600102 - The session does not exist. 1532 * @syscap SystemCapability.Multimedia.AVSession.Core 1533 * @since 10 1534 */ 1535 off(type: 'setLoopMode', callback?: (mode: LoopMode) => void): void; 1536 1537 /** 1538 * Register toggle favorite command callback 1539 * @param { 'toggleFavorite' } type - Registration Type 'toggleFavorite' 1540 * @param { function } callback - Used to handle toggleFavorite command.The callback provides 1541 * the assetId for which the favorite status needs to be switched. 1542 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1543 * 2.Incorrect parameter types. 1544 * @throws { BusinessError } 6600101 - Session service exception. 1545 * @throws { BusinessError } 6600102 - The session does not exist. 1546 * @syscap SystemCapability.Multimedia.AVSession.Core 1547 * @since 10 1548 */ 1549 on(type: 'toggleFavorite', callback: (assetId: string) => void): void; 1550 1551 /** 1552 * Unregister toggle favorite command callback 1553 * @param { 'toggleFavorite' } type - Registration Type 'toggleFavorite' 1554 * @param { function } callback - Used to handle toggleFavorite command.The callback provides 1555 * the assetId for which the favorite status needs to be switched. 1556 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1557 * 2.Incorrect parameter types. 1558 * @throws { BusinessError } 6600101 - Session service exception. 1559 * @throws { BusinessError } 6600102 - The session does not exist. 1560 * @syscap SystemCapability.Multimedia.AVSession.Core 1561 * @since 10 1562 */ 1563 off(type: 'toggleFavorite', callback?: (assetId: string) => void): void; 1564 1565 /** 1566 * Register media key handling callback 1567 * @param { 'handleKeyEvent' } type - Registration Type 'handleKeyEvent' 1568 * @param { function } callback - Used to handle key events.The callback provides the KeyEvent 1569 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1570 * 2.Incorrect parameter types. 1571 * @throws { BusinessError } 6600101 - Session service exception. 1572 * @throws { BusinessError } 6600102 - The session does not exist. 1573 * @syscap SystemCapability.Multimedia.AVSession.Core 1574 * @since 10 1575 */ 1576 on(type: 'handleKeyEvent', callback: (event: KeyEvent) => void): void; 1577 1578 /** 1579 * Unregister media key handling callback 1580 * @param { 'handleKeyEvent' } type - Registration Type 'handleKeyEvent' 1581 * @param { function } callback - Used to handle key events.The callback provides the KeyEvent 1582 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1583 * 2.Incorrect parameter types. 1584 * @throws { BusinessError } 6600101 - Session service exception. 1585 * @throws { BusinessError } 6600102 - The session does not exist. 1586 * @syscap SystemCapability.Multimedia.AVSession.Core 1587 * @since 10 1588 */ 1589 off(type: 'handleKeyEvent', callback?: (event: KeyEvent) => void): void; 1590 1591 /** 1592 * Register session output device change callback 1593 * @param { 'outputDeviceChange' } type - Registration Type 'outputDeviceChange' 1594 * @param { function } callback - Used to handle output device changed. 1595 * The callback provide the new device info {@link OutputDeviceInfo} and related connection state {@link ConnectionState}. 1596 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1597 * 2.Incorrect parameter types. 1598 * @throws { BusinessError } 6600101 - Session service exception 1599 * @throws { BusinessError } 6600102 - The session does not exist 1600 * @syscap SystemCapability.Multimedia.AVSession.Core 1601 * @since 10 1602 */ 1603 /** 1604 * Register session output device change callback 1605 * @param { 'outputDeviceChange' } type - Registration Type 'outputDeviceChange' 1606 * @param { function } callback - Used to handle output device changed. 1607 * The callback provide the new device info {@link OutputDeviceInfo} and related connection state {@link ConnectionState}. 1608 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1609 * 2.Incorrect parameter types. 1610 * @throws { BusinessError } 6600101 - Session service exception 1611 * @throws { BusinessError } 6600102 - The session does not exist 1612 * @syscap SystemCapability.Multimedia.AVSession.Core 1613 * @atomicservice 1614 * @since 12 1615 */ 1616 on(type: 'outputDeviceChange', callback: (state: ConnectionState, device: OutputDeviceInfo) => void): void; 1617 1618 /** 1619 * Unregister session output device change callback 1620 * @param { 'outputDeviceChange' } type - Registration Type 'outputDeviceChange' 1621 * @param { function } callback - Used to handle output device changed. 1622 * The callback provide the new device info {@link OutputDeviceInfo} and related connection state {@link ConnectionState}. 1623 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1624 * 2.Incorrect parameter types. 1625 * @throws { BusinessError } 6600101 - Session service exception 1626 * @throws { BusinessError } 6600102 - The session does not exist 1627 * @syscap SystemCapability.Multimedia.AVSession.Core 1628 * @since 10 1629 */ 1630 /** 1631 * Unregister session output device change callback 1632 * @param { 'outputDeviceChange' } type - Registration Type 'outputDeviceChange' 1633 * @param { function } callback - Used to handle output device changed. 1634 * The callback provide the new device info {@link OutputDeviceInfo} and related connection state {@link ConnectionState}. 1635 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1636 * 2.Incorrect parameter types. 1637 * @throws { BusinessError } 6600101 - Session service exception 1638 * @throws { BusinessError } 6600102 - The session does not exist 1639 * @syscap SystemCapability.Multimedia.AVSession.Core 1640 * @atomicservice 1641 * @since 12 1642 */ 1643 off(type: 'outputDeviceChange', callback?: (state: ConnectionState, device: OutputDeviceInfo) => void): void; 1644 1645 /** 1646 * Register session custom command change callback 1647 * @param { 'commonCommand' } type - Registration Type 'commonCommand' 1648 * @param { function } callback - Used to handle event when the common command is received 1649 * The callback provide the command name and command args 1650 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1651 * 2.Incorrect parameter types. 1652 * @throws { BusinessError } 6600101 - Session service exception. 1653 * @throws { BusinessError } 6600102 - The session does not exist. 1654 * @syscap SystemCapability.Multimedia.AVSession.Core 1655 * @since 10 1656 */ 1657 on(type: 'commonCommand', callback: (command: string, args: {[key: string]: Object}) => void): void; 1658 1659 /** 1660 * Unregister session custom command change callback 1661 * @param { 'commonCommand' } type - Registration Type 'commonCommand' 1662 * @param { function } callback - Used to cancel a specific listener 1663 * The callback provide the command name and command args 1664 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1665 * 2.Incorrect parameter types. 1666 * @throws { BusinessError } 6600101 - Session service exception. 1667 * @throws { BusinessError } 6600102 - The session does not exist. 1668 * @syscap SystemCapability.Multimedia.AVSession.Core 1669 * @since 10 1670 */ 1671 off(type: 'commonCommand', callback?: (command: string, args: {[key: string]: Object}) => void): void; 1672 1673 /** 1674 * Register the item to play from the playlist change callback 1675 * @param { 'skipToQueueItem' } type - Registration Type 'skipToQueueItem' 1676 * @param { function } callback - Used to handle the item to be played. 1677 * The callback provide the new device info {@link OutputDeviceInfo} 1678 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1679 * 2.Incorrect parameter types. 1680 * @throws { BusinessError } 6600101 - Session service exception. 1681 * @throws { BusinessError } 6600102 - The session does not exist. 1682 * @syscap SystemCapability.Multimedia.AVSession.Core 1683 * @since 10 1684 */ 1685 on(type: 'skipToQueueItem', callback: (itemId: number) => void): void; 1686 1687 /** 1688 * Unregister the item to play from the playlist change callback 1689 * @param { 'skipToQueueItem' } type - Registration Type 'skipToQueueItem' 1690 * @param { function } callback - Used to handle the item to be played. 1691 * The callback provide the new device info {@link OutputDeviceInfo} 1692 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1693 * 2.Incorrect parameter types. 1694 * @throws { BusinessError } 6600101 - Session service exception. 1695 * @throws { BusinessError } 6600102 - The session does not exist. 1696 * @syscap SystemCapability.Multimedia.AVSession.Core 1697 * @since 10 1698 */ 1699 off(type: 'skipToQueueItem', callback?: (itemId: number) => void): void; 1700 1701 /** 1702 * Register answer command callback. 1703 * As long as it is registered, it means that the ability supports this command. 1704 * If you cancel the callback, you need to call off {@link off} 1705 * @param { 'answer' } type - Command to register 'answer'. 1706 * @param { Callback<void> } callback - Used to handle ('answer') command 1707 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1708 * 2.Incorrect parameter types. 1709 * @throws { BusinessError } 6600101 - Session service exception. 1710 * @throws { BusinessError } 6600102 - The session does not exist. 1711 * @syscap SystemCapability.Multimedia.AVSession.Core 1712 * @since 11 1713 */ 1714 on(type: 'answer', callback: Callback<void>): void; 1715 1716 /** 1717 * Unregister answer command callback. 1718 * @param { 'answer' } type - Command to register 'answer'. 1719 * @param { Callback<void> } callback - Used to handle ('answer') command 1720 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1721 * 2.Incorrect parameter types. 1722 * @throws { BusinessError } 6600101 - Session service exception. 1723 * @throws { BusinessError } 6600102 - The session does not exist. 1724 * @syscap SystemCapability.Multimedia.AVSession.Core 1725 * @since 11 1726 */ 1727 off(type: 'answer', callback?: Callback<void>): void; 1728 1729 /** 1730 * Register hangUp command callback. 1731 * As long as it is registered, it means that the ability supports this command. 1732 * If you cancel the callback, you need to call off {@link off} 1733 * @param { 'hangUp' } type - Command to register 'hangUp'. 1734 * @param { Callback<void> } callback - Used to handle ('hangUp') command 1735 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1736 * 2.Incorrect parameter types. 1737 * @throws { BusinessError } 6600101 - Session service exception. 1738 * @throws { BusinessError } 6600102 - The session does not exist. 1739 * @syscap SystemCapability.Multimedia.AVSession.Core 1740 * @since 11 1741 */ 1742 on(type: 'hangUp', callback: Callback<void>): void; 1743 1744 /** 1745 * Unregister hangUp command callback. 1746 * @param { 'hangUp' } type - Command to register 'hangUp'. 1747 * @param { Callback<void> } callback - Used to handle ('hangUp') command 1748 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1749 * 2.Incorrect parameter types. 1750 * @throws { BusinessError } 6600101 - Session service exception. 1751 * @throws { BusinessError } 6600102 - The session does not exist. 1752 * @syscap SystemCapability.Multimedia.AVSession.Core 1753 * @since 11 1754 */ 1755 off(type: 'hangUp', callback?: Callback<void>): void; 1756 1757 /** 1758 * Register toggleCallMute command callback. 1759 * As long as it is registered, it means that the ability supports this command. 1760 * If you cancel the callback, you need to call off {@link off} 1761 * @param { 'toggleCallMute' } type - Command to register 'toggleCallMute'. 1762 * @param { Callback<void> } callback - Used to handle ('toggleCallMute') command 1763 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1764 * 2.Incorrect parameter types. 1765 * @throws { BusinessError } 6600101 - Session service exception. 1766 * @throws { BusinessError } 6600102 - The session does not exist. 1767 * @syscap SystemCapability.Multimedia.AVSession.Core 1768 * @since 11 1769 */ 1770 on(type: 'toggleCallMute', callback: Callback<void>): void; 1771 1772 /** 1773 * Unregister toggleCallMute command callback. 1774 * @param { 'toggleCallMute' } type - Command to register 'toggleCallMute'. 1775 * @param { Callback<void> } callback - Used to handle ('toggleCallMute') command 1776 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified.2.Incorrect parameter types. 1777 * @throws { BusinessError } 6600101 - Session service exception. 1778 * @throws { BusinessError } 6600102 - The session does not exist. 1779 * @syscap SystemCapability.Multimedia.AVSession.Core 1780 * @since 11 1781 */ 1782 off(type: 'toggleCallMute', callback?: Callback<void>): void; 1783 1784 /** 1785 * Register listener for cast display information changed. 1786 * @param { 'castDisplayChange' } type - Type of the 'castDisplayChange' to listen for. 1787 * @param { Callback<CastDisplayInfo> } callback - Callback used to return cast display information. 1788 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1789 * 2.Incorrect parameter types. 1790 * @throws { BusinessError } 6600101 - Session service exception 1791 * @throws { BusinessError } 6600102 - The session does not exist 1792 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 1793 * @since 12 1794 */ 1795 on(type: 'castDisplayChange', callback: Callback<CastDisplayInfo>): void; 1796 1797 /** 1798 * Unregister listener for cast display information changed. 1799 * @param { 'castDisplayChange' } type - Type of the 'castDisplayChange' to listen for. 1800 * @param { Callback<CastDisplayInfo> } callback - Callback used to return cast display information. 1801 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 1802 * 2.Incorrect parameter types. 1803 * @throws { BusinessError } 6600101 - Session service exception 1804 * @throws { BusinessError } 6600102 - The session does not exist 1805 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 1806 * @since 12 1807 */ 1808 off(type: 'castDisplayChange', callback?: Callback<CastDisplayInfo>): void; 1809 1810 /** 1811 * Stop current cast and disconnect device connection. 1812 * @param { AsyncCallback<void> } callback A callback instance used to return when cast stopped completed. 1813 * @throws { BusinessError } 6600109 - The remote connection is not established 1814 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1815 * @since 10 1816 */ 1817 stopCasting(callback: AsyncCallback<void>): void; 1818 1819 /** 1820 * Stop current cast and disconnect device connection. 1821 * @returns { Promise<void> } void result promise when executed successfully 1822 * @throws { BusinessError } 6600109 - The remote connection is not established 1823 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1824 * @since 10 1825 */ 1826 /** 1827 * Stop current cast and disconnect device connection. 1828 * @returns { Promise<void> } void result promise when executed successfully 1829 * @throws { BusinessError } 6600109 - The remote connection is not established 1830 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1831 * @atomicservice 1832 * @since 12 1833 */ 1834 stopCasting(): Promise<void>; 1835 1836 /** 1837 * Activate the session, indicating that the session can accept control commands 1838 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the session is activated. 1839 * @throws { BusinessError } 6600101 - Session service exception. 1840 * @throws { BusinessError } 6600102 - The session does not exist. 1841 * @syscap SystemCapability.Multimedia.AVSession.Core 1842 * @since 10 1843 */ 1844 activate(callback: AsyncCallback<void>): void; 1845 1846 /** 1847 * Activate the session, indicating that the session can accept control commands 1848 * @returns { Promise<void> } void result promise when executed successfully 1849 * @throws { BusinessError } 6600101 - Session service exception. 1850 * @throws { BusinessError } 6600102 - The session does not exist. 1851 * @syscap SystemCapability.Multimedia.AVSession.Core 1852 * @since 10 1853 */ 1854 /** 1855 * Activate the session, indicating that the session can accept control commands 1856 * @returns { Promise<void> } void result promise when executed successfully 1857 * @throws { BusinessError } 6600101 - Session service exception. 1858 * @throws { BusinessError } 6600102 - The session does not exist. 1859 * @syscap SystemCapability.Multimedia.AVSession.Core 1860 * @atomicservice 1861 * @since 12 1862 */ 1863 activate(): Promise<void>; 1864 1865 /** 1866 * Deactivate the session, indicating that the session not ready to accept control commands 1867 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the session is deactivated. 1868 * @throws { BusinessError } 6600101 - Session service exception. 1869 * @throws { BusinessError } 6600102 - The session does not exist. 1870 * @syscap SystemCapability.Multimedia.AVSession.Core 1871 * @since 10 1872 */ 1873 deactivate(callback: AsyncCallback<void>): void; 1874 1875 /** 1876 * Deactivate the session, indicating that the session not ready to accept control commands 1877 * @returns { Promise<void> } void promise when executed successfully 1878 * @throws { BusinessError } 6600101 - Session service exception. 1879 * @throws { BusinessError } 6600102 - The session does not exist. 1880 * @syscap SystemCapability.Multimedia.AVSession.Core 1881 * @since 10 1882 */ 1883 /** 1884 * Deactivate the session, indicating that the session not ready to accept control commands 1885 * @returns { Promise<void> } void promise when executed successfully 1886 * @throws { BusinessError } 6600101 - Session service exception. 1887 * @throws { BusinessError } 6600102 - The session does not exist. 1888 * @syscap SystemCapability.Multimedia.AVSession.Core 1889 * @atomicservice 1890 * @since 12 1891 */ 1892 deactivate(): Promise<void>; 1893 1894 /** 1895 * Destroy this session, the server will clean up the session resources 1896 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 1897 * @throws { BusinessError } 6600101 - Session service exception. 1898 * @throws { BusinessError } 6600102 - The session does not exist. 1899 * @syscap SystemCapability.Multimedia.AVSession.Core 1900 * @since 10 1901 */ 1902 destroy(callback: AsyncCallback<void>): void; 1903 1904 /** 1905 * Destroy this session, the server will clean up the session resources 1906 * @returns { Promise<void> } void promise when executed successfully 1907 * @throws { BusinessError } 6600101 - Session service exception. 1908 * @throws { BusinessError } 6600102 - The session does not exist. 1909 * @syscap SystemCapability.Multimedia.AVSession.Core 1910 * @since 10 1911 */ 1912 /** 1913 * Destroy this session, the server will clean up the session resources 1914 * @returns { Promise<void> } void promise when executed successfully 1915 * @throws { BusinessError } 6600101 - Session service exception. 1916 * @throws { BusinessError } 6600102 - The session does not exist. 1917 * @syscap SystemCapability.Multimedia.AVSession.Core 1918 * @atomicservice 1919 * @since 12 1920 */ 1921 destroy(): Promise<void>; 1922 } 1923 1924 /** 1925 * The type of control command 1926 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1927 * @since 10 1928 */ 1929 /** 1930 * The type of control command 1931 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1932 * @atomicservice 1933 * @since 12 1934 */ 1935 type AVCastControlCommandType = 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind' | 1936 'seek' | 'setVolume' | 'setSpeed' | 'setLoopMode' | 'toggleFavorite' | 'toggleMute'; 1937 1938 /** 1939 * The definition of command to be sent to the session 1940 * @interface AVCastControlCommand 1941 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1942 * @since 10 1943 */ 1944 /** 1945 * The definition of command to be sent to the session 1946 * @interface AVCastControlCommand 1947 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1948 * @atomicservice 1949 * @since 12 1950 */ 1951 interface AVCastControlCommand { 1952 /** 1953 * The command value {@link AVCastControlCommandType} 1954 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1955 * @since 10 1956 */ 1957 /** 1958 * The command value {@link AVCastControlCommandType} 1959 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1960 * @atomicservice 1961 * @since 12 1962 */ 1963 command: AVCastControlCommandType; 1964 1965 /** 1966 * Parameter carried in the command. 1967 * The seek command must carry the number parameter. 1968 * The setVolume command must carry the number parameter. 1969 * The toggleFavorite command must carry the {@link AVMediaDescription.assetId} parameter. 1970 * The setSpeed command must carry the {@link #media.PlaybackSpeed} parameter. 1971 * The setLoopMode command must carry the {@link LoopMode} parameter. 1972 * Other commands do not need to carry parameters. 1973 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1974 * @since 10 1975 */ 1976 /** 1977 * Parameter carried in the command. 1978 * The seek command must carry the number parameter. 1979 * The setVolume command must carry the number parameter. 1980 * The toggleFavorite command must carry the {@link AVMediaDescription.assetId} parameter. 1981 * The setSpeed command must carry the {@link #media.PlaybackSpeed} parameter. 1982 * The setLoopMode command must carry the {@link LoopMode} parameter. 1983 * Other commands do not need to carry parameters. 1984 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1985 * @atomicservice 1986 * @since 12 1987 */ 1988 parameter?: media.PlaybackSpeed | number | string | LoopMode; 1989 } 1990 1991 /** 1992 * AVCastController definition used to implement a remote control when a cast is connected 1993 * @interface AVCastController 1994 * @syscap SystemCapability.Multimedia.AVSession.AVCast 1995 * @since 10 1996 */ 1997 /** 1998 * AVCastController definition used to implement a remote control when a cast is connected 1999 * @interface AVCastController 2000 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2001 * @atomicservice 2002 * @since 12 2003 */ 2004 interface AVCastController { 2005 /** 2006 * Set a surface instance to display playing view, used at sink side. 2007 * @param { string } surfaceId - surface id, video player will use this id get a surface instance. 2008 * @param { AsyncCallback<void> } callback - A callback instance used to return when set surface completed. 2009 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2010 * 2.Parameter verification failed. 2011 * @throws { BusinessError } 6600109 - The remote connection is not established 2012 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2013 * @systemapi 2014 * @since 10 2015 */ 2016 setDisplaySurface(surfaceId: string, callback: AsyncCallback<void>): void; 2017 2018 /** 2019 * Set a surface instance to display playing view, used at sink side. 2020 * @param { string } surfaceId - surface id, video player will use this id get a surface instance. 2021 * @returns { Promise<void> } Promise used to return the result. 2022 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2023 * 2.Parameter verification failed. 2024 * @throws { BusinessError } 6600109 - The remote connection is not established 2025 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2026 * @systemapi 2027 * @since 10 2028 */ 2029 setDisplaySurface(surfaceId: string): Promise<void>; 2030 2031 /** 2032 * Get the playback status of the current player 2033 * @param { AsyncCallback<AVPlaybackState> } callback - The triggered asyncCallback when (getAVPlaybackState). 2034 * @throws { BusinessError } 6600101 - Session service exception 2035 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2036 * @since 10 2037 */ 2038 getAVPlaybackState(callback: AsyncCallback<AVPlaybackState>): void; 2039 2040 /** 2041 * Get the playback status of the current player 2042 * @returns { Promise<AVPlaybackState> } (AVPlaybackState) returned through promise 2043 * @throws { BusinessError } 6600101 - Session service exception 2044 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2045 * @since 10 2046 */ 2047 /** 2048 * Get the playback status of the current player 2049 * @returns { Promise<AVPlaybackState> } (AVPlaybackState) returned through promise 2050 * @throws { BusinessError } 6600101 - Session service exception 2051 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2052 * @atomicservice 2053 * @since 12 2054 */ 2055 getAVPlaybackState(): Promise<AVPlaybackState>; 2056 2057 /** 2058 * Send control commands to remote player 2059 * @param { AVCastControlCommand } command The command to be send. 2060 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 2061 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2062 * 2.Parameter verification failed. 2063 * @throws { BusinessError } 6600101 - Session service exception 2064 * @throws { BusinessError } 6600105 - Invalid session command 2065 * @throws { BusinessError } 6600109 - The remote connection is not established 2066 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2067 * @since 10 2068 */ 2069 sendControlCommand(command: AVCastControlCommand, callback: AsyncCallback<void>): void; 2070 2071 /** 2072 * Send control commands to remote player 2073 * @param { AVCastControlCommand } command The command to be send. 2074 * @returns { Promise<void> } Promise used to return the result. 2075 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2076 * 2.Parameter verification failed. 2077 * @throws { BusinessError } 6600101 - Session service exception 2078 * @throws { BusinessError } 6600105 - Invalid session command 2079 * @throws { BusinessError } 6600109 - The remote connection is not established 2080 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2081 * @since 10 2082 */ 2083 /** 2084 * Send control commands to remote player 2085 * @param { AVCastControlCommand } command The command to be send. 2086 * @returns { Promise<void> } Promise used to return the result. 2087 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2088 * 2.Parameter verification failed. 2089 * @throws { BusinessError } 6600101 - Session service exception 2090 * @throws { BusinessError } 6600105 - Invalid session command 2091 * @throws { BusinessError } 6600109 - The remote connection is not established 2092 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2093 * @atomicservice 2094 * @since 12 2095 */ 2096 sendControlCommand(command: AVCastControlCommand): Promise<void>; 2097 2098 /** 2099 * Play the current item, should contain mediaUri otherwise the playback will fail. 2100 * @param { AVQueueItem } item media item info. 2101 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 2102 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2103 * 2.Parameter verification failed. 2104 * @throws {BusinessError} 6600101 - Session service exception 2105 * @throws {BusinessError} 6600109 - The remote connection is not established 2106 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2107 * @since 10 2108 */ 2109 start(item: AVQueueItem, callback: AsyncCallback<void>): void; 2110 2111 /** 2112 * Play the current item, should contain mediaUri otherwise the playback will fail. 2113 * @param { AVQueueItem } item media item info. 2114 * @returns { Promise<void> } Promise used to return the result. 2115 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2116 * 2.Parameter verification failed. 2117 * @throws {BusinessError} 6600101 - Session service exception 2118 * @throws {BusinessError} 6600109 - The remote connection is not established 2119 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2120 * @since 10 2121 */ 2122 /** 2123 * Play the current item, should contain mediaUri otherwise the playback will fail. 2124 * @param { AVQueueItem } item media item info. 2125 * @returns { Promise<void> } Promise used to return the result. 2126 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2127 * 2.Parameter verification failed. 2128 * @throws {BusinessError} 6600101 - Session service exception 2129 * @throws {BusinessError} 6600109 - The remote connection is not established 2130 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2131 * @atomicservice 2132 * @since 12 2133 */ 2134 start(item: AVQueueItem): Promise<void>; 2135 2136 /** 2137 * Load the current item and mediaUri can be null, this is needed for sink media information displaying 2138 * @param { AVQueueItem } item media item info. 2139 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 2140 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2141 * 2.Parameter verification failed. 2142 * @throws {BusinessError} 6600101 - Session service exception 2143 * @throws {BusinessError} 6600109 - The remote connection is not established 2144 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2145 * @since 10 2146 */ 2147 prepare(item: AVQueueItem, callback: AsyncCallback<void>): void; 2148 2149 /** 2150 * Load the current item and mediaUri can be null, this is needed for sink media information displaying 2151 * @param { AVQueueItem } item media item info. 2152 * @returns { Promise<void> } Promise used to return the result. 2153 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2154 * 2.Parameter verification failed. 2155 * @throws {BusinessError} 6600101 - Session service exception 2156 * @throws {BusinessError} 6600109 - The remote connection is not established 2157 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2158 * @since 10 2159 */ 2160 /** 2161 * Load the current item and mediaUri can be null, this is needed for sink media information displaying 2162 * @param { AVQueueItem } item media item info. 2163 * @returns { Promise<void> } Promise used to return the result. 2164 * @throws {BusinessError} 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2165 * 2.Parameter verification failed. 2166 * @throws {BusinessError} 6600101 - Session service exception 2167 * @throws {BusinessError} 6600109 - The remote connection is not established 2168 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2169 * @atomicservice 2170 * @since 12 2171 */ 2172 prepare(item: AVQueueItem): Promise<void>; 2173 2174 /** 2175 * Get the current playing item 2176 * @param { AsyncCallback<AVQueueItem> } callback - The triggered asyncCallback. 2177 * @throws { BusinessError } 6600101 - Session service exception 2178 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2179 * @since 10 2180 */ 2181 getCurrentItem(callback: AsyncCallback<AVQueueItem>): void; 2182 2183 /** 2184 * Get the current playing item 2185 * @returns { Promise<AVQueueItem> } (AVQueueItem) returned through promise 2186 * @throws { BusinessError } 6600101 - Session service exception 2187 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2188 * @since 10 2189 */ 2190 /** 2191 * Get the current playing item 2192 * @returns { Promise<AVQueueItem> } (AVQueueItem) returned through promise 2193 * @throws { BusinessError } 6600101 - Session service exception 2194 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2195 * @atomicservice 2196 * @since 12 2197 */ 2198 getCurrentItem(): Promise<AVQueueItem>; 2199 2200 /** 2201 * Get commands supported by the current cast controller 2202 * @param { AsyncCallback<Array<AVCastControlCommandType>> } callback - The triggered asyncCallback when (getValidCommands). 2203 * @throws { BusinessError } 6600101 - Session service exception. 2204 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2205 * @since 11 2206 */ 2207 getValidCommands(callback: AsyncCallback<Array<AVCastControlCommandType>>): void; 2208 2209 /** 2210 * Get commands supported by the current cast controller 2211 * @returns { Promise<Array<AVCastControlCommandType>> } array of AVCastControlCommandType promise 2212 * @throws { BusinessError } 6600101 - Session service exception. 2213 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2214 * @since 11 2215 */ 2216 getValidCommands(): Promise<Array<AVCastControlCommandType>>; 2217 2218 /** 2219 * Process the response corresponding to the media key request obtained by the application. 2220 * @param { string } assetId - The assetId of resource which provides the response. 2221 * @param { Uint8Array } response - Response corresponding to the request. 2222 * @returns { Promise<void> } void promise when executed successfully 2223 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2224 * 2.Parameter verification failed. 2225 * @throws { BusinessError } 6600101 - Session service exception 2226 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2227 * @atomicservice 2228 * @since 12 2229 */ 2230 processMediaKeyResponse(assetId: string, response: Uint8Array): Promise<void>; 2231 2232 /** 2233 * Destroy the controller 2234 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 2235 * @throws { BusinessError } 6600101 - Session service exception. 2236 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2237 * @since 11 2238 */ 2239 release(callback: AsyncCallback<void>): void; 2240 2241 /** 2242 * Destroy the controller 2243 * @returns { Promise<void> } void promise when executed successfully 2244 * @throws { BusinessError } 6600101 - Session service exception. 2245 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2246 * @since 11 2247 */ 2248 /** 2249 * Destroy the controller 2250 * @returns { Promise<void> } void promise when executed successfully 2251 * @throws { BusinessError } 6600101 - Session service exception. 2252 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2253 * @atomicservice 2254 * @since 12 2255 */ 2256 release(): Promise<void>; 2257 2258 /** 2259 * Register playback state changed callback 2260 * @param { 'playbackStateChange' } type 2261 * @param { Array<keyof AVPlaybackState> | 'all' } filter - The properties of {@link AVPlaybackState} that you cared about 2262 * @param { function } callback - The callback used to handle playback state changed event. 2263 * The callback function provides the {@link AVPlaybackState} parameter. 2264 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2265 * 2.Incorrect parameter types. 2266 * @throws { BusinessError } 6600101 - Session service exception 2267 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2268 * @since 10 2269 */ 2270 /** 2271 * Register playback state changed callback 2272 * @param { 'playbackStateChange' } type 2273 * @param { Array<keyof AVPlaybackState> | 'all' } filter - The properties of {@link AVPlaybackState} that you cared about 2274 * @param { function } callback - The callback used to handle playback state changed event. 2275 * The callback function provides the {@link AVPlaybackState} parameter. 2276 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2277 * 2.Incorrect parameter types. 2278 * @throws { BusinessError } 6600101 - Session service exception 2279 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2280 * @atomicservice 2281 * @since 12 2282 */ 2283 on(type: 'playbackStateChange', filter: Array<keyof AVPlaybackState> | 'all', callback: (state: AVPlaybackState) => void): void; 2284 2285 /** 2286 * Unregister playback state changed callback 2287 * @param { 'playbackStateChange' } type 2288 * @param { function } callback - The callback used to handle playback state changed event. 2289 * The callback function provides the {@link AVPlaybackState} parameter. 2290 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2291 * 2.Incorrect parameter types. 2292 * @throws { BusinessError } 6600101 - Session service exception 2293 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2294 * @since 10 2295 */ 2296 /** 2297 * Unregister playback state changed callback 2298 * @param { 'playbackStateChange' } type 2299 * @param { function } callback - The callback used to handle playback state changed event. 2300 * The callback function provides the {@link AVPlaybackState} parameter. 2301 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2302 * 2.Incorrect parameter types. 2303 * @throws { BusinessError } 6600101 - Session service exception 2304 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2305 * @atomicservice 2306 * @since 12 2307 */ 2308 off(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void): void; 2309 2310 /** 2311 * Register listener for current media item playback events. 2312 * @param { 'mediaItemChange' } type Type of the playback event to listen for. 2313 * @param { Callback<AVQueueItem> } callback Callback used to listen for current item changed. 2314 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2315 * 2.Incorrect parameter types. 2316 * @throws { BusinessError } 6600101 - Session service exception 2317 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2318 * @since 10 2319 */ 2320 /** 2321 * Register listener for current media item playback events. 2322 * @param { 'mediaItemChange' } type Type of the playback event to listen for. 2323 * @param { Callback<AVQueueItem> } callback Callback used to listen for current item changed. 2324 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2325 * 2.Incorrect parameter types. 2326 * @throws { BusinessError } 6600101 - Session service exception 2327 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2328 * @atomicservice 2329 * @since 12 2330 */ 2331 on(type: 'mediaItemChange', callback: Callback<AVQueueItem>): void; 2332 2333 /** 2334 * Unregister listener for current media item playback events. 2335 * @param { 'mediaItemChange' } type Type of the playback event to listen for. 2336 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2337 * 2.Incorrect parameter types. 2338 * @throws { BusinessError } 6600101 - Session service exception 2339 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2340 * @since 10 2341 */ 2342 /** 2343 * Unregister listener for current media item playback events. 2344 * @param { 'mediaItemChange' } type Type of the playback event to listen for. 2345 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2346 * 2.Incorrect parameter types. 2347 * @throws { BusinessError } 6600101 - Session service exception 2348 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2349 * @atomicservice 2350 * @since 12 2351 */ 2352 off(type: 'mediaItemChange'): void; 2353 2354 /** 2355 * Register playback command callback sent by remote side or media center. 2356 * Application needs update the new media resource when receive these commands by using playItem. 2357 * @param { 'playNext' } type - Type of the 'playNext' event to listen for. 2358 * @param { Callback<void> } callback - Used to handle 'playNext' command 2359 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2360 * 2.Incorrect parameter types. 2361 * @throws { BusinessError } 6600101 - Session service exception 2362 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2363 * @since 10 2364 */ 2365 /** 2366 * Register playback command callback sent by remote side or media center. 2367 * Application needs update the new media resource when receive these commands by using playItem. 2368 * @param { 'playNext' } type - Type of the 'playNext' event to listen for. 2369 * @param { Callback<void> } callback - Used to handle 'playNext' command 2370 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2371 * 2.Incorrect parameter types. 2372 * @throws { BusinessError } 6600101 - Session service exception 2373 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2374 * @atomicservice 2375 * @since 12 2376 */ 2377 on(type: 'playNext', callback: Callback<void>): void; 2378 2379 /** 2380 * Unregister playback command callback sent by remote side or media center. 2381 * When canceling the callback, need to update the supported commands list. 2382 * @param { 'playNext' } type - Type of the 'playNext' event to listen for. 2383 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2384 * 2.Incorrect parameter types. 2385 * @throws { BusinessError } 6600101 - Session service exception 2386 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2387 * @since 10 2388 */ 2389 /** 2390 * Unregister playback command callback sent by remote side or media center. 2391 * When canceling the callback, need to update the supported commands list. 2392 * @param { 'playNext' } type - Type of the 'playNext' event to listen for. 2393 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2394 * 2.Incorrect parameter types. 2395 * @throws { BusinessError } 6600101 - Session service exception 2396 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2397 * @atomicservice 2398 * @since 12 2399 */ 2400 off(type: 'playNext'): void; 2401 2402 /** 2403 * Register playback command callback sent by remote side or media center. 2404 * Application needs update the new media resource when receive these commands by using playItem. 2405 * @param { 'playPrevious' } type - Type of the 'playPrevious' to listen for. 2406 * @param { Callback<void> } callback - Used to handle 'playPrevious' command 2407 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2408 * 2.Incorrect parameter types. 2409 * @throws { BusinessError } 6600101 - Session service exception 2410 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2411 * @since 10 2412 */ 2413 /** 2414 * Register playback command callback sent by remote side or media center. 2415 * Application needs update the new media resource when receive these commands by using playItem. 2416 * @param { 'playPrevious' } type - Type of the 'playPrevious' to listen for. 2417 * @param { Callback<void> } callback - Used to handle 'playPrevious' command 2418 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2419 * 2.Incorrect parameter types. 2420 * @throws { BusinessError } 6600101 - Session service exception 2421 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2422 * @atomicservice 2423 * @since 12 2424 */ 2425 on(type: 'playPrevious', callback: Callback<void>): void; 2426 2427 /** 2428 * Unregister playback command callback sent by remote side or media center. 2429 * When canceling the callback, need to update the supported commands list. 2430 * @param { 'playPrevious' } type - Type of the 'playPrevious' to listen for. 2431 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2432 * 2.Incorrect parameter types. 2433 * @throws { BusinessError } 6600101 - Session service exception 2434 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2435 * @since 10 2436 */ 2437 /** 2438 * Unregister playback command callback sent by remote side or media center. 2439 * When canceling the callback, need to update the supported commands list. 2440 * @param { 'playPrevious' } type - Type of the 'playPrevious' to listen for. 2441 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2442 * 2.Incorrect parameter types. 2443 * @throws { BusinessError } 6600101 - Session service exception 2444 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2445 * @atomicservice 2446 * @since 12 2447 */ 2448 off(type: 'playPrevious'): void; 2449 2450 /** 2451 * Register requested playback command callback sent by remote side or media center. 2452 * The AVQueueItem may include the requested assetId, starting position and other configurations. 2453 * @param { 'requestPlay' } type - Type of the 'requestPlay' to listen for. 2454 * @param { Callback<AVQueueItem> } callback - Used to handle 'requestPlay' command 2455 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2456 * 2.Incorrect parameter types. 2457 * @throws { BusinessError } 6600101 - Session service exception 2458 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2459 * @since 11 2460 */ 2461 on(type: 'requestPlay', callback: Callback<AVQueueItem>): void; 2462 2463 /** 2464 * Unregister requested playback command callback sent by remote side or media center. 2465 * @param { 'requestPlay' } type - Type of the 'requestPlay' to listen for. 2466 * @param { Callback<AVQueueItem> } callback - Used to handle 'requestPlay' command 2467 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2468 * 2.Incorrect parameter types. 2469 * @throws { BusinessError } 6600101 - Session service exception 2470 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2471 * @since 11 2472 */ 2473 off(type: 'requestPlay', callback?: Callback<AVQueueItem>): void; 2474 2475 /** 2476 * Register endOfStream state callback. 2477 * Application needs update the new media resource when receive these commands by using playItem. 2478 * @param { 'endOfStream' } type - Type of the 'endOfStream' to listen for. 2479 * @param { Callback<void> } callback - Used to handle 'endOfStream' command 2480 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2481 * 2.Incorrect parameter types. 2482 * @throws { BusinessError } 6600101 - Session service exception 2483 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2484 * @since 11 2485 */ 2486 on(type: 'endOfStream', callback: Callback<void>): void; 2487 2488 /** 2489 * Unregister endOfStream state callback. 2490 * @param { 'endOfStream' } type - Type of the 'endOfStream' to listen for. 2491 * @param { Callback<void> } callback - Used to handle 'endOfStream' command 2492 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2493 * 2.Incorrect parameter types. 2494 * @throws { BusinessError } 6600101 - Session service exception 2495 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2496 * @since 11 2497 */ 2498 off(type: 'endOfStream', callback?: Callback<void>): void; 2499 2500 /** 2501 * Register listens for playback events. 2502 * @param { 'seekDone' } type - Type of the 'seekDone' to listen for. 2503 * @param { Callback<number> } callback - Callback used to listen for the playback seekDone event. 2504 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2505 * 2.Incorrect parameter types. 2506 * @throws { BusinessError } 6600101 - Session service exception 2507 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2508 * @since 10 2509 */ 2510 /** 2511 * Register listens for playback events. 2512 * @param { 'seekDone' } type - Type of the 'seekDone' to listen for. 2513 * @param { Callback<number> } callback - Callback used to listen for the playback seekDone event. 2514 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2515 * 2.Incorrect parameter types. 2516 * @throws { BusinessError } 6600101 - Session service exception 2517 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2518 * @atomicservice 2519 * @since 12 2520 */ 2521 on(type: 'seekDone', callback: Callback<number>): void; 2522 2523 /** 2524 * Unregister listens for playback events. 2525 * @param { 'seekDone' } type - Type of the 'seekDone' to listen for. 2526 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2527 * 2.Incorrect parameter types. 2528 * @throws { BusinessError } 6600101 - Session service exception 2529 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2530 * @since 10 2531 */ 2532 /** 2533 * Unregister listens for playback events. 2534 * @param { 'seekDone' } type - Type of the 'seekDone' to listen for. 2535 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2536 * 2.Incorrect parameter types. 2537 * @throws { BusinessError } 6600101 - Session service exception 2538 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2539 * @atomicservice 2540 * @since 12 2541 */ 2542 off(type: 'seekDone'): void; 2543 2544 /** 2545 * Register the valid commands of the casted session changed callback 2546 * @param { 'validCommandChange' } type - 'validCommandChange' 2547 * @param { Callback<Array<AVCastControlCommandType>> } callback - The callback used to handle the changes. 2548 * The callback function provides an array of AVCastControlCommandType. 2549 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2550 * 2.Incorrect parameter types. 2551 * @throws { BusinessError } 6600101 - Session service exception. 2552 * @throws { BusinessError } 6600103 - The session controller does not exist. 2553 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2554 * @since 11 2555 */ 2556 on(type: 'validCommandChange', callback: Callback<Array<AVCastControlCommandType>>); 2557 2558 /** 2559 * Unregister the valid commands of the casted session changed callback 2560 * @param { 'validCommandChange' } type - 'validCommandChange' 2561 * @param { Callback<Array<AVCastControlCommandType>> } callback - The callback used to handle the changes. 2562 * The callback function provides an array of AVCastControlCommandType. 2563 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2564 * 2.Incorrect parameter types. 2565 * @throws { BusinessError } 6600101 - Session service exception. 2566 * @throws { BusinessError } 6600103 - The session controller does not exist. 2567 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2568 * @since 11 2569 */ 2570 off(type: 'validCommandChange', callback?: Callback<Array<AVCastControlCommandType>>); 2571 2572 /** 2573 * Register listener for video size change event, used at remote side. 2574 * @param { 'videoSizeChange' } type - Type of the 'videoSizeChange' to listen for. 2575 * @param { function } callback - Callback used to return video size. 2576 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2577 * 2.Incorrect parameter types. 2578 * @throws { BusinessError } 6600101 - Session service exception 2579 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2580 * @systemapi 2581 * @since 10 2582 */ 2583 on(type: 'videoSizeChange', callback: (width: number, height: number) => void): void; 2584 2585 /** 2586 * Unregister listener for video size change event, used at remote side. 2587 * @param { 'videoSizeChange' } type - Type of the 'videoSizeChange' to listen for. 2588 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2589 * 2.Incorrect parameter types. 2590 * @throws { BusinessError } 6600101 - Session service exception 2591 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2592 * @systemapi 2593 * @since 10 2594 */ 2595 off(type: 'videoSizeChange'): void; 2596 2597 /** 2598 * Register listeners for playback error events. 2599 * @param { 'error' } type Type of the 'error' to listen for. 2600 * @param { ErrorCallback } callback Callback used to listen for the playback error event. 2601 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2602 * 2.Incorrect parameter types. 2603 * @throws { BusinessError } 5400101 - No memory. 2604 * @throws { BusinessError } 5400102 - Operation not allowed. 2605 * @throws { BusinessError } 5400103 - I/O error. 2606 * @throws { BusinessError } 5400104 - Time out. 2607 * @throws { BusinessError } 5400105 - Service died. 2608 * @throws { BusinessError } 5400106 - Unsupport format. 2609 * @throws { BusinessError } 6600101 - Session service exception 2610 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2611 * @since 10 2612 */ 2613 /** 2614 * Register listeners for playback error events. 2615 * @param { 'error' } type Type of the 'error' to listen for. 2616 * @param { ErrorCallback } callback Callback used to listen for the playback error event. 2617 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2618 * 2.Incorrect parameter types. 2619 * @throws { BusinessError } 5400101 - No memory. 2620 * @throws { BusinessError } 5400102 - Operation not allowed. 2621 * @throws { BusinessError } 5400103 - I/O error. 2622 * @throws { BusinessError } 5400104 - Time out. 2623 * @throws { BusinessError } 5400105 - Service died. 2624 * @throws { BusinessError } 5400106 - Unsupport format. 2625 * @throws { BusinessError } 6600101 - Session service exception 2626 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2627 * @atomicservice 2628 * @since 12 2629 */ 2630 on(type: 'error', callback: ErrorCallback): void; 2631 2632 /** 2633 * Unregister listens for playback error events. 2634 * @param { 'error' } type Type of the 'error' to listen for. 2635 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2636 * 2.Incorrect parameter types. 2637 * @throws { BusinessError } 5400101 - No memory. 2638 * @throws { BusinessError } 5400102 - Operation not allowed. 2639 * @throws { BusinessError } 5400103 - I/O error. 2640 * @throws { BusinessError } 5400104 - Time out. 2641 * @throws { BusinessError } 5400105 - Service died. 2642 * @throws { BusinessError } 5400106 - Unsupport format. 2643 * @throws { BusinessError } 6600101 - Session service exception 2644 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2645 * @since 10 2646 */ 2647 /** 2648 * Unregister listens for playback error events. 2649 * @param { 'error' } type Type of the 'error' to listen for. 2650 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2651 * 2.Incorrect parameter types. 2652 * @throws { BusinessError } 5400101 - No memory. 2653 * @throws { BusinessError } 5400102 - Operation not allowed. 2654 * @throws { BusinessError } 5400103 - I/O error. 2655 * @throws { BusinessError } 5400104 - Time out. 2656 * @throws { BusinessError } 5400105 - Service died. 2657 * @throws { BusinessError } 5400106 - Unsupport format. 2658 * @throws { BusinessError } 6600101 - Session service exception 2659 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2660 * @atomicservice 2661 * @since 12 2662 */ 2663 off(type: 'error'): void; 2664 2665 /** 2666 * Register listener for drm key request. 2667 * @param { 'keyRequest' } type - Type of the 'keyRequest' to listen for. 2668 * @param { KeyRequestCallback } callback - Callback used to request drm key. 2669 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2670 * 2.Incorrect parameter types. 2671 * @throws { BusinessError } 6600101 - Session service exception 2672 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2673 * @atomicservice 2674 * @since 12 2675 */ 2676 on(type: 'keyRequest', callback: KeyRequestCallback): void; 2677 2678 /** 2679 * Unregister listener for drm key request. 2680 * @param { 'keyRequest' } type - Type of the 'keyRequest' to listen for. 2681 * @param { KeyRequestCallback } callback - Callback used to request drm key. 2682 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 2683 * 2.Incorrect parameter types. 2684 * @throws { BusinessError } 6600101 - Session service exception 2685 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2686 * @atomicservice 2687 * @since 12 2688 */ 2689 off(type: 'keyRequest', callback?: KeyRequestCallback): void; 2690 } 2691 2692 /** 2693 * The callback of key request. 2694 * 2695 * @typedef { Function } KeyRequestCallback 2696 * @param { string } assetId - request key for current assetId 2697 * @param { Uint8Array } requestData - media key request data sent to media key server 2698 * @syscap SystemCapability.Multimedia.AVSession.AVCast 2699 * @atomicservice 2700 * @since 12 2701 */ 2702 type KeyRequestCallback = (assetId: string, requestData: Uint8Array) => void; 2703 2704 /** 2705 * Enumerates the cast display states. 2706 * 2707 * @enum { number } 2708 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2709 * @since 12 2710 */ 2711 enum CastDisplayState { 2712 /** 2713 * Screen off. 2714 * 2715 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2716 * @since 12 2717 */ 2718 STATE_OFF = 1, 2719 2720 /** 2721 * Screen on. 2722 * 2723 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2724 * @since 12 2725 */ 2726 STATE_ON, 2727 } 2728 2729 /** 2730 * Define the information for extended display screen. 2731 * @typedef CastDisplayInfo 2732 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2733 * @since 12 2734 */ 2735 interface CastDisplayInfo { 2736 /** 2737 * Display ID. 2738 * The application can get more display information based on the same id from display interface. 2739 * 2740 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2741 * @since 12 2742 */ 2743 id: number; 2744 2745 /** 2746 * Display name. 2747 * 2748 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2749 * @since 12 2750 */ 2751 name: string; 2752 2753 /** 2754 * The state of display. 2755 * 2756 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2757 * @since 12 2758 */ 2759 state: CastDisplayState; 2760 2761 /** 2762 * Display width, in pixels. 2763 * 2764 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2765 * @since 12 2766 */ 2767 width: number; 2768 2769 /** 2770 * Display height, in pixels. 2771 * 2772 * @syscap SystemCapability.Multimedia.AVSession.ExtendedDisplayCast 2773 * @since 12 2774 */ 2775 height: number; 2776 } 2777 2778 /** 2779 * Define the device connection state. 2780 * @enum { number } 2781 * @syscap SystemCapability.Multimedia.AVSession.Core 2782 * @since 10 2783 */ 2784 /** 2785 * Define the device connection state. 2786 * @enum { number } 2787 * @syscap SystemCapability.Multimedia.AVSession.Core 2788 * @atomicservice 2789 * @since 12 2790 */ 2791 enum ConnectionState { 2792 /** 2793 * A connection state indicating the device is in the process of connecting. 2794 * @syscap SystemCapability.Multimedia.AVSession.Core 2795 * @since 10 2796 */ 2797 /** 2798 * A connection state indicating the device is in the process of connecting. 2799 * @syscap SystemCapability.Multimedia.AVSession.Core 2800 * @atomicservice 2801 * @since 12 2802 */ 2803 STATE_CONNECTING = 0, 2804 2805 /** 2806 * A connection state indicating the device is connected. 2807 * @syscap SystemCapability.Multimedia.AVSession.Core 2808 * @since 10 2809 */ 2810 /** 2811 * A connection state indicating the device is connected. 2812 * @syscap SystemCapability.Multimedia.AVSession.Core 2813 * @atomicservice 2814 * @since 12 2815 */ 2816 STATE_CONNECTED = 1, 2817 2818 /** 2819 * The default connection state indicating the device is disconnected. 2820 * @syscap SystemCapability.Multimedia.AVSession.Core 2821 * @since 10 2822 */ 2823 /** 2824 * The default connection state indicating the device is disconnected. 2825 * @syscap SystemCapability.Multimedia.AVSession.Core 2826 * @atomicservice 2827 * @since 12 2828 */ 2829 STATE_DISCONNECTED = 6, 2830 } 2831 2832 /** 2833 * The pre-defined display tag by system. 2834 * @enum { number } 2835 * @syscap SystemCapability.Multimedia.AVSession.Core 2836 * @since 11 2837 */ 2838 enum DisplayTag { 2839 /** 2840 * Indicate the AUDIO VIVID property of current media resource. 2841 * @syscap SystemCapability.Multimedia.AVSession.Core 2842 * @since 11 2843 */ 2844 TAG_AUDIO_VIVID = 1, 2845 } 2846 2847 /** 2848 * The play list information definition. 2849 * @interface AVQueueInfo 2850 * @syscap SystemCapability.Multimedia.AVSession.Core 2851 * @systemapi 2852 * @since 11 2853 */ 2854 interface AVQueueInfo { 2855 /** 2856 * The bundle name of application which current play list belongs to. 2857 * @type { string } 2858 * @syscap SystemCapability.Multimedia.AVSession.Core 2859 * @systemapi 2860 * @since 11 2861 */ 2862 bundleName: string; 2863 2864 /** 2865 * The name of play list 2866 * @type { string } 2867 * @syscap SystemCapability.Multimedia.AVSession.Core 2868 * @systemapi 2869 * @since 11 2870 */ 2871 avQueueName: string; 2872 2873 /** 2874 * The id of play list 2875 * @type { string } 2876 * @syscap SystemCapability.Multimedia.AVSession.Core 2877 * @systemapi 2878 * @since 11 2879 */ 2880 avQueueId: string; 2881 2882 /** 2883 * The artwork of play list, can be a {@link PixelMap} or a URI formatted string, 2884 * @syscap SystemCapability.Multimedia.AVSession.Core 2885 * @systemapi 2886 * @since 11 2887 */ 2888 avQueueImage: image.PixelMap | string; 2889 2890 /** 2891 * The time when the user last played the playlist. 2892 * The time format can be system, such as 1611081385000, it means 2021-01-20 02:36:25. 2893 * @type { ?number } 2894 * @syscap SystemCapability.Multimedia.AVSession.Core 2895 * @systemapi 2896 * @since 11 2897 */ 2898 lastPlayedTime?: number; 2899 } 2900 2901 /** 2902 * The metadata of the current media.Used to set the properties of the current media file 2903 * @interface AVMetadata 2904 * @syscap SystemCapability.Multimedia.AVSession.Core 2905 * @since 10 2906 */ 2907 /** 2908 * The metadata of the current media.Used to set the properties of the current media file 2909 * @interface AVMetadata 2910 * @syscap SystemCapability.Multimedia.AVSession.Core 2911 * @atomicservice 2912 * @since 12 2913 */ 2914 interface AVMetadata { 2915 /** 2916 * Unique ID used to represent this media. 2917 * @type { string } 2918 * @syscap SystemCapability.Multimedia.AVSession.Core 2919 * @since 10 2920 */ 2921 /** 2922 * Unique ID used to represent this media. 2923 * @type { string } 2924 * @syscap SystemCapability.Multimedia.AVSession.Core 2925 * @atomicservice 2926 * @since 12 2927 */ 2928 assetId: string; 2929 2930 /** 2931 * The title of this media, for display in media center. 2932 * @type { ?string } 2933 * @syscap SystemCapability.Multimedia.AVSession.Core 2934 * @since 10 2935 */ 2936 /** 2937 * The title of this media, for display in media center. 2938 * @type { ?string } 2939 * @syscap SystemCapability.Multimedia.AVSession.Core 2940 * @atomicservice 2941 * @since 12 2942 */ 2943 title?: string; 2944 2945 /** 2946 * The artist of this media 2947 * @type { ?string } 2948 * @syscap SystemCapability.Multimedia.AVSession.Core 2949 * @since 10 2950 */ 2951 /** 2952 * The artist of this media 2953 * @type { ?string } 2954 * @syscap SystemCapability.Multimedia.AVSession.Core 2955 * @atomicservice 2956 * @since 12 2957 */ 2958 artist?: string; 2959 2960 /** 2961 * The author of this media 2962 * @type { ?string } 2963 * @syscap SystemCapability.Multimedia.AVSession.Core 2964 * @since 10 2965 */ 2966 /** 2967 * The author of this media 2968 * @type { ?string } 2969 * @syscap SystemCapability.Multimedia.AVSession.Core 2970 * @atomicservice 2971 * @since 12 2972 */ 2973 author?: string; 2974 2975 /** 2976 * The name of play list which current media belongs to 2977 * @type { ?string } 2978 * @syscap SystemCapability.Multimedia.AVSession.Core 2979 * @since 12 2980 */ 2981 avQueueName?: string; 2982 2983 /** 2984 * The id of play list which current media belongs to, it should be an unique identifier in the application. 2985 * @type { ?string } 2986 * @syscap SystemCapability.Multimedia.AVSession.Core 2987 * @since 11 2988 */ 2989 avQueueId?: string; 2990 2991 /** 2992 * The artwork of play list as a {@link PixelMap} or an uri formatted String, 2993 * @syscap SystemCapability.Multimedia.AVSession.Core 2994 * @since 11 2995 */ 2996 avQueueImage?: image.PixelMap | string; 2997 2998 /** 2999 * The album of this media 3000 * @type { ?string } 3001 * @syscap SystemCapability.Multimedia.AVSession.Core 3002 * @since 10 3003 */ 3004 /** 3005 * The album of this media 3006 * @type { ?string } 3007 * @syscap SystemCapability.Multimedia.AVSession.Core 3008 * @atomicservice 3009 * @since 12 3010 */ 3011 album?: string; 3012 3013 /** 3014 * The writer of this media 3015 * @type { ?string } 3016 * @syscap SystemCapability.Multimedia.AVSession.Core 3017 * @since 10 3018 */ 3019 /** 3020 * The writer of this media 3021 * @type { ?string } 3022 * @syscap SystemCapability.Multimedia.AVSession.Core 3023 * @atomicservice 3024 * @since 12 3025 */ 3026 writer?: string; 3027 3028 /** 3029 * The composer of this media 3030 * @type { ?string } 3031 * @syscap SystemCapability.Multimedia.AVSession.Core 3032 * @since 10 3033 */ 3034 composer?: string; 3035 3036 /** 3037 * The duration of this media, used to automatically calculate playback position 3038 * @type { ?number } 3039 * @syscap SystemCapability.Multimedia.AVSession.Core 3040 * @since 10 3041 */ 3042 /** 3043 * The duration of this media, used to automatically calculate playback position 3044 * @type { ?number } 3045 * @syscap SystemCapability.Multimedia.AVSession.Core 3046 * @atomicservice 3047 * @since 12 3048 */ 3049 duration?: number; 3050 3051 /** 3052 * The image of the media as a {@link PixelMap} or an uri formatted String, 3053 * used to display in media center. 3054 * @syscap SystemCapability.Multimedia.AVSession.Core 3055 * @since 10 3056 */ 3057 /** 3058 * The image of the media as a {@link PixelMap} or an uri formatted String, 3059 * used to display in media center. 3060 * @syscap SystemCapability.Multimedia.AVSession.Core 3061 * @atomicservice 3062 * @since 12 3063 */ 3064 mediaImage?: image.PixelMap | string; 3065 3066 /** 3067 * The publishDate of the media 3068 * @type { ?Date } 3069 * @syscap SystemCapability.Multimedia.AVSession.Core 3070 * @since 10 3071 */ 3072 publishDate?: Date; 3073 3074 /** 3075 * The subtitle of the media, used for display 3076 * @type { ?string } 3077 * @syscap SystemCapability.Multimedia.AVSession.Core 3078 * @since 10 3079 */ 3080 /** 3081 * The subtitle of the media, used for display 3082 * @type { ?string } 3083 * @syscap SystemCapability.Multimedia.AVSession.Core 3084 * @atomicservice 3085 * @since 12 3086 */ 3087 subtitle?: string; 3088 3089 /** 3090 * The discription of the media, used for display 3091 * @type { ?string } 3092 * @syscap SystemCapability.Multimedia.AVSession.Core 3093 * @since 10 3094 */ 3095 /** 3096 * The discription of the media, used for display 3097 * @type { ?string } 3098 * @syscap SystemCapability.Multimedia.AVSession.Core 3099 * @atomicservice 3100 * @since 12 3101 */ 3102 description?: string; 3103 3104 /** 3105 * The lyric of the media, it should be in standard lyric format 3106 * @type { ?string } 3107 * @syscap SystemCapability.Multimedia.AVSession.Core 3108 * @since 10 3109 */ 3110 lyric?: string; 3111 3112 /** 3113 * The previous playable media id. 3114 * Used to tell the controller if there is a previous playable media 3115 * @type { ?string } 3116 * @syscap SystemCapability.Multimedia.AVSession.Core 3117 * @since 10 3118 */ 3119 /** 3120 * The previous playable media id. 3121 * Used to tell the controller if there is a previous playable media 3122 * @type { ?string } 3123 * @syscap SystemCapability.Multimedia.AVSession.Core 3124 * @atomicservice 3125 * @since 12 3126 */ 3127 previousAssetId?: string; 3128 3129 /** 3130 * The next playable media id. 3131 * Used to tell the controller if there is a next playable media 3132 * @type { ?string } 3133 * @syscap SystemCapability.Multimedia.AVSession.Core 3134 * @since 10 3135 */ 3136 /** 3137 * The next playable media id. 3138 * Used to tell the controller if there is a next playable media 3139 * @type { ?string } 3140 * @syscap SystemCapability.Multimedia.AVSession.Core 3141 * @atomicservice 3142 * @since 12 3143 */ 3144 nextAssetId?: string; 3145 3146 /** 3147 * The protocols supported by this session, if not set, the default is {@link TYPE_CAST_PLUS_STREAM}. 3148 * See {@link ProtocolType} 3149 * @type { ?number } 3150 * @syscap SystemCapability.Multimedia.AVSession.Core 3151 * @since 11 3152 */ 3153 /** 3154 * The protocols supported by this session, if not set, the default is {@link TYPE_CAST_PLUS_STREAM}. 3155 * See {@link ProtocolType} 3156 * @type { ?number } 3157 * @syscap SystemCapability.Multimedia.AVSession.Core 3158 * @atomicservice 3159 * @since 12 3160 */ 3161 filter?: number; 3162 3163 /** 3164 * The drm schemes supported by this session which are represented by uuid. 3165 * @type { ?Array<string> } 3166 * @syscap SystemCapability.Multimedia.AVSession.Core 3167 * @since 12 3168 */ 3169 drmSchemes?: Array<string>; 3170 3171 /** 3172 * The supported skipIntervals when doing fast forward and rewind operation, the default is {@link SECONDS_15}. 3173 * See {@link SkipIntervals} 3174 * @type { ?SkipIntervals } 3175 * @syscap SystemCapability.Multimedia.AVSession.Core 3176 * @since 11 3177 */ 3178 skipIntervals?: SkipIntervals; 3179 3180 /** 3181 * The display tags supported by application to be displayed on media center 3182 * @type { ?number } 3183 * @syscap SystemCapability.Multimedia.AVSession.Core 3184 * @since 11 3185 */ 3186 displayTags?: number; 3187 } 3188 3189 /** 3190 * The description of the media for an item in the playlist of the session 3191 * @interface AVMediaDescription 3192 * @syscap SystemCapability.Multimedia.AVSession.Core 3193 * @since 10 3194 */ 3195 /** 3196 * The description of the media for an item in the playlist of the session 3197 * @interface AVMediaDescription 3198 * @syscap SystemCapability.Multimedia.AVSession.Core 3199 * @atomicservice 3200 * @since 12 3201 */ 3202 interface AVMediaDescription { 3203 /** 3204 * Unique ID used to represent this media. 3205 * @type { string } 3206 * @syscap SystemCapability.Multimedia.AVSession.Core 3207 * @since 10 3208 */ 3209 /** 3210 * Unique ID used to represent this media. 3211 * @type { string } 3212 * @syscap SystemCapability.Multimedia.AVSession.Core 3213 * @atomicservice 3214 * @since 12 3215 */ 3216 assetId: string; 3217 /** 3218 * The title of this media, for display in media center. 3219 * @type { ?string } 3220 * @syscap SystemCapability.Multimedia.AVSession.Core 3221 * @since 10 3222 */ 3223 /** 3224 * The title of this media, for display in media center. 3225 * @type { ?string } 3226 * @syscap SystemCapability.Multimedia.AVSession.Core 3227 * @atomicservice 3228 * @since 12 3229 */ 3230 title?: string; 3231 3232 /** 3233 * The subtitle of the media, used for display 3234 * @type { ?string } 3235 * @syscap SystemCapability.Multimedia.AVSession.Core 3236 * @since 10 3237 */ 3238 /** 3239 * The subtitle of the media, used for display 3240 * @type { ?string } 3241 * @syscap SystemCapability.Multimedia.AVSession.Core 3242 * @atomicservice 3243 * @since 12 3244 */ 3245 subtitle?: string; 3246 3247 /** 3248 * The description of this media 3249 * @type { ?string } 3250 * @syscap SystemCapability.Multimedia.AVSession.Core 3251 * @since 10 3252 */ 3253 /** 3254 * The description of this media 3255 * @type { ?string } 3256 * @syscap SystemCapability.Multimedia.AVSession.Core 3257 * @atomicservice 3258 * @since 12 3259 */ 3260 description?: string; 3261 3262 /** 3263 * The image of this media asset displayed in the media center. 3264 * It can be a {@link PixelMap} or a URI formatted string, 3265 * @syscap SystemCapability.Multimedia.AVSession.Core 3266 * @since 10 3267 */ 3268 /** 3269 * The image of this media asset displayed in the media center. 3270 * It can be a {@link PixelMap} or a URI formatted string, 3271 * @syscap SystemCapability.Multimedia.AVSession.Core 3272 * @atomicservice 3273 * @since 12 3274 */ 3275 mediaImage?: image.PixelMap | string; 3276 /** 3277 * Any additional attributes that can be represented as key-value pairs 3278 * @syscap SystemCapability.Multimedia.AVSession.Core 3279 * @since 10 3280 */ 3281 extras?: {[key: string]: Object}; 3282 3283 /** 3284 * The type of this media, such as video, audio and so on. 3285 * @type { ?string } 3286 * @syscap SystemCapability.Multimedia.AVSession.Core 3287 * @since 10 3288 */ 3289 /** 3290 * The type of this media, such as video, audio and so on. 3291 * @type { ?string } 3292 * @syscap SystemCapability.Multimedia.AVSession.Core 3293 * @atomicservice 3294 * @since 12 3295 */ 3296 mediaType?: string; 3297 3298 /** 3299 * The size of this media. 3300 * @type { ?number } 3301 * @syscap SystemCapability.Multimedia.AVSession.Core 3302 * @since 10 3303 */ 3304 /** 3305 * The size of this media. 3306 * @type { ?number } 3307 * @syscap SystemCapability.Multimedia.AVSession.Core 3308 * @atomicservice 3309 * @since 12 3310 */ 3311 mediaSize?: number; 3312 3313 /** 3314 * The album title of this media 3315 * @type { ?string } 3316 * @syscap SystemCapability.Multimedia.AVSession.Core 3317 * @since 10 3318 */ 3319 /** 3320 * The album title of this media 3321 * @type { ?string } 3322 * @syscap SystemCapability.Multimedia.AVSession.Core 3323 * @atomicservice 3324 * @since 12 3325 */ 3326 albumTitle?: string; 3327 3328 /** 3329 * The album cover uri of this media 3330 * @type { ?string } 3331 * @syscap SystemCapability.Multimedia.AVSession.Core 3332 * @since 10 3333 */ 3334 /** 3335 * The album cover uri of this media 3336 * @type { ?string } 3337 * @syscap SystemCapability.Multimedia.AVSession.Core 3338 * @atomicservice 3339 * @since 12 3340 */ 3341 albumCoverUri?: string; 3342 3343 /** 3344 * The lyric content of the media, it should be in standard lyric format 3345 * @type { ?string } 3346 * @syscap SystemCapability.Multimedia.AVSession.Core 3347 * @since 10 3348 */ 3349 /** 3350 * The lyric content of the media, it should be in standard lyric format 3351 * @type { ?string } 3352 * @syscap SystemCapability.Multimedia.AVSession.Core 3353 * @atomicservice 3354 * @since 12 3355 */ 3356 lyricContent?: string; 3357 3358 /** 3359 * The lyric uri of the media. 3360 * @type { ?string } 3361 * @syscap SystemCapability.Multimedia.AVSession.Core 3362 * @since 10 3363 */ 3364 /** 3365 * The lyric uri of the media. 3366 * @type { ?string } 3367 * @syscap SystemCapability.Multimedia.AVSession.Core 3368 * @atomicservice 3369 * @since 12 3370 */ 3371 lyricUri?: string; 3372 3373 /** 3374 * The artist of this media. 3375 * @type { ?string } 3376 * @syscap SystemCapability.Multimedia.AVSession.Core 3377 * @since 10 3378 */ 3379 /** 3380 * The artist of this media. 3381 * @type { ?string } 3382 * @syscap SystemCapability.Multimedia.AVSession.Core 3383 * @atomicservice 3384 * @since 12 3385 */ 3386 artist?: string; 3387 3388 /** 3389 * The uri of the media, used to locate the media in some special cases 3390 * @type { ?string } 3391 * @syscap SystemCapability.Multimedia.AVSession.Core 3392 * @since 10 3393 */ 3394 /** 3395 * The uri of the media, used to locate the media in some special cases 3396 * @type { ?string } 3397 * @syscap SystemCapability.Multimedia.AVSession.Core 3398 * @atomicservice 3399 * @since 12 3400 */ 3401 mediaUri?: string; 3402 3403 /** 3404 * Media file descriptor. 3405 * @syscap SystemCapability.Multimedia.AVSession.Core 3406 * @since 10 3407 */ 3408 /** 3409 * Media file descriptor. 3410 * @syscap SystemCapability.Multimedia.AVSession.Core 3411 * @atomicservice 3412 * @since 12 3413 */ 3414 fdSrc?: media.AVFileDescriptor; 3415 3416 /** 3417 * DataSource descriptor. The caller ensures the fileSize and callback are valid. 3418 * @type { ?media.AVDataSrcDescriptor } 3419 * @syscap SystemCapability.Multimedia.AVSession.Core 3420 * @since 12 3421 */ 3422 dataSrc?: media.AVDataSrcDescriptor; 3423 3424 /** 3425 * The drm scheme supported by this resource which is represented by uuid. 3426 * @type { ?string } 3427 * @syscap SystemCapability.Multimedia.AVSession.Core 3428 * @since 12 3429 */ 3430 drmScheme?: string; 3431 3432 /** 3433 * The duration of this media 3434 * @type { ?number } 3435 * @syscap SystemCapability.Multimedia.AVSession.Core 3436 * @since 10 3437 */ 3438 /** 3439 * The duration of this media 3440 * @type { ?number } 3441 * @syscap SystemCapability.Multimedia.AVSession.Core 3442 * @atomicservice 3443 * @since 12 3444 */ 3445 duration?: number; 3446 3447 /** 3448 * Media start position, described by milliseconds. 3449 * @type { ?number } 3450 * @syscap SystemCapability.Multimedia.AVSession.Core 3451 * @since 10 3452 */ 3453 /** 3454 * Media start position, described by milliseconds. 3455 * @type { ?number } 3456 * @syscap SystemCapability.Multimedia.AVSession.Core 3457 * @atomicservice 3458 * @since 12 3459 */ 3460 startPosition?: number; 3461 3462 /** 3463 * Media credits position, described by milliseconds. 3464 * @type { ?number } 3465 * @syscap SystemCapability.Multimedia.AVSession.Core 3466 * @since 10 3467 */ 3468 /** 3469 * Media credits position, described by milliseconds. 3470 * @type { ?number } 3471 * @syscap SystemCapability.Multimedia.AVSession.Core 3472 * @atomicservice 3473 * @since 12 3474 */ 3475 creditsPosition?: number; 3476 3477 /** 3478 * Application name. 3479 * @type { ?string } 3480 * @syscap SystemCapability.Multimedia.AVSession.Core 3481 * @since 10 3482 */ 3483 /** 3484 * Application name. 3485 * @type { ?string } 3486 * @syscap SystemCapability.Multimedia.AVSession.Core 3487 * @atomicservice 3488 * @since 12 3489 */ 3490 appName?: string; 3491 3492 /** 3493 * The display tags supported by application to be displayed on media center 3494 * @type { ?number } 3495 * @syscap SystemCapability.Multimedia.AVSession.Core 3496 * @since 11 3497 */ 3498 /** 3499 * The display tags supported by application to be displayed on media center 3500 * @type { ?number } 3501 * @syscap SystemCapability.Multimedia.AVSession.Core 3502 * @atomicservice 3503 * @since 12 3504 */ 3505 displayTags?: number; 3506 } 3507 3508 /** 3509 * The item in the playlist of the session 3510 * @interface AVQueueItem 3511 * @syscap SystemCapability.Multimedia.AVSession.Core 3512 * @since 10 3513 */ 3514 /** 3515 * The item in the playlist of the session 3516 * @interface AVQueueItem 3517 * @syscap SystemCapability.Multimedia.AVSession.Core 3518 * @atomicservice 3519 * @since 12 3520 */ 3521 interface AVQueueItem { 3522 /** 3523 * Sequence number of the item in the playlist. 3524 * @type { number } 3525 * @syscap SystemCapability.Multimedia.AVSession.Core 3526 * @since 10 3527 */ 3528 /** 3529 * Sequence number of the item in the playlist. 3530 * @type { number } 3531 * @syscap SystemCapability.Multimedia.AVSession.Core 3532 * @atomicservice 3533 * @since 12 3534 */ 3535 itemId: number; 3536 3537 /** 3538 * The media description of the item in the playlist. 3539 * @syscap SystemCapability.Multimedia.AVSession.Core 3540 * @since 10 3541 */ 3542 /** 3543 * The media description of the item in the playlist. 3544 * @syscap SystemCapability.Multimedia.AVSession.Core 3545 * @atomicservice 3546 * @since 12 3547 */ 3548 description?: AVMediaDescription; 3549 } 3550 3551 /** 3552 * Used to indicate the playback state of the current media. 3553 * If the playback state of the media changes, it needs to be updated synchronously 3554 * @interface AVPlaybackState 3555 * @syscap SystemCapability.Multimedia.AVSession.Core 3556 * @since 10 3557 */ 3558 /** 3559 * Used to indicate the playback state of the current media. 3560 * If the playback state of the media changes, it needs to be updated synchronously 3561 * @interface AVPlaybackState 3562 * @syscap SystemCapability.Multimedia.AVSession.Core 3563 * @atomicservice 3564 * @since 12 3565 */ 3566 interface AVPlaybackState { 3567 /** 3568 * Current playback state. See {@link PlaybackState} 3569 * @syscap SystemCapability.Multimedia.AVSession.Core 3570 * @since 10 3571 */ 3572 /** 3573 * Current playback state. See {@link PlaybackState} 3574 * @syscap SystemCapability.Multimedia.AVSession.Core 3575 * @atomicservice 3576 * @since 12 3577 */ 3578 state?: PlaybackState; 3579 3580 /** 3581 * Current playback speed 3582 * @type { ?number } 3583 * @syscap SystemCapability.Multimedia.AVSession.Core 3584 * @since 10 3585 */ 3586 /** 3587 * Current playback speed 3588 * @type { ?number } 3589 * @syscap SystemCapability.Multimedia.AVSession.Core 3590 * @atomicservice 3591 * @since 12 3592 */ 3593 speed?: number; 3594 3595 /** 3596 * Current playback position of this media. See {@link PlaybackPosition} 3597 * @syscap SystemCapability.Multimedia.AVSession.Core 3598 * @since 10 3599 */ 3600 /** 3601 * Current playback position of this media. See {@link PlaybackPosition} 3602 * @syscap SystemCapability.Multimedia.AVSession.Core 3603 * @atomicservice 3604 * @since 12 3605 */ 3606 position?: PlaybackPosition; 3607 3608 /** 3609 * The current buffered time, the maximum playable position 3610 * @type { ?number } 3611 * @syscap SystemCapability.Multimedia.AVSession.Core 3612 * @since 10 3613 */ 3614 /** 3615 * The current buffered time, the maximum playable position 3616 * @type { ?number } 3617 * @syscap SystemCapability.Multimedia.AVSession.Core 3618 * @atomicservice 3619 * @since 12 3620 */ 3621 bufferedTime?: number; 3622 3623 /** 3624 * Current playback loop mode. See {@link LoopMode} 3625 * @syscap SystemCapability.Multimedia.AVSession.Core 3626 * @since 10 3627 */ 3628 /** 3629 * Current playback loop mode. See {@link LoopMode} 3630 * @syscap SystemCapability.Multimedia.AVSession.Core 3631 * @atomicservice 3632 * @since 12 3633 */ 3634 loopMode?: LoopMode; 3635 3636 /** 3637 * Current Favorite Status 3638 * @type { ?boolean } 3639 * @syscap SystemCapability.Multimedia.AVSession.Core 3640 * @since 10 3641 */ 3642 /** 3643 * Current Favorite Status 3644 * @type { ?boolean } 3645 * @syscap SystemCapability.Multimedia.AVSession.Core 3646 * @atomicservice 3647 * @since 12 3648 */ 3649 isFavorite?: boolean; 3650 3651 /** 3652 * Current active item id 3653 * @type { ?number } 3654 * @syscap SystemCapability.Multimedia.AVSession.Core 3655 * @since 10 3656 */ 3657 /** 3658 * Current active item id 3659 * @type { ?number } 3660 * @syscap SystemCapability.Multimedia.AVSession.Core 3661 * @atomicservice 3662 * @since 12 3663 */ 3664 activeItemId?: number; 3665 3666 /** 3667 * Current player volume 3668 * @type { ?number } 3669 * @syscap SystemCapability.Multimedia.AVSession.Core 3670 * @since 10 3671 */ 3672 /** 3673 * Current player volume 3674 * @type { ?number } 3675 * @syscap SystemCapability.Multimedia.AVSession.Core 3676 * @atomicservice 3677 * @since 12 3678 */ 3679 volume?: number; 3680 3681 /** 3682 * maximum volume 3683 * @type { ?number } 3684 * @syscap SystemCapability.Multimedia.AVSession.Core 3685 * @since 11 3686 */ 3687 /** 3688 * maximum volume 3689 * @type { ?number } 3690 * @syscap SystemCapability.Multimedia.AVSession.Core 3691 * @atomicservice 3692 * @since 12 3693 */ 3694 maxVolume?: number; 3695 3696 /** 3697 * Current muted status 3698 * @type { ?boolean } 3699 * @syscap SystemCapability.Multimedia.AVSession.Core 3700 * @since 11 3701 */ 3702 /** 3703 * Current muted status 3704 * @type { ?boolean } 3705 * @syscap SystemCapability.Multimedia.AVSession.Core 3706 * @atomicservice 3707 * @since 12 3708 */ 3709 muted?: boolean; 3710 3711 /** 3712 * The duration of this media asset. 3713 * @type { ?number } 3714 * @syscap SystemCapability.Multimedia.AVSession.Core 3715 * @since 11 3716 */ 3717 duration?: number; 3718 3719 /** 3720 * The video width of this media asset. 3721 * @type { ?number } 3722 * @syscap SystemCapability.Multimedia.AVSession.Core 3723 * @since 11 3724 */ 3725 /** 3726 * The video width of this media asset. 3727 * @type { ?number } 3728 * @syscap SystemCapability.Multimedia.AVSession.Core 3729 * @atomicservice 3730 * @since 12 3731 */ 3732 videoWidth?: number; 3733 3734 /** 3735 * The video height of this media asset. 3736 * @type { ?number } 3737 * @syscap SystemCapability.Multimedia.AVSession.Core 3738 * @since 11 3739 */ 3740 /** 3741 * The video height of this media asset. 3742 * @type { ?number } 3743 * @syscap SystemCapability.Multimedia.AVSession.Core 3744 * @atomicservice 3745 * @since 12 3746 */ 3747 videoHeight?: number; 3748 3749 /** 3750 * Current custom media packets 3751 * @syscap SystemCapability.Multimedia.AVSession.Core 3752 * @since 10 3753 */ 3754 /** 3755 * Current custom media packets 3756 * @syscap SystemCapability.Multimedia.AVSession.Core 3757 * @atomicservice 3758 * @since 12 3759 */ 3760 extras?: {[key: string]: Object}; 3761 } 3762 3763 /** 3764 * Playback position definition 3765 * @interface PlaybackPosition 3766 * @syscap SystemCapability.Multimedia.AVSession.Core 3767 * @since 10 3768 */ 3769 /** 3770 * Playback position definition 3771 * @interface PlaybackPosition 3772 * @syscap SystemCapability.Multimedia.AVSession.Core 3773 * @atomicservice 3774 * @since 12 3775 */ 3776 interface PlaybackPosition { 3777 /** 3778 * Elapsed time(position) of this media set by the app. 3779 * @type { number } 3780 * @syscap SystemCapability.Multimedia.AVSession.Core 3781 * @since 10 3782 */ 3783 /** 3784 * Elapsed time(position) of this media set by the app. 3785 * @type { number } 3786 * @syscap SystemCapability.Multimedia.AVSession.Core 3787 * @atomicservice 3788 * @since 12 3789 */ 3790 elapsedTime: number; 3791 3792 /** 3793 * Record the system time when elapsedTime is set. 3794 * @type { number } 3795 * @syscap SystemCapability.Multimedia.AVSession.Core 3796 * @since 10 3797 */ 3798 /** 3799 * Record the system time when elapsedTime is set. 3800 * @type { number } 3801 * @syscap SystemCapability.Multimedia.AVSession.Core 3802 * @atomicservice 3803 * @since 12 3804 */ 3805 updateTime: number; 3806 } 3807 3808 /** 3809 * The metadata of the current call. 3810 * @interface CallMetadata 3811 * @syscap SystemCapability.Multimedia.AVSession.Core 3812 * @since 11 3813 */ 3814 interface CallMetadata { 3815 /** 3816 * The displayed user name of current call. 3817 * @type { ?string } 3818 * @syscap SystemCapability.Multimedia.AVSession.Core 3819 * @since 11 3820 */ 3821 name?: string; 3822 3823 /** 3824 * The phone number of current call. 3825 * @type { ?string } 3826 * @syscap SystemCapability.Multimedia.AVSession.Core 3827 * @since 11 3828 */ 3829 phoneNumber?: string; 3830 3831 /** 3832 * The displayed picture that represents a particular user. 3833 * @type { ?image.PixelMap } 3834 * @syscap SystemCapability.Multimedia.AVSession.Core 3835 * @since 11 3836 */ 3837 avatar?: image.PixelMap; 3838 } 3839 3840 /** 3841 * Used to indicate the call state of the current call. 3842 * @interface AVCallState 3843 * @syscap SystemCapability.Multimedia.AVSession.Core 3844 * @since 11 3845 */ 3846 interface AVCallState { 3847 /** 3848 * Current call state. See {@link CallState} 3849 * @type {CallState} 3850 * @syscap SystemCapability.Multimedia.AVSession.Core 3851 * @since 11 3852 */ 3853 state: CallState; 3854 3855 /** 3856 * Current muted status. 3857 * @type { boolean } 3858 * @syscap SystemCapability.Multimedia.AVSession.Core 3859 * @since 11 3860 */ 3861 muted: boolean; 3862 } 3863 3864 /** 3865 * Enumeration of current call state 3866 * @enum { number } 3867 * @syscap SystemCapability.Multimedia.AVSession.Core 3868 * @since 11 3869 */ 3870 enum CallState { 3871 /** 3872 * Idle state. 3873 * @syscap SystemCapability.Multimedia.AVSession.Core 3874 * @since 11 3875 */ 3876 CALL_STATE_IDLE = 0, 3877 3878 /** 3879 * Incoming state. 3880 * @syscap SystemCapability.Multimedia.AVSession.Core 3881 * @since 11 3882 */ 3883 CALL_STATE_INCOMING = 1, 3884 3885 /** 3886 * Active state in calling. 3887 * @syscap SystemCapability.Multimedia.AVSession.Core 3888 * @since 11 3889 */ 3890 CALL_STATE_ACTIVE = 2, 3891 3892 /** 3893 * Dialing state. 3894 * @syscap SystemCapability.Multimedia.AVSession.Core 3895 * @since 11 3896 */ 3897 CALL_STATE_DIALING = 3, 3898 3899 /** 3900 * Waiting state. 3901 * @syscap SystemCapability.Multimedia.AVSession.Core 3902 * @since 11 3903 */ 3904 CALL_STATE_WAITING = 4, 3905 3906 /** 3907 * Holding state. 3908 * @syscap SystemCapability.Multimedia.AVSession.Core 3909 * @since 11 3910 */ 3911 CALL_STATE_HOLDING = 5, 3912 3913 /** 3914 * Disconnecting state. 3915 * @syscap SystemCapability.Multimedia.AVSession.Core 3916 * @since 11 3917 */ 3918 CALL_STATE_DISCONNECTING = 6, 3919 } 3920 3921 /** 3922 * cast category indicating different playback scenes 3923 * @enum { number } 3924 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3925 * @since 10 3926 */ 3927 /** 3928 * cast category indicating different playback scenes 3929 * @enum { number } 3930 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3931 * @atomicservice 3932 * @since 12 3933 */ 3934 enum AVCastCategory { 3935 /** 3936 * The default cast type "local", media can be routed on the same device, 3937 * including internal speakers or audio jack on the device itself, A2DP devices. 3938 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3939 * @since 10 3940 */ 3941 /** 3942 * The default cast type "local", media can be routed on the same device, 3943 * including internal speakers or audio jack on the device itself, A2DP devices. 3944 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3945 * @atomicservice 3946 * @since 12 3947 */ 3948 CATEGORY_LOCAL = 0, 3949 3950 /** 3951 * The remote category indicating the media is presenting on a remote device, 3952 * the application needs to get an AVCastController to control remote playback. 3953 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3954 * @since 10 3955 */ 3956 /** 3957 * The remote category indicating the media is presenting on a remote device, 3958 * the application needs to get an AVCastController to control remote playback. 3959 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3960 * @atomicservice 3961 * @since 12 3962 */ 3963 CATEGORY_REMOTE = 1, 3964 } 3965 /** 3966 * Device type definition 3967 * @enum { number } 3968 * @syscap SystemCapability.Multimedia.AVSession.Core 3969 * @since 10 3970 */ 3971 /** 3972 * Device type definition 3973 * @enum { number } 3974 * @syscap SystemCapability.Multimedia.AVSession.Core 3975 * @atomicservice 3976 * @since 12 3977 */ 3978 enum DeviceType { 3979 /** 3980 * A device type indicating the route is on internal speakers or audio jack on the device itself. 3981 * @syscap SystemCapability.Multimedia.AVSession.Core 3982 * @since 10 3983 */ 3984 /** 3985 * A device type indicating the route is on internal speakers or audio jack on the device itself. 3986 * @syscap SystemCapability.Multimedia.AVSession.Core 3987 * @atomicservice 3988 * @since 12 3989 */ 3990 DEVICE_TYPE_LOCAL = 0, 3991 3992 /** 3993 * A device type indicating the route is on a TV. 3994 * @syscap SystemCapability.Multimedia.AVSession.AVCast 3995 * @since 10 3996 */ 3997 /** 3998 * A device type indicating the route is on a TV. 3999 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4000 * @atomicservice 4001 * @since 12 4002 */ 4003 DEVICE_TYPE_TV = 2, 4004 4005 /** 4006 * A device type indicating the route is on a smart speaker. 4007 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4008 * @since 10 4009 */ 4010 /** 4011 * A device type indicating the route is on a smart speaker. 4012 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4013 * @atomicservice 4014 * @since 12 4015 */ 4016 DEVICE_TYPE_SMART_SPEAKER = 3, 4017 4018 /** 4019 * A device type indicating the route is on a bluetooth device. 4020 * @syscap SystemCapability.Multimedia.AVSession.Core 4021 * @since 10 4022 */ 4023 /** 4024 * A device type indicating the route is on a bluetooth device. 4025 * @syscap SystemCapability.Multimedia.AVSession.Core 4026 * @atomicservice 4027 * @since 12 4028 */ 4029 DEVICE_TYPE_BLUETOOTH = 10, 4030 } 4031 4032 /** 4033 * Device Information Definition 4034 * @interface DeviceInfo 4035 * @syscap SystemCapability.Multimedia.AVSession.Core 4036 * @since 10 4037 */ 4038 /** 4039 * Device Information Definition 4040 * @interface DeviceInfo 4041 * @syscap SystemCapability.Multimedia.AVSession.Core 4042 * @atomicservice 4043 * @since 12 4044 */ 4045 interface DeviceInfo { 4046 /** 4047 * The playback type supported by the device. See {@link AVCastCategory} 4048 * @syscap SystemCapability.Multimedia.AVSession.Core 4049 * @since 10 4050 */ 4051 /** 4052 * The playback type supported by the device. See {@link AVCastCategory} 4053 * @syscap SystemCapability.Multimedia.AVSession.Core 4054 * @atomicservice 4055 * @since 12 4056 */ 4057 castCategory: AVCastCategory; 4058 /** 4059 * Audio device id.The length of the audioDeviceId array is greater than 1 4060 * if output to multiple devices at the same time. 4061 * @syscap SystemCapability.Multimedia.AVSession.Core 4062 * @since 10 4063 */ 4064 /** 4065 * Audio device id.The length of the audioDeviceId array is greater than 1 4066 * if output to multiple devices at the same time. 4067 * @syscap SystemCapability.Multimedia.AVSession.Core 4068 * @atomicservice 4069 * @since 12 4070 */ 4071 deviceId: string; 4072 4073 /** 4074 * Device name. The length of the deviceName array is greater than 1 4075 * if output to multiple devices at the same time. 4076 * @syscap SystemCapability.Multimedia.AVSession.Core 4077 * @since 10 4078 */ 4079 /** 4080 * Device name. The length of the deviceName array is greater than 1 4081 * if output to multiple devices at the same time. 4082 * @syscap SystemCapability.Multimedia.AVSession.Core 4083 * @atomicservice 4084 * @since 12 4085 */ 4086 deviceName: string; 4087 4088 /** 4089 * device type. 4090 * @syscap SystemCapability.Multimedia.AVSession.Core 4091 * @since 10 4092 */ 4093 /** 4094 * device type. 4095 * @syscap SystemCapability.Multimedia.AVSession.Core 4096 * @atomicservice 4097 * @since 12 4098 */ 4099 deviceType: DeviceType; 4100 4101 /** 4102 * device ip address if available. 4103 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4104 * @systemapi 4105 * @since 10 4106 */ 4107 ipAddress?: string; 4108 4109 /** 4110 * device provider which supplies the route capability. 4111 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4112 * @systemapi 4113 * @since 10 4114 */ 4115 providerId?: number; 4116 4117 /** 4118 * The protocols supported by current device, can be union of {@link ProtocolType}. 4119 * @type { ?number } 4120 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4121 * @since 11 4122 */ 4123 /** 4124 * The protocols supported by current device, can be union of {@link ProtocolType}. 4125 * @type { ?number } 4126 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4127 * @atomicservice 4128 * @since 12 4129 */ 4130 supportedProtocols?: number; 4131 4132 /** 4133 * The drm capability supported by current device, each drm is represented by uuid. 4134 * @type { ?Array<string> } 4135 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4136 * @atomicservice 4137 * @since 12 4138 */ 4139 supportedDrmCapabilities?: Array<string>; 4140 4141 /** 4142 * Define different authentication status. 4143 * 0: Device not authenticated. 4144 * 1: Device already authenticated. 4145 * @type { ?number } 4146 * @syscap SystemCapability.Multimedia.AVSession.AVCast 4147 * @systemapi 4148 * @since 11 4149 */ 4150 authenticationStatus?: number; 4151 } 4152 4153 /** 4154 * Target Device Information Definition 4155 * @interface OutputDeviceInfo 4156 * @syscap SystemCapability.Multimedia.AVSession.Core 4157 * @since 10 4158 */ 4159 /** 4160 * Target Device Information Definition 4161 * @interface OutputDeviceInfo 4162 * @syscap SystemCapability.Multimedia.AVSession.Core 4163 * @atomicservice 4164 * @since 12 4165 */ 4166 interface OutputDeviceInfo { 4167 /** 4168 * Arrays of device information 4169 * @syscap SystemCapability.Multimedia.AVSession.Core 4170 * @since 10 4171 */ 4172 /** 4173 * Arrays of device information 4174 * @syscap SystemCapability.Multimedia.AVSession.Core 4175 * @atomicservice 4176 * @since 12 4177 */ 4178 devices: Array<DeviceInfo>; 4179 } 4180 4181 /** 4182 * Loop Play Mode Definition 4183 * @enum { number } 4184 * @syscap SystemCapability.Multimedia.AVSession.Core 4185 * @since 10 4186 */ 4187 /** 4188 * Loop Play Mode Definition 4189 * @enum { number } 4190 * @syscap SystemCapability.Multimedia.AVSession.Core 4191 * @atomicservice 4192 * @since 12 4193 */ 4194 enum LoopMode { 4195 /** 4196 * The default mode is sequential playback 4197 * @syscap SystemCapability.Multimedia.AVSession.Core 4198 * @since 10 4199 */ 4200 /** 4201 * The default mode is sequential playback 4202 * @syscap SystemCapability.Multimedia.AVSession.Core 4203 * @atomicservice 4204 * @since 12 4205 */ 4206 LOOP_MODE_SEQUENCE = 0, 4207 4208 /** 4209 * Single loop mode 4210 * @syscap SystemCapability.Multimedia.AVSession.Core 4211 * @since 10 4212 */ 4213 /** 4214 * Single loop mode 4215 * @syscap SystemCapability.Multimedia.AVSession.Core 4216 * @atomicservice 4217 * @since 12 4218 */ 4219 LOOP_MODE_SINGLE = 1, 4220 4221 /** 4222 * List loop mode 4223 * @syscap SystemCapability.Multimedia.AVSession.Core 4224 * @since 10 4225 */ 4226 /** 4227 * List loop mode 4228 * @syscap SystemCapability.Multimedia.AVSession.Core 4229 * @atomicservice 4230 * @since 12 4231 */ 4232 LOOP_MODE_LIST = 2, 4233 4234 /** 4235 * Shuffle playback mode 4236 * @syscap SystemCapability.Multimedia.AVSession.Core 4237 * @since 10 4238 */ 4239 /** 4240 * Shuffle playback mode 4241 * @syscap SystemCapability.Multimedia.AVSession.Core 4242 * @atomicservice 4243 * @since 12 4244 */ 4245 LOOP_MODE_SHUFFLE = 3, 4246 4247 /** 4248 * Custom playback mode supported by application 4249 * @syscap SystemCapability.Multimedia.AVSession.Core 4250 * @since 11 4251 */ 4252 /** 4253 * Custom playback mode supported by application 4254 * @syscap SystemCapability.Multimedia.AVSession.Core 4255 * @atomicservice 4256 * @since 12 4257 */ 4258 LOOP_MODE_CUSTOM = 4, 4259 } 4260 4261 /** 4262 * Supported skip intervals definition 4263 * @enum { number } 4264 * @syscap SystemCapability.Multimedia.AVSession.Core 4265 * @since 11 4266 */ 4267 enum SkipIntervals { 4268 /** 4269 * 10 seconds 4270 * @syscap SystemCapability.Multimedia.AVSession.Core 4271 * @since 11 4272 */ 4273 SECONDS_10 = 10, 4274 /** 4275 * 15 seconds 4276 * @syscap SystemCapability.Multimedia.AVSession.Core 4277 * @since 11 4278 */ 4279 SECONDS_15 = 15, 4280 /** 4281 * 30 seconds 4282 * @syscap SystemCapability.Multimedia.AVSession.Core 4283 * @since 11 4284 */ 4285 SECONDS_30 = 30, 4286 } 4287 4288 /** 4289 * Definition of current playback state 4290 * @enum { number } 4291 * @syscap SystemCapability.Multimedia.AVSession.Core 4292 * @since 10 4293 */ 4294 /** 4295 * Definition of current playback state 4296 * @enum { number } 4297 * @syscap SystemCapability.Multimedia.AVSession.Core 4298 * @atomicservice 4299 * @since 12 4300 */ 4301 enum PlaybackState { 4302 /** 4303 * Initial state. The initial state of media file 4304 * @syscap SystemCapability.Multimedia.AVSession.Core 4305 * @since 10 4306 */ 4307 /** 4308 * Initial state. The initial state of media file 4309 * @syscap SystemCapability.Multimedia.AVSession.Core 4310 * @atomicservice 4311 * @since 12 4312 */ 4313 PLAYBACK_STATE_INITIAL = 0, 4314 4315 /** 4316 * Preparing state. Indicates that the media file is not ready to play, 4317 * the media is loading or buffering 4318 * @syscap SystemCapability.Multimedia.AVSession.Core 4319 * @since 10 4320 */ 4321 /** 4322 * Preparing state. Indicates that the media file is not ready to play, 4323 * the media is loading or buffering 4324 * @syscap SystemCapability.Multimedia.AVSession.Core 4325 * @atomicservice 4326 * @since 12 4327 */ 4328 PLAYBACK_STATE_PREPARE = 1, 4329 4330 /** 4331 * Playing state. 4332 * @syscap SystemCapability.Multimedia.AVSession.Core 4333 * @since 10 4334 */ 4335 /** 4336 * Playing state. 4337 * @syscap SystemCapability.Multimedia.AVSession.Core 4338 * @atomicservice 4339 * @since 12 4340 */ 4341 PLAYBACK_STATE_PLAY = 2, 4342 4343 /** 4344 * Paused state. 4345 * @syscap SystemCapability.Multimedia.AVSession.Core 4346 * @since 10 4347 */ 4348 /** 4349 * Paused state. 4350 * @syscap SystemCapability.Multimedia.AVSession.Core 4351 * @atomicservice 4352 * @since 12 4353 */ 4354 PLAYBACK_STATE_PAUSE = 3, 4355 4356 /** 4357 * Fast forwarding state. 4358 * @syscap SystemCapability.Multimedia.AVSession.Core 4359 * @since 10 4360 */ 4361 /** 4362 * Fast forwarding state. 4363 * @syscap SystemCapability.Multimedia.AVSession.Core 4364 * @atomicservice 4365 * @since 12 4366 */ 4367 PLAYBACK_STATE_FAST_FORWARD = 4, 4368 4369 /** 4370 * Rewinding state. 4371 * @syscap SystemCapability.Multimedia.AVSession.Core 4372 * @since 10 4373 */ 4374 /** 4375 * Rewinding state. 4376 * @syscap SystemCapability.Multimedia.AVSession.Core 4377 * @atomicservice 4378 * @since 12 4379 */ 4380 PLAYBACK_STATE_REWIND = 5, 4381 4382 /** 4383 * Stopped state.The server will clear the media playback position and other information. 4384 * @syscap SystemCapability.Multimedia.AVSession.Core 4385 * @since 10 4386 */ 4387 /** 4388 * Stopped state.The server will clear the media playback position and other information. 4389 * @syscap SystemCapability.Multimedia.AVSession.Core 4390 * @atomicservice 4391 * @since 12 4392 */ 4393 PLAYBACK_STATE_STOP = 6, 4394 4395 /** 4396 * Completed state. 4397 * @syscap SystemCapability.Multimedia.AVSession.Core 4398 * @since 10 4399 */ 4400 /** 4401 * Completed state. 4402 * @syscap SystemCapability.Multimedia.AVSession.Core 4403 * @atomicservice 4404 * @since 12 4405 */ 4406 PLAYBACK_STATE_COMPLETED = 7, 4407 4408 /** 4409 * Released state. 4410 * @syscap SystemCapability.Multimedia.AVSession.Core 4411 * @since 10 4412 */ 4413 /** 4414 * Released state. 4415 * @syscap SystemCapability.Multimedia.AVSession.Core 4416 * @atomicservice 4417 * @since 12 4418 */ 4419 PLAYBACK_STATE_RELEASED = 8, 4420 4421 /** 4422 * error state. 4423 * @syscap SystemCapability.Multimedia.AVSession.Core 4424 * @since 10 4425 */ 4426 /** 4427 * error state. 4428 * @syscap SystemCapability.Multimedia.AVSession.Core 4429 * @atomicservice 4430 * @since 12 4431 */ 4432 PLAYBACK_STATE_ERROR = 9, 4433 4434 /** 4435 * Idle state. 4436 * @syscap SystemCapability.Multimedia.AVSession.Core 4437 * @since 11 4438 */ 4439 /** 4440 * Idle state. 4441 * @syscap SystemCapability.Multimedia.AVSession.Core 4442 * @atomicservice 4443 * @since 12 4444 */ 4445 PLAYBACK_STATE_IDLE = 10, 4446 4447 /** 4448 * Buffering state. 4449 * @syscap SystemCapability.Multimedia.AVSession.Core 4450 * @since 11 4451 */ 4452 /** 4453 * Buffering state. 4454 * @syscap SystemCapability.Multimedia.AVSession.Core 4455 * @atomicservice 4456 * @since 12 4457 */ 4458 PLAYBACK_STATE_BUFFERING = 11, 4459 } 4460 4461 /** 4462 * The description of the session 4463 * @interface AVSessionDescriptor 4464 * @syscap SystemCapability.Multimedia.AVSession.Manager 4465 * @systemapi 4466 * @since 9 4467 */ 4468 interface AVSessionDescriptor { 4469 /** 4470 * Unique ID of the session 4471 * @type { string } 4472 * @syscap SystemCapability.Multimedia.AVSession.Manager 4473 * @systemapi 4474 * @since 9 4475 */ 4476 sessionId: string; 4477 4478 /** 4479 * Session type, currently supports audio or video 4480 * @syscap SystemCapability.Multimedia.AVSession.Manager 4481 * @systemapi 4482 * @since 9 4483 */ 4484 type: AVSessionType; 4485 4486 /** 4487 * The session tag set by the application 4488 * @type { string } 4489 * @syscap SystemCapability.Multimedia.AVSession.Manager 4490 * @systemapi 4491 * @since 9 4492 */ 4493 sessionTag: string; 4494 4495 /** 4496 * The elementName of the ability that created this session. See {@link ElementName} in bundle/elementName.d.ts 4497 * @syscap SystemCapability.Multimedia.AVSession.Manager 4498 * @systemapi 4499 * @since 9 4500 */ 4501 elementName: ElementName; 4502 4503 /** 4504 * Session active state 4505 * @type { boolean } 4506 * @syscap SystemCapability.Multimedia.AVSession.Manager 4507 * @systemapi 4508 * @since 9 4509 */ 4510 isActive: boolean; 4511 4512 /** 4513 * Is it the top priority session 4514 * @type { boolean } 4515 * @syscap SystemCapability.Multimedia.AVSession.Manager 4516 * @systemapi 4517 * @since 9 4518 */ 4519 isTopSession: boolean; 4520 4521 /** 4522 * The current output device information. 4523 * It will be undefined if this is a local session. 4524 * @syscap SystemCapability.Multimedia.AVSession.Manager 4525 * @systemapi 4526 * @since 9 4527 */ 4528 outputDevice: OutputDeviceInfo; 4529 } 4530 4531 /** 4532 * Session controller,used to control media playback and get media information 4533 * @interface AVSessionController 4534 * @syscap SystemCapability.Multimedia.AVSession.Core 4535 * @since 10 4536 */ 4537 interface AVSessionController { 4538 /** 4539 * Unique session Id 4540 * @syscap SystemCapability.Multimedia.AVSession.Core 4541 * @since 10 4542 */ 4543 readonly sessionId: string; 4544 4545 /** 4546 * Get the playback status of the current session 4547 * @param { AsyncCallback<AVPlaybackState> } callback - The triggered asyncCallback when (getAVPlaybackState). 4548 * @throws { BusinessError } 6600101 - Session service exception. 4549 * @throws { BusinessError } 6600102 - The session does not exist. 4550 * @throws { BusinessError } 6600103 - The session controller does not exist. 4551 * @syscap SystemCapability.Multimedia.AVSession.Core 4552 * @since 10 4553 */ 4554 getAVPlaybackState(callback: AsyncCallback<AVPlaybackState>): void; 4555 4556 /** 4557 * Get the playback status of the current session 4558 * @returns { Promise<AVPlaybackState> } (AVPlaybackState) returned through promise 4559 * @throws { BusinessError } 6600101 - Session service exception. 4560 * @throws { BusinessError } 6600102 - The session does not exist. 4561 * @throws { BusinessError } 6600103 - The session controller does not exist. 4562 * @syscap SystemCapability.Multimedia.AVSession.Core 4563 * @since 10 4564 */ 4565 getAVPlaybackState(): Promise<AVPlaybackState>; 4566 4567 /** 4568 * Get the playback status of the current session 4569 * @returns { AVPlaybackState } (AVPlaybackState) returned 4570 * @throws { BusinessError } 6600101 - Session service exception. 4571 * @throws { BusinessError } 6600102 - The session does not exist. 4572 * @throws { BusinessError } 6600103 - The session controller does not exist. 4573 * @syscap SystemCapability.Multimedia.AVSession.Core 4574 * @since 10 4575 */ 4576 getAVPlaybackStateSync(): AVPlaybackState; 4577 4578 /** 4579 * Get the metadata of the current session 4580 * @param { AsyncCallback<AVMetadata> } callback - The triggered asyncCallback when (getAVMetadata). 4581 * @throws { BusinessError } 6600101 - Session service exception. 4582 * @throws { BusinessError } 6600102 - The session does not exist. 4583 * @throws { BusinessError } 6600103 - The session controller does not exist. 4584 * @syscap SystemCapability.Multimedia.AVSession.Core 4585 * @since 10 4586 */ 4587 getAVMetadata(callback: AsyncCallback<AVMetadata>): void; 4588 4589 /** 4590 * Get the metadata of the current session 4591 * @returns { Promise<AVMetadata> } (AVMetadata) returned through promise 4592 * @throws { BusinessError } 6600101 - Session service exception. 4593 * @throws { BusinessError } 6600102 - The session does not exist. 4594 * @throws { BusinessError } 6600103 - The session controller does not exist. 4595 * @syscap SystemCapability.Multimedia.AVSession.Core 4596 * @since 10 4597 */ 4598 getAVMetadata(): Promise<AVMetadata>; 4599 4600 /** 4601 * Get the metadata of the current session 4602 * @returns { AVMetadata } (AVMetadata) returned 4603 * @throws { BusinessError } 6600101 - Session service exception. 4604 * @throws { BusinessError } 6600102 - The session does not exist. 4605 * @throws { BusinessError } 6600103 - The session controller does not exist. 4606 * @syscap SystemCapability.Multimedia.AVSession.Core 4607 * @since 10 4608 */ 4609 getAVMetadataSync(): AVMetadata; 4610 4611 /** 4612 * Get the call status of the current session 4613 * @param { AsyncCallback<AVCallState> } callback - The triggered asyncCallback when (getAVCallState). 4614 * @throws { BusinessError } 6600101 - Session service exception. 4615 * @throws { BusinessError } 6600102 - The session does not exist. 4616 * @throws { BusinessError } 6600103 - The session controller does not exist. 4617 * @syscap SystemCapability.Multimedia.AVSession.Core 4618 * @since 11 4619 */ 4620 getAVCallState(callback: AsyncCallback<AVCallState>): void; 4621 4622 /** 4623 * Get the call status of the current session 4624 * @returns { Promise<AVCallState> } (AVCallState) returned through promise 4625 * @throws { BusinessError } 6600101 - Session service exception. 4626 * @throws { BusinessError } 6600102 - The session does not exist. 4627 * @throws { BusinessError } 6600103 - The session controller does not exist. 4628 * @syscap SystemCapability.Multimedia.AVSession.Core 4629 * @since 11 4630 */ 4631 getAVCallState(): Promise<AVCallState>; 4632 4633 /** 4634 * Get the call metadata of the current session 4635 * @param { AsyncCallback<CallMetadata> } callback - The triggered asyncCallback when (getCallMetadata). 4636 * @throws { BusinessError } 6600101 - Session service exception. 4637 * @throws { BusinessError } 6600102 - The session does not exist. 4638 * @throws { BusinessError } 6600103 - The session controller does not exist. 4639 * @syscap SystemCapability.Multimedia.AVSession.Core 4640 * @since 11 4641 */ 4642 getCallMetadata(callback: AsyncCallback<CallMetadata>): void; 4643 4644 /** 4645 * Get the call metadata of the current session 4646 * @returns { Promise<CallMetadata> } (CallMetadata) returned through promise 4647 * @throws { BusinessError } 6600101 - Session service exception. 4648 * @throws { BusinessError } 6600102 - The session does not exist. 4649 * @throws { BusinessError } 6600103 - The session controller does not exist. 4650 * @syscap SystemCapability.Multimedia.AVSession.Core 4651 * @since 11 4652 */ 4653 getCallMetadata(): Promise<CallMetadata>; 4654 4655 /** 4656 * Get the name of the playlist of the current session 4657 * @param { AsyncCallback<string> } callback - The triggered asyncCallback when (getAVQueueTitle). 4658 * @throws { BusinessError } 6600101 - Session service exception. 4659 * @throws { BusinessError } 6600102 - The session does not exist. 4660 * @throws { BusinessError } 6600103 - The session controller does not exist. 4661 * @syscap SystemCapability.Multimedia.AVSession.Core 4662 * @since 10 4663 */ 4664 getAVQueueTitle(callback: AsyncCallback<string>): void; 4665 4666 /** 4667 * Get the name of the playlist of the current session 4668 * @returns { Promise<string> } (string) returned through promise 4669 * @throws { BusinessError } 6600101 - Session service exception. 4670 * @throws { BusinessError } 6600102 - The session does not exist. 4671 * @throws { BusinessError } 6600103 - The session controller does not exist. 4672 * @syscap SystemCapability.Multimedia.AVSession.Core 4673 * @since 10 4674 */ 4675 getAVQueueTitle(): Promise<string>; 4676 4677 /** 4678 * Get the name of the playlist of the current session 4679 * @returns { string } (string) returned 4680 * @throws { BusinessError } 6600101 - Session service exception. 4681 * @throws { BusinessError } 6600102 - The session does not exist. 4682 * @throws { BusinessError } 6600103 - The session controller does not exist. 4683 * @syscap SystemCapability.Multimedia.AVSession.Core 4684 * @since 10 4685 */ 4686 getAVQueueTitleSync(): string; 4687 4688 /** 4689 * Get the playlist of the current session 4690 * @param { AsyncCallback<Array<AVQueueItem>> } callback - The triggered asyncCallback when (getAVQueueItems). 4691 * @throws { BusinessError } 6600101 - Session service exception. 4692 * @throws { BusinessError } 6600102 - The session does not exist. 4693 * @throws { BusinessError } 6600103 - The session controller does not exist. 4694 * @syscap SystemCapability.Multimedia.AVSession.Core 4695 * @since 10 4696 */ 4697 getAVQueueItems(callback: AsyncCallback<Array<AVQueueItem>>): void; 4698 4699 /** 4700 * Get the playlist of the current session 4701 * @returns { Promise<Array<AVQueueItem>> } (Array<AVQueueItem>) returned through promise 4702 * @throws { BusinessError } 6600101 - Session service exception. 4703 * @throws { BusinessError } 6600102 - The session does not exist. 4704 * @throws { BusinessError } 6600103 - The session controller does not exist. 4705 * @syscap SystemCapability.Multimedia.AVSession.Core 4706 * @since 10 4707 */ 4708 getAVQueueItems(): Promise<Array<AVQueueItem>>; 4709 4710 /** 4711 * Get the playlist of the current session 4712 * @returns { Array<AVQueueItem> } (Array<AVQueueItem>) returned 4713 * @throws { BusinessError } 6600101 - Session service exception. 4714 * @throws { BusinessError } 6600102 - The session does not exist. 4715 * @throws { BusinessError } 6600103 - The session controller does not exist. 4716 * @syscap SystemCapability.Multimedia.AVSession.Core 4717 * @since 10 4718 */ 4719 getAVQueueItemsSync(): Array<AVQueueItem>; 4720 4721 /** 4722 * Set the item in the playlist to be played 4723 * @param { number } itemId - The serial number of the item to be played 4724 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully 4725 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4726 * 2.Parameter verification failed. 4727 * @throws { BusinessError } 6600101 - Session service exception. 4728 * @throws { BusinessError } 6600102 - The session does not exist. 4729 * @throws { BusinessError } 6600103 - The session controller does not exist. 4730 * @syscap SystemCapability.Multimedia.AVSession.Core 4731 * @since 10 4732 */ 4733 skipToQueueItem(itemId: number, callback: AsyncCallback<void>): void; 4734 4735 /** 4736 * Set the item in the playlist to be played 4737 * @param { number } itemId - The serial number of the item to be played 4738 * @returns { Promise<void> } void promise when executed successfully 4739 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4740 * 2.Parameter verification failed. 4741 * @throws { BusinessError } 6600101 - Session service exception. 4742 * @throws { BusinessError } 6600102 - The session does not exist. 4743 * @throws { BusinessError } 6600103 - The session controller does not exist. 4744 * @syscap SystemCapability.Multimedia.AVSession.Core 4745 * @since 10 4746 */ 4747 skipToQueueItem(itemId: number): Promise<void>; 4748 4749 /** 4750 * Get output device information 4751 * @param { AsyncCallback<OutputDeviceInfo> } callback - The triggered asyncCallback when (getOutputDevice). 4752 * @throws { BusinessError } 600101 - Session service exception. 4753 * @throws { BusinessError } 600103 - The session controller does not exist. 4754 * @syscap SystemCapability.Multimedia.AVSession.Core 4755 * @since 10 4756 */ 4757 getOutputDevice(callback: AsyncCallback<OutputDeviceInfo>): void; 4758 4759 /** 4760 * Get output device information 4761 * @returns { Promise<OutputDeviceInfo> } (OutputDeviceInfo) returned through promise 4762 * @throws { BusinessError } 600101 - Session service exception. 4763 * @throws { BusinessError } 600103 - The session controller does not exist. 4764 * @syscap SystemCapability.Multimedia.AVSession.Core 4765 * @since 10 4766 */ 4767 getOutputDevice(): Promise<OutputDeviceInfo>; 4768 4769 /** 4770 * Get output device information 4771 * @returns { OutputDeviceInfo } (OutputDeviceInfo) returned 4772 * @throws { BusinessError } 6600101 - Session service exception. 4773 * @throws { BusinessError } 6600103 - The session controller does not exist. 4774 * @syscap SystemCapability.Multimedia.AVSession.Core 4775 * @since 10 4776 */ 4777 getOutputDeviceSync(): OutputDeviceInfo; 4778 4779 /** 4780 * Send media key event to this session 4781 * @param { KeyEvent } event - The KeyEvent 4782 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 4783 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4784 * 2.Parameter verification failed. 4785 * @throws { BusinessError } 600101 - Session service exception. 4786 * @throws { BusinessError } 600102 - The session does not exist. 4787 * @throws { BusinessError } 600103 - The session controller does not exist. 4788 * @throws { BusinessError } 600105 - Invalid session command. 4789 * @throws { BusinessError } 600106 - The session is not activated. 4790 * @syscap SystemCapability.Multimedia.AVSession.Core 4791 * @since 10 4792 */ 4793 sendAVKeyEvent(event: KeyEvent, callback: AsyncCallback<void>): void; 4794 4795 /** 4796 * Send media key event to this session 4797 * @param { KeyEvent } event - The KeyEvent 4798 * @returns { Promise<void> } void promise when executed successfully 4799 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4800 * 2.Parameter verification failed. 4801 * @throws { BusinessError } 600101 - Session service exception. 4802 * @throws { BusinessError } 600102 - The session does not exist. 4803 * @throws { BusinessError } 600103 - The session controller does not exist. 4804 * @throws { BusinessError } 600105 - Invalid session command. 4805 * @throws { BusinessError } 600106 - The session is not activated. 4806 * @syscap SystemCapability.Multimedia.AVSession.Core 4807 * @since 10 4808 */ 4809 sendAVKeyEvent(event: KeyEvent): Promise<void>; 4810 4811 /** 4812 * Get the {@link WantAgent} of this session that can launch the session ability 4813 * @param { AsyncCallback<WantAgent> } callback - The asyncCallback triggered when getting the WantAgent. 4814 * @throws { BusinessError } 6600101 - Session service exception. 4815 * @throws { BusinessError } 6600102 - The session does not exist. 4816 * @throws { BusinessError } 6600103 - The session controller does not exist. 4817 * @syscap SystemCapability.Multimedia.AVSession.Core 4818 * @since 10 4819 */ 4820 getLaunchAbility(callback: AsyncCallback<WantAgent>): void; 4821 4822 /** 4823 * Get the {@link WantAgent} of this session that can launch the session ability 4824 * @returns { Promise<WantAgent> } WantAgent promise 4825 * @throws { BusinessError } 6600101 - Session service exception. 4826 * @throws { BusinessError } 6600102 - The session does not exist. 4827 * @throws { BusinessError } 6600103 - The session controller does not exist. 4828 * @syscap SystemCapability.Multimedia.AVSession.Core 4829 * @since 10 4830 */ 4831 getLaunchAbility(): Promise<WantAgent>; 4832 4833 /** 4834 * Get the adjusted playback position. The time automatically calculated by the system 4835 * taking into account factors such as playback status, playback speed, and application update time. 4836 * @returns { number } current playback position in ms.Note that the returns value of each call will be different. 4837 * @throws { BusinessError } 6600101 - Session service exception. 4838 * @throws { BusinessError } 6600103 - The session controller does not exist. 4839 * @syscap SystemCapability.Multimedia.AVSession.Core 4840 * @since 10 4841 */ 4842 getRealPlaybackPositionSync(): number; 4843 4844 /** 4845 * Check if the current session is active 4846 * @param { AsyncCallback<boolean> } callback - The triggered asyncCallback when (isActive). 4847 * @throws { BusinessError } 6600101 - Session service exception. 4848 * @throws { BusinessError } 6600102 - The session does not exist. 4849 * @throws { BusinessError } 6600103 - The session controller does not exist. 4850 * @syscap SystemCapability.Multimedia.AVSession.Core 4851 * @since 10 4852 */ 4853 isActive(callback: AsyncCallback<boolean>): void; 4854 4855 /** 4856 * Check if the current session is active 4857 * @returns { Promise<boolean> } boolean promise 4858 * @throws { BusinessError } 6600101 - Session service exception. 4859 * @throws { BusinessError } 6600102 - The session does not exist. 4860 * @throws { BusinessError } 6600103 - The session controller does not exist. 4861 * @syscap SystemCapability.Multimedia.AVSession.Core 4862 * @since 10 4863 */ 4864 isActive(): Promise<boolean>; 4865 4866 /** 4867 * Check if the current session is active 4868 * @returns { boolean } boolean 4869 * @throws { BusinessError } 6600101 - Session service exception. 4870 * @throws { BusinessError } 6600102 - The session does not exist. 4871 * @throws { BusinessError } 6600103 - The session controller does not exist. 4872 * @syscap SystemCapability.Multimedia.AVSession.Core 4873 * @since 10 4874 */ 4875 isActiveSync(): boolean; 4876 4877 /** 4878 * Destroy the server controller 4879 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 4880 * @throws { BusinessError } 6600101 - Session service exception. 4881 * @throws { BusinessError } 6600103 - The session controller does not exist. 4882 * @syscap SystemCapability.Multimedia.AVSession.Core 4883 * @since 10 4884 */ 4885 destroy(callback: AsyncCallback<void>): void; 4886 4887 /** 4888 * Destroy the server controller 4889 * @returns { Promise<void> } void promise when executed successfully 4890 * @throws { BusinessError } 6600101 - Session service exception. 4891 * @throws { BusinessError } 6600103 - The session controller does not exist. 4892 * @syscap SystemCapability.Multimedia.AVSession.Core 4893 * @since 10 4894 */ 4895 destroy(): Promise<void>; 4896 4897 /** 4898 * Get commands supported by the current session 4899 * @param { AsyncCallback<Array<AVControlCommandType>> } callback - The triggered asyncCallback when (getValidCommands). 4900 * @throws { BusinessError } 6600101 - Session service exception. 4901 * @throws { BusinessError } 6600102 - The session does not exist. 4902 * @throws { BusinessError } 6600103 - The session controller does not exist. 4903 * @syscap SystemCapability.Multimedia.AVSession.Core 4904 * @since 10 4905 */ 4906 getValidCommands(callback: AsyncCallback<Array<AVControlCommandType>>): void; 4907 4908 /** 4909 * Get commands supported by the current session 4910 * @returns { Promise<Array<AVControlCommandType>> } array of AVControlCommandType promise 4911 * @throws { BusinessError } 6600101 - Session service exception. 4912 * @throws { BusinessError } 6600102 - The session does not exist. 4913 * @throws { BusinessError } 6600103 - The session controller does not exist. 4914 * @syscap SystemCapability.Multimedia.AVSession.Core 4915 * @since 10 4916 */ 4917 getValidCommands(): Promise<Array<AVControlCommandType>>; 4918 4919 /** 4920 * Get commands supported by the current session 4921 * @returns {Array<AVControlCommandType> } array of AVControlCommandType 4922 * @throws { BusinessError } 6600101 - Session service exception. 4923 * @throws { BusinessError } 6600102 - The session does not exist. 4924 * @throws { BusinessError } 6600103 - The session controller does not exist. 4925 * @syscap SystemCapability.Multimedia.AVSession.Core 4926 * @since 10 4927 */ 4928 getValidCommandsSync(): Array<AVControlCommandType>; 4929 4930 /** 4931 * Send control commands to this session 4932 * @param { AVControlCommand } command - The command to be sent. See {@link AVControlCommand} 4933 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 4934 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4935 * 2.Parameter verification failed. 4936 * @throws { BusinessError } 6600101 - Session service exception. 4937 * @throws { BusinessError } 6600102 - The session does not exist. 4938 * @throws { BusinessError } 6600103 - The session controller does not exist. 4939 * @throws { BusinessError } 6600105 - Invalid session command. 4940 * @throws { BusinessError } 6600106 - The session is not activated. 4941 * @throws { BusinessError } 6600107 - Too many commands or events. 4942 * @syscap SystemCapability.Multimedia.AVSession.Core 4943 * @since 10 4944 */ 4945 sendControlCommand(command: AVControlCommand, callback: AsyncCallback<void>): void; 4946 4947 /** 4948 * Send control commands to this session 4949 * @param { AVControlCommand } command - The command to be sent. See {@link AVControlCommand} 4950 * @returns { Promise<void> } void promise when executed successfully 4951 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4952 * 2.Parameter verification failed. 4953 * @throws { BusinessError } 6600101 - Session service exception. 4954 * @throws { BusinessError } 6600102 - The session does not exist. 4955 * @throws { BusinessError } 6600103 - The session controller does not exist. 4956 * @throws { BusinessError } 6600105 - Invalid session command. 4957 * @throws { BusinessError } 6600106 - The session is not activated. 4958 * @throws { BusinessError } 6600107 - Too many commands or events. 4959 * @syscap SystemCapability.Multimedia.AVSession.Core 4960 * @since 10 4961 */ 4962 sendControlCommand(command: AVControlCommand): Promise<void>; 4963 4964 /** 4965 * Send common commands to this session 4966 * @param { string } command - The command name to be sent. 4967 * @param { object } args - The parameters of session event 4968 * @param { AsyncCallback<void> } callback - The asyncCallback triggered when the command is executed successfully. 4969 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4970 * 2.Parameter verification failed. 4971 * @throws { BusinessError } 6600101 - Session service exception. 4972 * @throws { BusinessError } 6600102 - The session does not exist. 4973 * @throws { BusinessError } 6600103 - The session controller does not exist. 4974 * @throws { BusinessError } 6600105 - Invalid session command. 4975 * @throws { BusinessError } 6600106 - The session is not activated. 4976 * @throws { BusinessError } 6600107 - Too many commands or events. 4977 * @syscap SystemCapability.Multimedia.AVSession.Core 4978 * @since 10 4979 */ 4980 sendCommonCommand(command: string, args: {[key: string]: Object}, callback: AsyncCallback<void>): void; 4981 4982 /** 4983 * Send common commands to this session 4984 * @param { string } command - The command name to be sent. 4985 * @param { object } args - The parameters of session event 4986 * @returns { Promise<void> } void promise when executed successfully 4987 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 4988 * 2.Parameter verification failed. 4989 * @throws { BusinessError } 6600101 - Session service exception. 4990 * @throws { BusinessError } 6600102 - The session does not exist. 4991 * @throws { BusinessError } 6600103 - The session controller does not exist. 4992 * @throws { BusinessError } 6600105 - Invalid session command. 4993 * @throws { BusinessError } 6600106 - The session is not activated. 4994 * @throws { BusinessError } 6600107 - Too many commands or events. 4995 * @syscap SystemCapability.Multimedia.AVSession.Core 4996 * @since 10 4997 */ 4998 sendCommonCommand(command: string, args: {[key: string]: Object}): Promise<void>; 4999 5000 /** 5001 * Get custom media packets provided by the corresponding session 5002 * @param { AsyncCallback<{[key: string]: Object}> } callback - The triggered asyncCallback when (getExtras). 5003 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5004 * 2.Incorrect parameter types. 3.Parameter verification failed. 5005 * @throws { BusinessError } 6600101 - Session service exception. 5006 * @throws { BusinessError } 6600102 - The session does not exist. 5007 * @throws { BusinessError } 6600103 - The session controller does not exist. 5008 * @throws { BusinessError } 6600105 - Invalid session command. 5009 * @throws { BusinessError } 6600107 - Too many commands or events. 5010 * @syscap SystemCapability.Multimedia.AVSession.Core 5011 * @since 10 5012 */ 5013 getExtras(callback: AsyncCallback<{[key: string]: Object}>): void; 5014 5015 /** 5016 * Get custom media packets provided by the corresponding session 5017 * @returns { Promise<{[key: string]: Object}> } the parameters of extras 5018 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5019 * 2.Incorrect parameter types. 3.Parameter verification failed. 5020 * @throws { BusinessError } 6600101 - Session service exception. 5021 * @throws { BusinessError } 6600102 - The session does not exist. 5022 * @throws { BusinessError } 6600103 - The session controller does not exist. 5023 * @throws { BusinessError } 6600105 - Invalid session command. 5024 * @throws { BusinessError } 6600107 - Too many commands or events. 5025 * @syscap SystemCapability.Multimedia.AVSession.Core 5026 * @since 10 5027 */ 5028 getExtras(): Promise<{[key: string]: Object}>; 5029 5030 /** 5031 * Register metadata changed callback 5032 * @param { 'metadataChange' } type 5033 * @param { Array<keyof AVMetadata> | 'all' } filter - The properties of {@link AVMetadata} that you cared about 5034 * @param { function } callback - The callback used to handle metadata changed event. 5035 * The callback function provides the {@link AVMetadata} parameter. 5036 * It only contains the properties set in the filter. 5037 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5038 * 2.Incorrect parameter types. 5039 * @throws { BusinessError } 6600101 - Session service exception. 5040 * @throws { BusinessError } 6600103 - The session controller does not exist. 5041 * @syscap SystemCapability.Multimedia.AVSession.Core 5042 * @since 10 5043 */ 5044 on(type: 'metadataChange', filter: Array<keyof AVMetadata> | 'all', callback: (data: AVMetadata) => void); 5045 5046 /** 5047 * Unregister metadata changed callback 5048 * @param { 'metadataChange' } type 5049 * @param { function } callback - The callback used to handle metadata changed event. 5050 * The callback function provides the {@link AVMetadata} parameter. 5051 * It only contains the properties set in the filter. 5052 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5053 * 2.Incorrect parameter types. 5054 * @throws { BusinessError } 6600101 - Session service exception. 5055 * @throws { BusinessError } 6600103 - The session controller does not exist. 5056 * @syscap SystemCapability.Multimedia.AVSession.Core 5057 * @since 10 5058 */ 5059 off(type: 'metadataChange', callback?: (data: AVMetadata) => void); 5060 5061 /** 5062 * Register playback state changed callback 5063 * @param { 'playbackStateChange' } type 5064 * @param { Array<keyof AVPlaybackState> | 'all' } filter - The properties of {@link AVPlaybackState} that you cared about 5065 * @param { function } callback - The callback used to handle playback state changed event. 5066 * The callback function provides the {@link AVPlaybackState} parameter. 5067 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5068 * 2.Incorrect parameter types. 5069 * @throws { BusinessError } 6600101 - Session service exception. 5070 * @throws { BusinessError } 6600103 - The session controller does not exist. 5071 * @syscap SystemCapability.Multimedia.AVSession.Core 5072 * @since 10 5073 */ 5074 on(type: 'playbackStateChange', filter: Array<keyof AVPlaybackState> | 'all', callback: (state: AVPlaybackState) => void); 5075 5076 /** 5077 * Unregister playback state changed callback 5078 * @param { 'playbackStateChange' } type 5079 * @param { function } callback - The callback used to handle playback state changed event. 5080 * The callback function provides the {@link AVPlaybackState} parameter. 5081 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5082 * 2.Incorrect parameter types. 5083 * @throws { BusinessError } 6600101 - Session service exception. 5084 * @throws { BusinessError } 6600103 - The session controller does not exist. 5085 * @syscap SystemCapability.Multimedia.AVSession.Core 5086 * @since 10 5087 */ 5088 off(type: 'playbackStateChange', callback?: (state: AVPlaybackState) => void); 5089 5090 /** 5091 * Register call metadata changed callback 5092 * @param { 'callMetadataChange' } type - 'callMetadataChange' 5093 * @param { Array<keyof CallMetadata> | 'all' } filter - The properties of {@link CallMetadata} that you cared about 5094 * @param { Callback<CallMetadata> } callback - The callback used to handle call metadata changed event. 5095 * The callback function provides the {@link CallMetadata} parameter. 5096 * It only contains the properties set in the filter. 5097 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5098 * 2.Incorrect parameter types. 5099 * @throws { BusinessError } 6600101 - Session service exception. 5100 * @throws { BusinessError } 6600103 - The session controller does not exist. 5101 * @syscap SystemCapability.Multimedia.AVSession.Core 5102 * @since 11 5103 */ 5104 on(type: 'callMetadataChange', filter: Array<keyof CallMetadata> | 'all', callback: Callback<CallMetadata>): void; 5105 5106 /** 5107 * Unregister call metadata changed callback 5108 * @param { 'callMetadataChange' } type - 'callMetadataChange' 5109 * @param { Callback<CallMetadata> } callback - The callback used to handle call metadata changed event. 5110 * The callback function provides the {@link CallMetadata} parameter. 5111 * It only contains the properties set in the filter. 5112 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5113 * 2.Incorrect parameter types. 5114 * @throws { BusinessError } 6600101 - Session service exception. 5115 * @throws { BusinessError } 6600103 - The session controller does not exist. 5116 * @syscap SystemCapability.Multimedia.AVSession.Core 5117 * @since 11 5118 */ 5119 off(type: 'callMetadataChange', callback?: Callback<CallMetadata>): void; 5120 5121 /** 5122 * Register call state changed callback 5123 * @param { 'callStateChange' } type - 'callStateChange' 5124 * @param { Array<keyof AVCallState> | 'all' } filter - The properties of {@link AVCallState} that you cared about 5125 * @param { Callback<AVCallState> } callback - The callback used to handle call state changed event. 5126 * The callback function provides the {@link AVCallState} parameter. 5127 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5128 * 2.Incorrect parameter types. 5129 * @throws { BusinessError } 6600101 - Session service exception. 5130 * @throws { BusinessError } 6600103 - The session controller does not exist. 5131 * @syscap SystemCapability.Multimedia.AVSession.Core 5132 * @since 11 5133 */ 5134 on(type: 'callStateChange', filter: Array<keyof AVCallState> | 'all', callback: Callback<AVCallState>): void; 5135 5136 /** 5137 * Unregister playback state changed callback 5138 * @param { 'callStateChange' } type - 'callStateChange' 5139 * @param { Callback<AVCallState> } callback - The callback used to handle call state changed event. 5140 * The callback function provides the {@link AVCallState} parameter. 5141 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5142 * 2.Incorrect parameter types. 5143 * @throws { BusinessError } 6600101 - Session service exception. 5144 * @throws { BusinessError } 6600103 - The session controller does not exist. 5145 * @syscap SystemCapability.Multimedia.AVSession.Core 5146 * @since 11 5147 */ 5148 off(type: 'callStateChange', callback?: Callback<AVCallState>): void; 5149 5150 /** 5151 * Register current session destroyed callback 5152 * @param { 'sessionDestroy' } type 5153 * @param { function } callback - The callback used to handle current session destroyed event. 5154 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5155 * 2.Incorrect parameter types. 5156 * @throws { BusinessError } 6600101 - Session service exception. 5157 * @throws { BusinessError } 6600103 - The session controller does not exist. 5158 * @syscap SystemCapability.Multimedia.AVSession.Core 5159 * @since 10 5160 */ 5161 on(type: 'sessionDestroy', callback: () => void); 5162 5163 /** 5164 * Unregister current session destroyed callback 5165 * @param { 'sessionDestroy' } type - 'sessionDestroy' 5166 * @param { function } callback - The callback used to handle current session destroyed event. 5167 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5168 * 2.Incorrect parameter types. 5169 * @throws { BusinessError } 6600101 - Session service exception. 5170 * @throws { BusinessError } 6600103 - The session controller does not exist. 5171 * @syscap SystemCapability.Multimedia.AVSession.Core 5172 * @since 10 5173 */ 5174 off(type: 'sessionDestroy', callback?: () => void); 5175 5176 /** 5177 * Register the active state of this session changed callback 5178 * @param { 'activeStateChange' } type - 'activeStateChange' 5179 * @param { function } callback - The callback used to handle the active state of this session changed event. 5180 * The callback function provides the changed session state. 5181 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5182 * 2.Incorrect parameter types. 5183 * @throws { BusinessError } 6600101 - Session service exception. 5184 * @throws { BusinessError } 6600103 - The session controller does not exist. 5185 * @syscap SystemCapability.Multimedia.AVSession.Core 5186 * @since 10 5187 */ 5188 on(type: 'activeStateChange', callback: (isActive: boolean) => void); 5189 5190 /** 5191 * Unregister the active state of this session changed callback 5192 * @param { 'activeStateChange' } type - 'activeStateChange' 5193 * @param { function } callback - The callback used to handle the active state of this session changed event. 5194 * The callback function provides the changed session state. 5195 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5196 * 2.Incorrect parameter types. 5197 * @throws { BusinessError } 6600101 - Session service exception. 5198 * @throws { BusinessError } 6600103 - The session controller does not exist. 5199 * @syscap SystemCapability.Multimedia.AVSession.Core 5200 * @since 10 5201 */ 5202 off(type: 'activeStateChange', callback?: (isActive: boolean) => void); 5203 5204 /** 5205 * Register the valid commands of the session changed callback 5206 * @param { 'validCommandChange' } type - 'validCommandChange' 5207 * @param { function } callback - The callback used to handle the changes. 5208 * The callback function provides an array of AVControlCommandType. 5209 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5210 * 2.Incorrect parameter types. 5211 * @throws { BusinessError } 6600101 - Session service exception. 5212 * @throws { BusinessError } 6600103 - The session controller does not exist. 5213 * @syscap SystemCapability.Multimedia.AVSession.Core 5214 * @since 10 5215 */ 5216 on(type: 'validCommandChange', callback: (commands: Array<AVControlCommandType>) => void); 5217 5218 /** 5219 * Unregister the valid commands of the session changed callback 5220 * @param { 'validCommandChange' } type - 'validCommandChange' 5221 * @param { function } callback - The callback used to handle the changes. 5222 * The callback function provides an array of AVControlCommandType. 5223 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5224 * 2.Incorrect parameter types. 5225 * @throws { BusinessError } 6600101 - Session service exception. 5226 * @throws { BusinessError } 6600103 - The session controller does not exist. 5227 * @syscap SystemCapability.Multimedia.AVSession.Core 5228 * @since 10 5229 */ 5230 off(type: 'validCommandChange', callback?: (commands: Array<AVControlCommandType>) => void); 5231 5232 /** 5233 * Register session output device change callback 5234 * @param { 'outputDeviceChange' } type - Registration Type 'outputDeviceChange' 5235 * @param { function } callback - Used to handle output device changed. 5236 * The callback provide the new device info {@link OutputDeviceInfo} and related connection state {@link ConnectionState}. 5237 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5238 * 2.Incorrect parameter types. 5239 * @throws { BusinessError } 6600101 - Session service exception 5240 * @throws { BusinessError } 6600103 - The session controller does not exist 5241 * @syscap SystemCapability.Multimedia.AVSession.Core 5242 * @since 10 5243 */ 5244 on(type: 'outputDeviceChange', callback: (state: ConnectionState, device: OutputDeviceInfo) => void): void; 5245 5246 /** 5247 * Unregister session output device change callback 5248 * @param { 'outputDeviceChange' } type - Registration Type 'outputDeviceChange' 5249 * @param { function } callback - Used to handle output device changed. 5250 * The callback provide the new device info {@link OutputDeviceInfo} and related connection state {@link ConnectionState}. 5251 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5252 * 2.Incorrect parameter types. 5253 * @throws { BusinessError } 6600101 - Session service exception 5254 * @throws { BusinessError } 6600103 - The session controller does not exist 5255 * @syscap SystemCapability.Multimedia.AVSession.Core 5256 * @since 10 5257 */ 5258 off(type: 'outputDeviceChange', callback?: (state: ConnectionState, device: OutputDeviceInfo) => void): void; 5259 5260 /** 5261 * Register session event callback 5262 * @param { 'sessionEvent' } type - 'sessionEvent' 5263 * @param { function } callback - The callback used to handle session event changed event. 5264 * The callback function provides the event string and key-value pair parameters. 5265 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5266 * 2.Incorrect parameter types. 5267 * @throws { BusinessError } 6600101 - Session service exception. 5268 * @throws { BusinessError } 6600103 - The session controller does not exist. 5269 * @syscap SystemCapability.Multimedia.AVSession.Core 5270 * @since 10 5271 */ 5272 on(type: 'sessionEvent', callback: (sessionEvent: string, args: {[key: string]: Object}) => void): void; 5273 5274 /** 5275 * Unregister session event callback 5276 * @param { 'sessionEvent' } type - 'sessionEvent' 5277 * @param { function } callback - Used to cancel a specific listener 5278 * The callback function provides the event string and key-value pair parameters. 5279 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5280 * 2.Incorrect parameter types. 5281 * @throws { BusinessError } 6600101 - Session service exception. 5282 * @throws { BusinessError } 6600103 - The session controller does not exist. 5283 * @syscap SystemCapability.Multimedia.AVSession.Core 5284 * @since 10 5285 */ 5286 off(type: 'sessionEvent', callback?: (sessionEvent: string, args: {[key: string]: Object}) => void): void; 5287 5288 /** 5289 * Register session playlist change callback 5290 * @param { 'queueItemsChange' } type - Registration Type 'queueItemsChange' 5291 * @param { function } callback - Used to handle playlist changed. 5292 * The callback provides the new array of AVQueueItem {@link AVQueueItem} 5293 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5294 * 2.Incorrect parameter types. 5295 * @throws { BusinessError } 6600101 - Session service exception. 5296 * @throws { BusinessError } 6600103 - The session controller does not exist. 5297 * @syscap SystemCapability.Multimedia.AVSession.Core 5298 * @since 10 5299 */ 5300 on(type: 'queueItemsChange', callback: (items: Array<AVQueueItem>) => void): void; 5301 5302 /** 5303 * Unregister session playlist change callback 5304 * @param { 'queueItemsChange' } type - Registration Type 'queueItemsChange' 5305 * @param { function } callback - Used to handle playlist changed. 5306 * The callback provides the new array of AVQueueItem {@link AVQueueItem} 5307 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5308 * 2.Incorrect parameter types. 5309 * @throws { BusinessError } 6600101 - Session service exception. 5310 * @throws { BusinessError } 6600103 - The session controller does not exist. 5311 * @syscap SystemCapability.Multimedia.AVSession.Core 5312 * @since 10 5313 */ 5314 off(type: 'queueItemsChange', callback?: (items: Array<AVQueueItem>) => void): void; 5315 5316 /** 5317 * Register the name of session playlist change callback 5318 * @param { 'queueTitleChange' } type - Registration Type 'queueTitleChange' 5319 * @param { function } callback - Used to handle name of playlist changed. 5320 * The callback provides the new name. 5321 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5322 * 2.Incorrect parameter types. 5323 * @throws { BusinessError } 6600101 - Session service exception. 5324 * @throws { BusinessError } 6600103 - The session controller does not exist. 5325 * @syscap SystemCapability.Multimedia.AVSession.Core 5326 * @since 10 5327 */ 5328 on(type: 'queueTitleChange', callback: (title: string) => void): void; 5329 5330 /** 5331 * Unregister the name of session playlist change callback 5332 * @param { 'queueTitleChange' } type - Registration Type 'queueTitleChange' 5333 * @param { function } callback - Used to handle name of playlist changed. 5334 * The callback provides the new name. 5335 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5336 * 2.Incorrect parameter types. 5337 * @throws { BusinessError } 6600101 - Session service exception. 5338 * @throws { BusinessError } 6600103 - The session controller does not exist. 5339 * @syscap SystemCapability.Multimedia.AVSession.Core 5340 * @since 10 5341 */ 5342 off(type: 'queueTitleChange', callback?: (title: string) => void): void; 5343 5344 /** 5345 * Register the custom media packets change callback 5346 * @param { 'extrasChange' } type - Registration Type 'extrasChange' 5347 * @param { function } callback - Used to handle custom media packets changed. 5348 * The callback provides the new media packets. 5349 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5350 * 2.Incorrect parameter types. 5351 * @throws { BusinessError } 6600101 - Session service exception. 5352 * @throws { BusinessError } 6600103 - The session controller does not exist. 5353 * @syscap SystemCapability.Multimedia.AVSession.Core 5354 * @since 10 5355 */ 5356 on(type: 'extrasChange', callback: (extras: {[key: string]: Object}) => void): void; 5357 5358 /** 5359 * Unregister the custom media packets change callback 5360 * @param { 'extrasChange' } type - Registration Type 'extrasChange' 5361 * @param { function } callback - Used to handle custom media packets changed. 5362 * The callback provides the new media packets. 5363 * @throws { BusinessError } 401 - parameter check failed. 1.Mandatory parameters are left unspecified. 5364 * 2.Incorrect parameter types. 5365 * @throws { BusinessError } 6600101 - Session service exception. 5366 * @throws { BusinessError } 6600103 - The session controller does not exist. 5367 * @syscap SystemCapability.Multimedia.AVSession.Core 5368 * @since 10 5369 */ 5370 off(type: 'extrasChange', callback?: (extras: {[key: string]: Object}) => void): void; 5371 } 5372 5373 /** 5374 * The type of control command 5375 * @syscap SystemCapability.Multimedia.AVSession.Core 5376 * @since 10 5377 */ 5378 /** 5379 * The type of control command, add new support 'playFromAssetId' | 'answer' | 'hangUp' | 'toggleCallMute' 5380 * @syscap SystemCapability.Multimedia.AVSession.Core 5381 * @since 11 5382 */ 5383 type AVControlCommandType = 'play' | 'pause' | 'stop' | 'playNext' | 'playPrevious' | 'fastForward' | 'rewind' | 5384 'seek' | 'setSpeed' | 'setLoopMode' | 'toggleFavorite' | 'playFromAssetId' | 'answer' | 'hangUp' | 'toggleCallMute'; 5385 5386 /** 5387 * The definition of command to be sent to the session 5388 * @interface AVControlCommand 5389 * @syscap SystemCapability.Multimedia.AVSession.Core 5390 * @since 10 5391 */ 5392 interface AVControlCommand { 5393 /** 5394 * The command value {@link AVControlCommandType} 5395 * @syscap SystemCapability.Multimedia.AVSession.Core 5396 * @since 10 5397 */ 5398 command: AVControlCommandType; 5399 5400 /** 5401 * parameter of the command. Whether this command requires parameters, see {@link AVSessionCommand} 5402 * seek command requires a number parameter 5403 * setSpeed command requires a number parameter 5404 * setLoopMode command requires a {@link LoopMode} parameter. 5405 * toggleFavorite command requires assetId {@link AVMetadata.assetId} parameter 5406 * other commands need no parameter 5407 * @syscap SystemCapability.Multimedia.AVSession.Core 5408 * @since 10 5409 */ 5410 parameter?: LoopMode | string | number; 5411 } 5412 5413 /** 5414 * Enumerates ErrorCode types, returns in BusinessError.code. 5415 * @enum { number } 5416 * @syscap SystemCapability.Multimedia.AVSession.Core 5417 * @since 10 5418 */ 5419 /** 5420 * Enumerates ErrorCode types, returns in BusinessError.code. 5421 * @enum { number } 5422 * @syscap SystemCapability.Multimedia.AVSession.Core 5423 * @atomicservice 5424 * @since 12 5425 */ 5426 enum AVSessionErrorCode { 5427 /** 5428 * Session service exception. 5429 * @syscap SystemCapability.Multimedia.AVSession.Core 5430 * @since 10 5431 */ 5432 /** 5433 * Session service exception. 5434 * @syscap SystemCapability.Multimedia.AVSession.Core 5435 * @atomicservice 5436 * @since 12 5437 */ 5438 ERR_CODE_SERVICE_EXCEPTION = 6600101, 5439 5440 /** 5441 * The session does not exist 5442 * @syscap SystemCapability.Multimedia.AVSession.Core 5443 * @since 10 5444 */ 5445 /** 5446 * The session does not exist 5447 * @syscap SystemCapability.Multimedia.AVSession.Core 5448 * @atomicservice 5449 * @since 12 5450 */ 5451 ERR_CODE_SESSION_NOT_EXIST = 6600102, 5452 5453 /** 5454 * The session controller does not exist. 5455 * @syscap SystemCapability.Multimedia.AVSession.Core 5456 * @since 10 5457 */ 5458 /** 5459 * The session controller does not exist. 5460 * @syscap SystemCapability.Multimedia.AVSession.Core 5461 * @atomicservice 5462 * @since 12 5463 */ 5464 ERR_CODE_CONTROLLER_NOT_EXIST = 6600103, 5465 5466 /** 5467 * The remote session connection failed. 5468 * @syscap SystemCapability.Multimedia.AVSession.Core 5469 * @since 10 5470 */ 5471 /** 5472 * The remote session connection failed. 5473 * @syscap SystemCapability.Multimedia.AVSession.Core 5474 * @atomicservice 5475 * @since 12 5476 */ 5477 ERR_CODE_REMOTE_CONNECTION_ERR = 6600104, 5478 5479 /** 5480 * Invalid session command. 5481 * @syscap SystemCapability.Multimedia.AVSession.Core 5482 * @since 10 5483 */ 5484 /** 5485 * Invalid session command. 5486 * @syscap SystemCapability.Multimedia.AVSession.Core 5487 * @atomicservice 5488 * @since 12 5489 */ 5490 ERR_CODE_COMMAND_INVALID = 6600105, 5491 5492 /** 5493 * The session is not activated. 5494 * @syscap SystemCapability.Multimedia.AVSession.Core 5495 * @since 10 5496 */ 5497 /** 5498 * The session is not activated. 5499 * @syscap SystemCapability.Multimedia.AVSession.Core 5500 * @atomicservice 5501 * @since 12 5502 */ 5503 ERR_CODE_SESSION_INACTIVE = 6600106, 5504 5505 /** 5506 * Too many commands or events. 5507 * @syscap SystemCapability.Multimedia.AVSession.Core 5508 * @since 10 5509 */ 5510 /** 5511 * Too many commands or events. 5512 * @syscap SystemCapability.Multimedia.AVSession.Core 5513 * @atomicservice 5514 * @since 12 5515 */ 5516 ERR_CODE_MESSAGE_OVERLOAD = 6600107, 5517 5518 /** 5519 * Device connecting failed. 5520 * @syscap SystemCapability.Multimedia.AVSession.Core 5521 * @since 10 5522 */ 5523 /** 5524 * Device connecting failed. 5525 * @syscap SystemCapability.Multimedia.AVSession.Core 5526 * @atomicservice 5527 * @since 12 5528 */ 5529 ERR_CODE_DEVICE_CONNECTION_FAILED = 6600108, 5530 5531 /** 5532 * The remote connection is not established. 5533 * @syscap SystemCapability.Multimedia.AVSession.Core 5534 * @since 10 5535 */ 5536 /** 5537 * The remote connection is not established. 5538 * @syscap SystemCapability.Multimedia.AVSession.Core 5539 * @atomicservice 5540 * @since 12 5541 */ 5542 ERR_CODE_REMOTE_CONNECTION_NOT_EXIST = 6600109, 5543 } 5544} 5545 5546export default avSession; 5547