openharmony 鸿蒙 arkts-apis-avsession-t

2026-08-25 浏览 (1)

Types

NOTE

The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.

AVSessionType10+

type AVSessionType = 'audio'|'video'|'voice_call'|'video_call'

Defines the session type supported by the session.

You can use the strings listed in the following table.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.AVSession.Core

TypeDescription
'audio'Audio session.
'video'Video session.
'voice_call'11+Voice call.
'video_call'12+Video call.

AVCastControlCommandType10+

type AVCastControlCommandType = 'play'|'pause'|'stop'|'playNext'|'playPrevious'|'fastForward'|'rewind'| 'seek'|'setVolume'|'setSpeed'|'setLoopMode'|'toggleFavorite'|'toggleMute'

Defines the commands that can be sent by a cast controller.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.AVSession.AVCast

TypeDescription
'play'Play the media. No parameter is required.
'pause'Pause the playback. No parameter is required.
'stop'Stop the playback. No parameter is required.
'playNext'Play the next media asset. No parameter is required.
'playPrevious'Play the previous media asset. No parameter is required.
'fastForward'Fast-forward. No parameter is required.
'rewind'Rewind. No parameter is required.
'seek'Seek to a playback position. The corresponding parameter is of the number type.
'setVolume'Set the volume. The corresponding parameter is of the number type. You can use AVPlaybackState.maxVolume to obtain the maximum system volume.
'setSpeed'Set the playback speed. The corresponding parameter is media.PlaybackSpeed.
'setLoopMode'Set the loop mode. The corresponding parameter is LoopMode.
'toggleFavorite'Favorite the media asset. The corresponding parameter is AVMetadata.assetId.
'toggleMute'Set the muted status. No parameter is required.

ExtraInfo18+

type ExtraInfo = Record<string, Object>

Defines the custom media packet set by the provider.

System capability: SystemCapability.Multimedia.AVSession.Core

TypeDescription
Record<string, Object>key specifies the remote distributed event type. Currently, the following event types are supported:
AUDIO_GET_VOLUME: obtains the volume of the remote device.
AUDIO_GET_AVAILABLE_DEVICES: obtains all remote devices that can be connected.
AUDIO_GET_PREFERRED_OUTPUT_DEVICE_FOR_RENDERER_INFO: obtains the actual remote audio device.
The provider returns the corresponding media packet object based on the event type.

KeyRequestCallback12+

type KeyRequestCallback = (assetId: string, requestData: Uint8Array) => void

Defines the callback invoked for the media key request event.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Multimedia.AVSession.AVCast

Parameters

NameTypeMandatoryDescription
assetIdstringYesMedia asset ID.
requestDataUint8ArrayYesData carried in the media key request.

Example

let keyRequestCallback: avSession.KeyRequestCallback = async(assetId: string, requestData: Uint8Array) => {
  console.info(`Succeeded in keyRequestCallback. assetId: ${assetId}, requestData: ${requestData}`);
}

AVControlCommandType10+

type AVControlCommandType = 'play'|'pause'|'stop'|'playNext'|'playPrevious'|'fastForward'|'rewind'| 'seek'|'setSpeed'|'setLoopMode'|'toggleFavorite'|'playFromAssetId'|'playWithAssetId'|'answer'|'hangUp'|'toggleCallMute'|'setTargetLoopMode'

Defines the commands that can be sent to a session.

You can use the union of the strings listed in the following table.

System capability: SystemCapability.Multimedia.AVSession.Core

TypeDescription
'play'Play the media. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'pause'Pause the playback. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'stop'Stop the playback. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'playNext'Play the next media asset. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'playPrevious'Play the previous media asset. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'fastForward'Fast-forward. For details about the corresponding parameters, see SkipIntervals.
Atomic service API: This API can be used in atomic services since API version 12.
'rewind'Rewind. For details about the corresponding parameters, see SkipIntervals.
Atomic service API: This API can be used in atomic services since API version 12.
'seek'Seek to a playback position. The corresponding parameter is of the number type.
Atomic service API: This API can be used in atomic services since API version 12.
'setSpeed'Set the playback speed. The corresponding parameter is of the number type.
Atomic service API: This API can be used in atomic services since API version 12.
'setLoopMode'Set the loop mode. The corresponding parameter is LoopMode.
Atomic service API: This API can be used in atomic services since API version 12.
'setTargetLoopMode' 18+Set the target loop mode. The recommended parameter is LoopMode.
Atomic service API: This API can be used in atomic services since API version 18.
'toggleFavorite'Favorite the media asset. The corresponding parameter is AVMetadata.assetId.
Atomic service API: This API can be used in atomic services since API version 12.
'playFromAssetId' 11+Play the media asset with the specified asset ID.
Atomic service API: This API can be used in atomic services since API version 12.
'playWithAssetId' 20+Play the media asset with the specified asset ID. The corresponding parameter is AVMetadata.assetId.
The string length must be less than 40960 bytes.
Atomic service API: This API can be used in atomic services since API version 20.
'answer' 11+Answer a call. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'hangUp' 11+The call is disconnecting. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.
'toggleCallMute' 11+Set the mute status for a call. No parameter is required.
Atomic service API: This API can be used in atomic services since API version 12.

NoParamCallback22+

type NoParamCallback = () => void

Defines a callback function type that takes no parameters.

System capability: SystemCapability.Multimedia.AVSession.Core

TwoParamCallback22+

type TwoParamCallback<T, G> = (data1: T, data2: G) => void

Defines a callback type that takes two parameters.

System capability: SystemCapability.Multimedia.AVSession.Core

Parameters

NameTypeMandatoryDescription
data1TYesParameter 1.
data2GYesParameter 2.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 arkts-apis-avsession

openharmony 鸿蒙 arkts-apis-avsession-e

openharmony 鸿蒙 capi-native-avsession-h

openharmony 鸿蒙 errorcode-avsession

openharmony 鸿蒙 js-apis-inner-application-MediaControlExtensionContext-sys

openharmony 鸿蒙 arkts-apis-avsession-AVSession

openharmony 鸿蒙 ohos-multimedia-avcastpicker

openharmony 鸿蒙 arkts-apis-avsession-AVCastController

openharmony 鸿蒙 arkts-apis-avsession-AVCastPickerHelper

openharmony 鸿蒙 capi-native-avmetadata-h

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/WKCBNHKL