msAudioCategory - Web APIs 编辑

Non-standard

This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

The msAudioCategory property of the HTML <audio> element, is a read/write proprietary attribute, specific to Internet Explorer and Microsoft Edge.

msAudioCategory specifies the purpose of the audio or video media, such as background audio or alerts.

Syntax

<audio controls="controls" msaudiocategory="BackgroundCapableMedia">  </audio>

The msAudioCategory property offers a variety of values that can enhance the behavior of your audio-aware app.

Note that you must set the msAudioCategory before setting the src property in code.

Value

Include a description of the property's value, including data type and what it represents.

ValueDescriptionBackground Capable?
AlertLooping or longer running alert sounds:
  • Alarms
  • Ring tones
  • Ringing notification
  • Sounds that need to attenuate existing audio
No
BackgroundCapableMediaFor audio that needs to continue playing in the background. Examples include the following local media playback scenarios:
  • Local playlist
  • Streaming radio
  • Streaming playlist
  • Music videos
  • Streaming audio/radio, YouTube, Netflix, etc.
Yes
CommunicationsFor streaming communication audio such as the following:
  • VOIP
  • Real time chat or other type of phone calls
Should not be used in non-real-time or non-communication scenarios, such as audio and/or video playback, as playback startup latency is affected. *Note that if msAudioCategory is set to Communications, msRealtime is automatically set to true.
Yes
ForeGroundOnlyMedia
  • Games or other sounds designed only to work in the foreground, but will mute existing background media sounds.
  • Game audio needed for the game experience (dancing games, music games)
  • Feature films (designed to pause when they go to the background)
No
GameEffects
  • Game sound effects designed to mix with existing audio
  • Characters talking
  • All non-music sounds
No
GameMediaBackground music played by a gameNo
SoundEffects
  • Game or other sound effects designed to mix with existing audio:
  • Characters talking
  • Beeps, dings, brief sounds
No
OtherDefault audio type, and recommended for all audio media that does not need to continue playing in the background.No

If msAudioDeviceType is not explicitly set, msAudioDeviceType will be set to Communications.

For hardware audio offload to be automatically applied, the audio category must be set to ForegroundOnlyMedia or BackgroundCapableMedia. Hardware audio offload optimizes audio rendering which can improve functionality and battery life.

Example

<audio msAudioCategory="BackgroundCapableMedia" controls="controls">
<source src="song.mp3"/>
</audio>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:86 次

字数:4716

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文