Home Web Front-end H5 Tutorial 克服 iOS HTML5 音频的局限

克服 iOS HTML5 音频的局限

May 10, 2018 pm 05:05 PM
h

       简介

       过去几年,开发人员一直都在制造完善的交互体验,努力使其可以在浏览器中正确运行。这样的站点通常需要使用浏览器插件 (Flash)。随着智能手机和平板电脑的推出,交互体验看似与新的小部件能够完美匹配。但是,由于移动设备的处理能力有限,浏览器插件不再是一种可行的开发平台。

       HTML5 已经添加了大量无需额外插件的使用的工具。W3C 的 HTML5 规范仍在开发之中,但是在规范开发过程中,浏览器已经开始提供支持。

       HTML5 音频是一个巨大的进步,它允许在浏览器中嵌入声音,尤其是在移动设备中,比如 iOS 的移动版 Safari 浏览器上。尽管 HTML5 音频是一个新特性,但已提供了 iOS 支持。根据流行的移动应用程序 Instapaper 的开发人员报导,2011 年 11 月,其 iOS 用户中有 98.8% 都在使用 iOS 4 或更高版本(请参阅 参考资料)。由于 HTML5 音频是在 iOS 3 中引入到移动版 Safari 中的,所以您可以放心,iOS 平台为 HTML5 音频提供了广泛的支持。

       在文本中,您将了解 HTML5 在桌面上和移动版 Safari 内的局限性,并尝试采用一些解决方案来创建交互的声音效果。本文涵盖的其他内容包括:不受支持的事件、audio sprite 以及如何使用 directCanvas 和 multiSound 加速 HTML5 游戏性能。

       有一点非常值得关注:对于 iOS 6,Apple 已经添加了对 Web Audio API(讨论如下)的支持,因此不再需要使用本文中所讨论的许多变通方法。不过,iOS 6 刚刚面世不到几周时间,所以 iOS 5 仍然是市场的主流。本文中所讨论的问题以及所提供的变通方式仍有效,应该在为移动版 Safari 开发声频时考虑使用它们。

       HTML5 音频的局限性

       在讨论移动版 Safari 中的局限性之前,有必要理解 HTML 音频在桌面上的局限性。HTML5 音频虽然很健壮,但有其局限性,这主要取决于它的实现。对于音乐播放器(点唱机播放器)或简单的声音效果,它很有效,但是对于声音密集的应用程序如游戏,它的表现不是很理想。

       格式支持

       不幸的是,并不是所有浏览器都支持相同的视频文件格式。如表 1 所示,目前有四种主要格式:MP3、OGG、WAV 和 AAC。

       为了涵盖所有浏览器,最好是让所有的视频流都具有 Ogg Vorbis 和 AAC 两种格式。

       为什么没有包括 MP3?MP3 在进行商业传播时需要支付繁重的版税。MP3 的授权要求对于所有超过 $100K 的数据收取 2% 的传播费。出于这个原因,我更倾向于使用 AAC 而非 MP3。AAC 也并非完全免版税的,但它对于免费传播的许可没有那么严格。AAC 还提供了更好的压缩,文件可以更小,它是 Web 领域的福音。

       Ogg Vorbis 之所以压倒性地获得了我的喜爱是因为它是开源的、无专利费并且免版税的。不过,只有 Firefox 支持它。

       清单 1 显示了跨浏览器兼容 HTML 标记。

       清单 1. 音频元素的 HTML 标记

       处理和效果

       在处理音频时,一个强大的特性是处理声音的能力。无论动态合成声音、处理声音效果、应用环境效果,还是进行基本的立体声平移,HTML5 音频缺乏所有这些处理能力。您加载的视频就是将要播放的视频。

       Web Audio API (Chrome) 和 Audio Data API (Firefox) 无需任何浏览器插件即可进行合成和动态处理音频的能力帮助您解决了特性缺失的问题。这两种 API 均在开发当中,仅在 Chrome 14+ 和 Firefox 4+ 中受支持。不幸的是,在实现方面这二者差异很大。目前有一些表现不错的库可用来使支持正规化,比如 audiolibjs(请参阅 参考资料)。Chrome 的 Web Audio API 就是通过 W3C 推广的标准。

       单音频层(多音的)

       要重复播放声音本身,必须实例化此声音的一个单独的音频对象。在标记和能够播放的音频之间存在 1:1 的对应。对于当前状态的 HTML5 音频,是无法分层的。其他平台,比如 Flash,可以分出一个单独的音频对象,无需创建一个新的音频对象。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How uniapp achieves rapid conversion between mini programs and H5 How uniapp achieves rapid conversion between mini programs and H5 Oct 20, 2023 pm 02:12 PM

How uniapp can achieve rapid conversion between mini programs and H5 requires specific code examples. In recent years, with the development of the mobile Internet and the popularity of smartphones, mini programs and H5 have become indispensable application forms. As a cross-platform development framework, uniapp can quickly realize the conversion between small programs and H5 based on a set of codes, greatly improving development efficiency. This article will introduce how uniapp can achieve rapid conversion between mini programs and H5, and give specific code examples. 1. Introduction to uniapp unia

