openharmony 鸿蒙 js-apis-systemSoundManager

2026-08-25 浏览 (1)

@ohos.multimedia.systemSoundManager (System Sound Management)

This module provides basic capabilities for managing system sound effects, including defining system sound effect types and obtaining system sound effect players.

Note:

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

Modules to Import

import { systemSoundManager } from '@kit.AudioKit';

SystemSoundType

Enumerates the system sound effect types.

Model constraint: This API can be used only in the stage model.

System capability: SystemCapability.Multimedia.SystemSound.Core

NameValueDescription
PHOTO_SHUTTER0Camera shutter sound.
VIDEO_RECORDING_BEGIN1Video recording start sound.
VIDEO_RECORDING_END2Video recording end sound.

systemSoundManager.createSystemSoundPlayer

createSystemSoundPlayer(): Promise<SystemSoundPlayer|null>

Creates a SystemSoundPlayer object. This API uses a promise to return the result.

System capability: SystemCapability.Multimedia.SystemSound.Core

Return value

TypeDescription
Promise<SystemSoundPlayer |null>Returns the SystemSoundPlayer object on success, null on failure.

Error codes

For details about the error codes, see Media Error Codes.

IDError Message
5400101No memory. Return by promise.

Example

import { BusinessError } from '@kit.BasicServicesKit';

let systemSoundPlayer: systemSoundManager.SystemSoundPlayer|null = null;

systemSoundManager.createSystemSoundPlayer().then((systemSoundPlayerInstance) => {
  console.info('Succeeded in creating the system sound player.');
  systemSoundPlayer = systemSoundPlayerInstance;
}).catch((err: BusinessError) => {
  console.error(`Failed to create the system sound player. Code: ${err.code}, message: ${err.message}`);
});

SystemSoundPlayer

type SystemSoundPlayer = _SystemSoundPlayer

Represents the system sound effect player object.

System capability: SystemCapability.Multimedia.SystemSound.Core

TypeDescription
_SystemSoundPlayerSystem sound effect player object.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-native-audiostreambuilder-h

openharmony 鸿蒙 capi-ohaudiosuite

openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer

openharmony 鸿蒙 arkts-apis-audio-i

openharmony 鸿蒙 capi-ohaudio

openharmony 鸿蒙 capi-ohmidi

openharmony 鸿蒙 arkts-apis-audio-AudioManager

openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams

openharmony 鸿蒙 capi-ohaudio-oh-audiostreaminfo

openharmony 鸿蒙 errorcode-ringtone

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