mirror of
https://gitee.com/openharmony/interface_sdk-js
synced 2025-04-12 10:13:17 +00:00
update media api Signed-off-by: huang-xl<huangxiaolong1@huawei.com>
This commit is contained in:
parent
500b65c5b2
commit
a78ac01d11
427
api/@ohos.multimedia.media.d.ts
vendored
427
api/@ohos.multimedia.media.d.ts
vendored
@ -13,116 +13,363 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {ErrorCallback, AsyncCallback, Callback} from './basic';
|
||||
import { ErrorCallback, AsyncCallback, Callback } from './basic';
|
||||
|
||||
/**
|
||||
* @name media
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
* @import import media from '@ohos.multimedia.media';
|
||||
* This part of the function is temporarily unavailable due to permission issues in the standard system,
|
||||
* waiting for update
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @import import media from '@ohos.multimedia.media'
|
||||
* @devices phone, tablet, tv, wearable
|
||||
*/
|
||||
declare namespace media {
|
||||
/**
|
||||
* Creates an AudioPlayer instance.
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @import import media from '@ohos.multimedia.media'
|
||||
* @return Returns an AudioPlayer instance if the operation is successful; returns null otherwise.
|
||||
*/
|
||||
function createAudioPlayer(): AudioPlayer;
|
||||
|
||||
/**
|
||||
* Creates an AudioRecorder instance.
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @import import media from '@ohos.multimedia.media'
|
||||
* @return Returns an AudioRecorder instance if the operation is successful; returns null otherwise.
|
||||
*/
|
||||
function createAudioRecorder(): AudioRecorder;
|
||||
|
||||
/**
|
||||
* Describes audio playback states.
|
||||
*/
|
||||
type AudioState = 'idle' | 'playing' | 'paused' | 'stopped';
|
||||
|
||||
/**
|
||||
* Manages and plays audio. Before calling an AudioPlayer method, you must use createAudioPlayer() to create an AudioPlayer instance.
|
||||
*/
|
||||
interface AudioPlayer {
|
||||
/**
|
||||
* Create the AudioPlayer instance to manage audio play
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
* Starts audio playback.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
function createAudioPlayer(): AudioPlayer;
|
||||
play(): void;
|
||||
|
||||
/**
|
||||
* Audio playback state
|
||||
* Pauses audio playback.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
type AudioState = 'playing' | 'paused' | 'stopped';
|
||||
pause(): void;
|
||||
|
||||
interface AudioPlayer {
|
||||
/**
|
||||
* start to play audio resource
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
play(): void;
|
||||
/**
|
||||
* Stops audio playback.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
stop(): void;
|
||||
|
||||
/**
|
||||
* pause playing
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
pause(): void;
|
||||
/**
|
||||
* Resets audio playback.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 7
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* stop playing
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Jumps to the specified playback position.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param timeMs Playback position to jump
|
||||
*/
|
||||
seek(timeMs: number): void;
|
||||
|
||||
/**
|
||||
* jump to a specified location
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
* @param time position to seek
|
||||
*/
|
||||
seek(timeMs: number):void;
|
||||
/**
|
||||
* Sets the volume.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param vol Relative volume. The value ranges from 0.00 to 1.00. The value 1 indicates the maximum volume (100%).
|
||||
*/
|
||||
setVolume(vol: number): void;
|
||||
|
||||
/**
|
||||
* change the audioplayer volume
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
* @param volume to set
|
||||
*/
|
||||
setVolume(vol: number): void;
|
||||
/**
|
||||
* Releases resources used for audio playback.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
release(): void;
|
||||
|
||||
/**
|
||||
* release audio resource
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
release(): void;
|
||||
/**
|
||||
* Audio media URI. Mainstream audio formats are supported.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
src: string;
|
||||
|
||||
/**
|
||||
* audio resource URI
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
src: string;
|
||||
/**
|
||||
* Whether to loop audio playback. The value true means to loop playback.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
loop: boolean;
|
||||
|
||||
/**
|
||||
* whether audio is single looping
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
* @option true "The audio looping function is enabled."
|
||||
* @option false "The audio looping function is disabled."
|
||||
*/
|
||||
loop: boolean;
|
||||
/**
|
||||
* Current playback position.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
readonly currentTime: number;
|
||||
|
||||
/**
|
||||
* audio property of current progress
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
readonly currentTime: number;
|
||||
/**
|
||||
* Playback duration. When the data source does not support seek, it returns - 1, such as a live broadcast scenario.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
readonly duration: number;
|
||||
|
||||
/**
|
||||
* audio property of audio playback duration
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
readonly duration: number;
|
||||
/**
|
||||
* Playback state.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
readonly state: AudioState;
|
||||
|
||||
/**
|
||||
* audio property of playback status
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
readonly state: AudioState;
|
||||
/**
|
||||
* Listens for audio playback events.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param type Type of the playback event to listen for.
|
||||
* @param callback Callback used to listen for the playback event.
|
||||
*/
|
||||
on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeChange', callback: () => void): void;
|
||||
|
||||
/**
|
||||
* audio callback function for listening to event
|
||||
* @devices phone
|
||||
* @sysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
on(type: 'play' | 'pause' | 'stop' | 'dataLoad' | 'finish' | 'volumeChange' | 'timeUpdate', callback: ()=>{}):void;
|
||||
on(type:'error', callback: ErrorCallback):void;
|
||||
}
|
||||
/**
|
||||
* Listens for audio playback events.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param type Type of the playback event to listen for.
|
||||
* @param callback Callback used to listen for the playback event.
|
||||
*/
|
||||
on(type: 'timeUpdate', callback: Callback<number>): void;
|
||||
|
||||
/**
|
||||
* Listens for playback error events.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param type Type of the playback error event to listen for.
|
||||
* @param callback Callback used to listen for the playback error event.
|
||||
*/
|
||||
on(type: 'error', callback: ErrorCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates audio encoding formats.
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @import import media from '@ohos.multimedia.media'
|
||||
* @devices phone, tablet, tv, wearable
|
||||
*/
|
||||
enum AudioEncoder {
|
||||
/**
|
||||
* Advanced Audio Coding Low Complexity (AAC-LC).
|
||||
*/
|
||||
AAC_LC = 3,
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerates audio output formats.
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @import import media from '@ohos.multimedia.media'
|
||||
* @devices phone, tablet, tv, wearable
|
||||
*/
|
||||
enum AudioOutputFormat {
|
||||
/**
|
||||
* Indicates the Moving Picture Experts Group-4 (MPEG4) media format.
|
||||
*/
|
||||
MPEG_4 = 2,
|
||||
|
||||
/**
|
||||
* Audio Data Transport Stream (ADTS), a transmission stream format of Advanced Audio Coding (AAC) audio.
|
||||
*/
|
||||
AAC_ADTS = 6
|
||||
}
|
||||
|
||||
interface Location {
|
||||
/**
|
||||
* Latitude.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
latitude: number;
|
||||
|
||||
/**
|
||||
* Longitude.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
interface AudioRecorderConfig {
|
||||
/**
|
||||
* Audio encoding format. The default value is DEFAULT.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
audioEncoder?: AudioEncoder;
|
||||
|
||||
/**
|
||||
* Audio encoding bit rate.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
audioEncodeBitRate?: number;
|
||||
|
||||
/**
|
||||
* Audio sampling rate.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
audioSampleRate?: number;
|
||||
|
||||
/**
|
||||
* Number of audio channels.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
numberOfChannels?: number;
|
||||
|
||||
/**
|
||||
* Audio output format. The default value is DEFAULT.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
format?: AudioOutputFormat;
|
||||
|
||||
/**
|
||||
* Audio output uri.support two kind of uri now.
|
||||
* format like: scheme + "://" + "context".
|
||||
* file: file://path
|
||||
* fd: fd://fd
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
uri: string;
|
||||
|
||||
/**
|
||||
* Geographical location information.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
location?: Location;
|
||||
}
|
||||
|
||||
interface AudioRecorder {
|
||||
/**
|
||||
* Prepares for recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param config Recording parameters.
|
||||
*/
|
||||
prepare(config: AudioRecorderConfig): void;
|
||||
|
||||
/**
|
||||
* Starts audio recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
start(): void;
|
||||
|
||||
/**
|
||||
* Pauses audio recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
pause(): void;
|
||||
|
||||
/**
|
||||
* Resumes audio recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
resume(): void;
|
||||
|
||||
/**
|
||||
* Stops audio recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
stop(): void;
|
||||
|
||||
/**
|
||||
* Releases resources used for audio recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
release(): void;
|
||||
|
||||
/**
|
||||
* Resets audio recording.
|
||||
* Before resetting audio recording, you must call stop() to stop recording. After audio recording is reset, you must call prepare() to set the recording configurations for another recording.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
*/
|
||||
reset(): void;
|
||||
|
||||
/**
|
||||
* Listens for audio recording events.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param type Type of the audio recording event to listen for.
|
||||
* @param callback Callback used to listen for the audio recording event.
|
||||
*/
|
||||
on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset', callback: () => void): void;
|
||||
|
||||
/**
|
||||
* Listens for audio recording error events.
|
||||
* @devices phone, tablet, tv, wearable
|
||||
* @since 6
|
||||
* @SysCap SystemCapability.Multimedia.Media
|
||||
* @param type Type of the audio recording error event to listen for.
|
||||
* @param callback Callback used to listen for the audio recording error event.
|
||||
*/
|
||||
on(type: 'error', callback: ErrorCallback): void;
|
||||
}
|
||||
}
|
||||
export default media;
|
||||
|
||||
export default media;
|
Loading…
x
Reference in New Issue
Block a user