161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit AudioKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport type { Callback, AsyncCallback } from '../@ohos.base';
2261847f8eSopenharmony_ciimport type audio from '../@ohos.multimedia.audio';
2361847f8eSopenharmony_ciimport type media from '../@ohos.multimedia.media';
2461847f8eSopenharmony_ci
2561847f8eSopenharmony_ci/**
2661847f8eSopenharmony_ci * Interface for ringtone options.
2761847f8eSopenharmony_ci * @typedef RingtoneOptions
2861847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core
2961847f8eSopenharmony_ci * @systemapi
3061847f8eSopenharmony_ci * @since 10
3161847f8eSopenharmony_ci */
3261847f8eSopenharmony_ciexport interface RingtoneOptions {
3361847f8eSopenharmony_ci  /**
3461847f8eSopenharmony_ci   * Ringtone volume.
3561847f8eSopenharmony_ci   * @type { number }
3661847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
3761847f8eSopenharmony_ci   * @systemapi
3861847f8eSopenharmony_ci   * @since 10
3961847f8eSopenharmony_ci   */
4061847f8eSopenharmony_ci  volume: number;
4161847f8eSopenharmony_ci  /**
4261847f8eSopenharmony_ci   * Loop value.
4361847f8eSopenharmony_ci   * @type { boolean }
4461847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
4561847f8eSopenharmony_ci   * @systemapi
4661847f8eSopenharmony_ci   * @since 10
4761847f8eSopenharmony_ci   */
4861847f8eSopenharmony_ci  loop: boolean;
4961847f8eSopenharmony_ci}
5061847f8eSopenharmony_ci
5161847f8eSopenharmony_ci/**
5261847f8eSopenharmony_ci * Ringtone player object.
5361847f8eSopenharmony_ci * @typedef RingtonePlayer
5461847f8eSopenharmony_ci * @syscap SystemCapability.Multimedia.SystemSound.Core
5561847f8eSopenharmony_ci * @systemapi
5661847f8eSopenharmony_ci * @since 10
5761847f8eSopenharmony_ci */
5861847f8eSopenharmony_ciexport interface RingtonePlayer {
5961847f8eSopenharmony_ci  /**
6061847f8eSopenharmony_ci   * Gets player state.
6161847f8eSopenharmony_ci   * @type { media.AVPlayerState }
6261847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
6361847f8eSopenharmony_ci   * @systemapi
6461847f8eSopenharmony_ci   * @since 10
6561847f8eSopenharmony_ci   */
6661847f8eSopenharmony_ci  readonly state: media.AVPlayerState;
6761847f8eSopenharmony_ci
6861847f8eSopenharmony_ci  /**
6961847f8eSopenharmony_ci   * Gets the title of ringtone.
7061847f8eSopenharmony_ci   * @param { AsyncCallback<string> } callback - Callback used to return the title.
7161847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
7261847f8eSopenharmony_ci   * @systemapi
7361847f8eSopenharmony_ci   * @since 10
7461847f8eSopenharmony_ci   */
7561847f8eSopenharmony_ci  getTitle(callback: AsyncCallback<string>): void;
7661847f8eSopenharmony_ci  /**
7761847f8eSopenharmony_ci   * Gets the title of ringtone.
7861847f8eSopenharmony_ci   * @returns { Promise<string> } Promise used to return the title.
7961847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
8061847f8eSopenharmony_ci   * @systemapi
8161847f8eSopenharmony_ci   * @since 10
8261847f8eSopenharmony_ci   */
8361847f8eSopenharmony_ci  getTitle(): Promise<string>;
8461847f8eSopenharmony_ci
8561847f8eSopenharmony_ci  /**
8661847f8eSopenharmony_ci   * Gets audio renderer info.
8761847f8eSopenharmony_ci   * @param { AsyncCallback<audio.AudioRendererInfo> } callback - Callback used to return AudioRendererInfo value.
8861847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
8961847f8eSopenharmony_ci   * @systemapi
9061847f8eSopenharmony_ci   * @since 10
9161847f8eSopenharmony_ci   */
9261847f8eSopenharmony_ci  getAudioRendererInfo(callback: AsyncCallback<audio.AudioRendererInfo>): void;
9361847f8eSopenharmony_ci  /**
9461847f8eSopenharmony_ci   * Gets audio renderer info.
9561847f8eSopenharmony_ci   * @returns { Promise<audio.AudioRendererInfo> } Promise used to return AudioRendererInfo value.
9661847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
9761847f8eSopenharmony_ci   * @systemapi
9861847f8eSopenharmony_ci   * @since 10
9961847f8eSopenharmony_ci   */
10061847f8eSopenharmony_ci  getAudioRendererInfo(): Promise<audio.AudioRendererInfo>;
10161847f8eSopenharmony_ci
10261847f8eSopenharmony_ci  /**
10361847f8eSopenharmony_ci   * Configure ringtone options.
10461847f8eSopenharmony_ci   * @param { RingtoneOptions } options - Ringtone configure options.
10561847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback used to return configuration result.
10661847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
10761847f8eSopenharmony_ci   * @systemapi
10861847f8eSopenharmony_ci   * @since 10
10961847f8eSopenharmony_ci   */
11061847f8eSopenharmony_ci  configure(options: RingtoneOptions, callback: AsyncCallback<void>): void;
11161847f8eSopenharmony_ci  /**
11261847f8eSopenharmony_ci   * Configure ringtone options.
11361847f8eSopenharmony_ci   * @param { RingtoneOptions } options - Ringtone configure options.
11461847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return configuration result.
11561847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
11661847f8eSopenharmony_ci   * @systemapi
11761847f8eSopenharmony_ci   * @since 10
11861847f8eSopenharmony_ci   */
11961847f8eSopenharmony_ci  configure(options: RingtoneOptions): Promise<void>;
12061847f8eSopenharmony_ci
12161847f8eSopenharmony_ci  /**
12261847f8eSopenharmony_ci   * Starts playing ringtone.
12361847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback used to return the starting result.
12461847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
12561847f8eSopenharmony_ci   * @systemapi
12661847f8eSopenharmony_ci   * @since 10
12761847f8eSopenharmony_ci   */
12861847f8eSopenharmony_ci  start(callback: AsyncCallback<void>): void;
12961847f8eSopenharmony_ci  /**
13061847f8eSopenharmony_ci   * Starts playing ringtone.
13161847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the starting result.
13261847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
13361847f8eSopenharmony_ci   * @systemapi
13461847f8eSopenharmony_ci   * @since 10
13561847f8eSopenharmony_ci   */
13661847f8eSopenharmony_ci  start(): Promise<void>;
13761847f8eSopenharmony_ci
13861847f8eSopenharmony_ci  /**
13961847f8eSopenharmony_ci   * Stop playing ringtone.
14061847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback used to return the stopping result.
14161847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
14261847f8eSopenharmony_ci   * @systemapi
14361847f8eSopenharmony_ci   * @since 10
14461847f8eSopenharmony_ci   */
14561847f8eSopenharmony_ci  stop(callback: AsyncCallback<void>): void;
14661847f8eSopenharmony_ci  /**
14761847f8eSopenharmony_ci   * Stop playing ringtone.
14861847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the stopping result.
14961847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
15061847f8eSopenharmony_ci   * @systemapi
15161847f8eSopenharmony_ci   * @since 10
15261847f8eSopenharmony_ci   */
15361847f8eSopenharmony_ci  stop(): Promise<void>;
15461847f8eSopenharmony_ci
15561847f8eSopenharmony_ci  /**
15661847f8eSopenharmony_ci   * Release ringtone player resource.
15761847f8eSopenharmony_ci   * @param { AsyncCallback<void> } callback - Callback used to return the releasing result.
15861847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
15961847f8eSopenharmony_ci   * @systemapi
16061847f8eSopenharmony_ci   * @since 10
16161847f8eSopenharmony_ci   */
16261847f8eSopenharmony_ci  release(callback: AsyncCallback<void>): void;
16361847f8eSopenharmony_ci  /**
16461847f8eSopenharmony_ci   * Release ringtone player resource.
16561847f8eSopenharmony_ci   * @returns { Promise<void> } Promise used to return the releasing result.
16661847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
16761847f8eSopenharmony_ci   * @systemapi
16861847f8eSopenharmony_ci   * @since 10
16961847f8eSopenharmony_ci   */
17061847f8eSopenharmony_ci  release(): Promise<void>;
17161847f8eSopenharmony_ci
17261847f8eSopenharmony_ci  /**
17361847f8eSopenharmony_ci   * Listens for audio interrupt events. This method uses a callback to get interrupt events. The interrupt event is
17461847f8eSopenharmony_ci   * triggered when audio playback is interrupted.
17561847f8eSopenharmony_ci   * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported.
17661847f8eSopenharmony_ci   * @param { Callback<audio.InterruptEvent> } callback - Callback used to listen for interrupt callback.
17761847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
17861847f8eSopenharmony_ci   *                                 1.Mandatory parameters are left unspecified;
17961847f8eSopenharmony_ci   *                                 2.Incorrect parameter types.
18061847f8eSopenharmony_ci   * @throws { BusinessError } 6800101 - Parameter verification failed.
18161847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
18261847f8eSopenharmony_ci   * @systemapi
18361847f8eSopenharmony_ci   * @since 10
18461847f8eSopenharmony_ci   */
18561847f8eSopenharmony_ci  on(type: 'audioInterrupt', callback: Callback<audio.InterruptEvent>): void;
18661847f8eSopenharmony_ci
18761847f8eSopenharmony_ci  /**
18861847f8eSopenharmony_ci   * Unsubscribes to audio interrupt events.
18961847f8eSopenharmony_ci   * @param { 'audioInterrupt' } type - Type of the event to listen for. Only the audioInterrupt event is supported.
19061847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
19161847f8eSopenharmony_ci   *                                 1.Mandatory parameters are left unspecified;
19261847f8eSopenharmony_ci   *                                 2.Incorrect parameter types.
19361847f8eSopenharmony_ci   * @throws { BusinessError } 6800101 - Parameter verification failed.
19461847f8eSopenharmony_ci   * @syscap SystemCapability.Multimedia.SystemSound.Core
19561847f8eSopenharmony_ci   * @systemapi
19661847f8eSopenharmony_ci   * @since 10
19761847f8eSopenharmony_ci   */
19861847f8eSopenharmony_ci  off(type: 'audioInterrupt'): void
19961847f8eSopenharmony_ci}