Which version is more stable: win1121h2 or 22h2? Which version is more stable: win1121h2 or 22h2? Jan 04, 2024 am 08:53 AM

Comparing the two versions of win1121h2 and 22h2, the latter 22h2 is more stable, and 22h2 has more functions. Compared with the previous 21h2, many functions have been improved. Let’s take a look. Which one is more stable, win1121h2 or 22h2: Answer: 22h2 is more stable. Comparing win1121h2 and 22h2, 22h2 is more stable. 22h2 adds a lot of features, and the problems of 21h2 have also been improved in 22h2. 22h2 update feature: Applications folder in start menu. Adjustable fixed area in the Start menu. Drag and drop on the taskbar. Focus Assist is integrated with the Notification Center. New "Spotlight" wallpaper feature. new

Which one is better between win101909 and 21h2? Which one is better between win101909 and 21h2? Dec 26, 2023 pm 02:01 PM

Windows 101909 is currently considered one of the most stable and reliable versions. However, unfortunately, service support for this version has ended recently. 21H2 is a relatively stable version. In fact, from the actual situation, both are very good choices. Which one is better, win101909 or 21h2? Answer: 1909 is more stable, and 21h2 will be more secure. In the current environment, 1909 is still generally regarded as one of the most stable and reliable versions. However, the Win101909 version has officially stopped serving on May 11, 2021. WindowsServer21h2 is committed to providing more professional IT function support to the majority of users. 1. After actual testing by many users,

Which is the better choice: win1123h2 or 22h2? Which is the better choice: win1123h2 or 22h2? Dec 28, 2023 pm 03:09 PM

The 23h2 version and the 22h2 version in the Windows 11 system will be released in 2023 and 2022 respectively. Generally speaking, system updates are getting better and better. The editor also believes that the 23h2 version is better than the 22h2 version. Which one is better, win1123h2 or 22h2? Answer: win1123h2 is better. According to reports, win1123h2 is a cumulative version update from 22h2 to the next version, and they are all the same platform. This means that there are no compatibility issues between the two versions. It is recommended that you update them in time. The win1123h2 version brings us many practical features, such as the never-merge mode for taskbar window applications. There are more

Solve the problem of not getting Win11 23H2 update Solve the problem of not getting Win11 23H2 update Jan 14, 2024 pm 09:24 PM

Everyone wants to update the 23H2 version of Win11 recently, but a small number of users have not received the update push message yet. It may be that a process in the background update progress is stuck, and it will be fine after a while. What to do if the Win11 update fails to get 23H2. Method 1: Wait patiently. If the user checks the update status of the computer and finds that it is stuck, we can wait for a while and the system will continue to update. Method 2: Clear the updated cache. If the user has updated the system before and has not cleared the more detailed cache, it will affect the normal update of 23h2. You can manually clear it. Method three: Use image installation. It is recommended that you go to Microsoft's official website to download the image file of win1123h2, and then update the file.

How to update Win101909 to 20H2 How to update Win101909 to 20H2 Jan 05, 2024 pm 09:53 PM

Now the win101909 version has stopped updating, so many users want to update their system version but don't know how to do it. Users only need to enter the computer settings to find the corresponding upgrade. How to update win101909 to 20h21. Click the Computer Start button, then click "Settings" 2. Then click "Update and Security" 3. Find Check for Updates here 4. Then find the corresponding version and click Download and Install, then wait for the computer to update itself That's it.

Win11 22H2 fixes taskbar failure and restores taskbar drag and drop function Win11 22H2 fixes taskbar failure and restores taskbar drag and drop function Dec 24, 2023 am 11:05 AM

The taskbar is the cause of many problems in the Win11 system this time. Therefore, Microsoft is about to optimize and fix it this time. The following is a detailed Win11 taskbar fault that will be fixed in 22H2. The taskbar drag and drop function may return to the details. Come and learn together. Just give it a try. Win11 taskbar failure will be fixed in 22H2 and the taskbar drag and drop function may return: 1. There are many problems and bugs in the taskbar of win11 system that affect the use of many users. Fortunately, this time Microsoft will carry out relevant maintenance for the new system. Optimize and fix, and make the taskbar more reliable. 2. Before this, when the mouse stayed on the taskbar, pop-up windows would randomly appear in other locations. 3. Also, when the mouse stays on the icon in the corner of the taskbar, the speed is too fast.

Detailed explanation of Win10 20H2 preview version 19042.388 update Detailed explanation of Win10 20H2 preview version 19042.388 update Dec 26, 2023 pm 02:45 PM

Not long ago, Microsoft's internal testers released the 20h2 version of win10. Many friends don't know what content it has updated. It doesn't matter. I will give you a detailed introduction below, let's take a look. What’s updated in win1020h2: 1. Fixed an issue that prevented you from using PowerShell to change the system locale on ServerCore. 2. Fixed the distortion issue in the tutor game application when resizing or switching to full-screen window in window mode. 3. Fixed the issue that caused lsass.exe to fail to force restart the device. 4. Fixed the document problem of being unable to print graphics or files after installing the windows update patch released on June 8. 5

See all articles