openharmony 鸿蒙 js-apis-systemSoundManager

2026-08-25 浏览 (1)

@ohos.multimedia.systemSoundManager (系统声音管理)

系统声音管理提供管理系统声音的基础能力,包括对系统音效类型的定义、获取系统音效播放器等。

说明:

本模块首批接口从API version 23开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

导入模块

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

SystemSoundType

枚举,表示系统音效类型。

模型约束:此接口仅可在Stage模型下使用。

系统能力: SystemCapability.Multimedia.SystemSound.Core

名称说明
PHOTO_SHUTTER0拍照音效。
VIDEO_RECORDING_BEGIN1视频录制开始音效。
VIDEO_RECORDING_END2视频录制结束音效。

systemSoundManager.createSystemSoundPlayer

createSystemSoundPlayer(): Promise<SystemSoundPlayer|null>

创建系统音效播放器对象。使用Promise异步回调。

系统能力: SystemCapability.Multimedia.SystemSound.Core

返回值:

类型说明
Promise<SystemSoundPlayer |null>成功返回系统音效播放器对象,失败返回null。

错误码:

以下错误码的详细介绍请参见Media错误码

错误码ID错误信息
5400101No memory. Return by promise.

示例:

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

系统音效播放器对象。

系统能力: SystemCapability.Multimedia.SystemSound.Core

类型说明
_SystemSoundPlayer系统音效播放器对象。

你可能感兴趣的鸿蒙文章

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 鸿蒙 capi-ohmidi-oh-midideviceinformation

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