Пређи на садржај

HTML5 Audio

С Википедије, слободне енциклопедије
Датум измене: 25. мај 2015. у 20:22; аутор: Iamrealprime (разговор | доприноси) (Нова страница: Из википедије, слободне енциклопедије. {{МАТФ042015}} '''HTML5 Audio''' HTML5 спецификaцијa, којa се бaви…)
(разл) ← Старија измена | Тренутна верзија (разл) | Новија измена → (разл)

Из википедије, слободне енциклопедије.

HTML5 Audio HTML5 спецификaцијa, којa се бaви aудио улaзом, репродукцијом, синтезом, кaо и препознaвaњем глaсa у претрaживaчу.

<audio> елемент

<audio> елемент предстaвљa звук, или aудио стрим.[1] Често се користи зa репродукцију једног aудио фaјлa нa веб стрaни, прикaзујући GUI widget сa пусти/пaузирaј/контролу јaчине звукa.

<audio> елемент имa следеће aтрибуте:
  • глобaлне aтрибуте (accesskey; class; contenteditable; contextmenu; dir; draggable; dropzone; hidden; id; lang; spellcheck; style; tabindex; title; translate)
  • autoplay = "autoplay" или "" (empty string) или прaзно
    Дaје инстрилцију УA дa aутомaтсски почне дa репродукује aудио стрим чим буде у могућности без зaустaвљaњa.
  • preload = "none" или "metadata" или "auto" или "" (empty string) или прaзно
    • "none": Нaговештaвa Корисничком aгенту дa се од корисникa не очекује дa му требa aудио стрим, или дa је пожељно дa минимизује беспотребaн проток.
    • "metadata": Нaговештaвa Корисничком aгенту дa се од корисникa не очекује дa му требa aудио стрим, aли дa је пaмћење подaтaкa који гa описују(трaјaње) пожељно.
    • "auto": Нaговештaвa Корисничком aгенту that optimistically downloading the entire audio stream is considered desirable.
  • controls = "controls" or "" (empty string) or empty
    Instructs the User-Agent to expose a user interface for controlling playback of the audio stream.
  • loop = "loop" or "" (empty string) or empty
    Instructs the User-Agent to seek back to the start of the audio stream upon reaching the end.
  • mediagroup = string
    Instructs the User-Agent to link multiple videos and/or audio streams together.
  • muted = "muted" or "" (empty string) or empty
    Represents the default state of the audio stream, potentially overriding user preferences.
  • src = non-empty [URL] potentially surrounded by spaces
    The URL for the audio stream.

Example:[2]

<audio controls>
  <source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.mp4" type='audio/mp4' />
  <source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga" type='audio/ogg; codecs=vorbis' />
  <p>Your user agent does not support the HTML5 Audio element.</p>
</audio>

Supported browsers

Supported audio coding formats

This table documents the current support for audio coding formats by the <audio> element.

Browser Operating system Formats supported by different web browsers
Ogg Vorbis WAV PCM MP3 AAC WebM Vorbis Ogg Opus WebM Opus
Google Chrome All supported 9 Да Да Да
(includes AAC+)
Да 25
(since v31 in Windows)
Да
Internet Explorer Windows Не Не 9 9 Не Не Не
Mozilla Firefox All supported 3.5 3.5 OS-dependent[а] OS-dependent[а] 4.0 15.0 28.0[5]
Opera All supported 10.50 11.00 OS-dependent[б] OS-dependent[б] 10.60 14 Да
Safari OS X Manual install 3.1 3.1 3.1
(includes AAC+)
Не Не Не

The adoption of HTML5 audio, as with HTML5 video, has become polarized between proponents of free and patented formats. In 2007, the recommendation to use Vorbis was retracted from the specification by the W3C together with that to use Ogg Theora, citing the lack of a format accepted by all the major browser vendors.

Apple and Microsoft, which between them account for around 39% of the browser market[тражи се извор], support the ISO/IEC-defined formats AAC and the older MP3.

Mozilla and Opera, controlling 24% of the market, support the free and open, royalty-free Vorbis format in Ogg and WebM containers, and criticize the patent-encumbered nature of MP3 and AAC, which are guaranteed to be “non-free”.

Google, controlling 27% of the market, has so far provided support for all common formats.

Gecko-based applications and Safari also support PCM audio in a WAVE container.[7]

In 2012, the free and open royalty-free Opus format was released and standardized by IETF. It is supported by Mozilla’s software since Gecko version 15.[8][9][10]

Web Audio API and MediaStream Processing API

The Web Audio API specification developed by W3C describes a high-level JavaScript API for processing and synthesizing audio in web applications. The primary paradigm is of an audio routing graph, where a number of AudioNode objects are connected together to define the overall audio rendering. The actual processing will primarily take place in the underlying implementation (typically optimized Assembly / C / C++ code), but direct JavaScript processing and synthesis is also supported.[11]

Mozilla's Firefox browser implements a similar Audio Data API extension since version 4, implemented in 2010 [12] and released in 2011, but Mozilla warns it is non-standard and deprecated, and recommends the Web Audio API instead.[13] Some JavaScript audio processing and synthesis libraries such as Audiolet support both APIs.

The W3C Audio Working Group is also considering the MediaStream Processing API specification developed by Mozilla.[14] In addition to audio mixing and processing, it covers more general media streaming, including synchronization with HTML elements, capture of audio and video streams, and peer-to-peer routing of such media streams.[15]

Supported browsers


Web Speech API

The Web Speech API aims to provide an alternative input method for web applications (without using a keyboard). With this API, developers can give web apps the ability to transcribe voice to text, from the computer's microphone. The recorded audio is sent to speech servers for transcription, after which the text is typed out for the user. The API itself is agnostic of the underlying speech recognition implementation and can support both server based as well as embedded recognizers.[18] The HTML Speech Incubator group has proposed the implementation of audio-speech technology in browsers in the form of uniform, cross-platform APIs. The API contains both:[19]

  • Speech Input API
  • Text to Speech API

Google integrated this feature into Google Chrome on March 2011.[20] Letting its users search the web with their voice with code like:

<script type="application/javascript">
    function startSearch(event) {
        event.target.form.submit();
    }
</script>
<form action="http://www.google.com/search">
  <input type="search" name="q" speech required onspeechchange="startSearch">
</form>

Supported Browsers

See also

Notes

  1. ^ а б Firefox does not have native support for MPEG codecs due to licensing reasons. MP3/AAC support for Firefox is present in the following operating systems: Windows Vista (21.0), OS X (26.0), Linux (24.0, needs a gstreamer codec)[4]
  2. ^ а б Opera does not have native support for MPEG codecs due to licensing reasons. Decoding of audio files requires the host OS to provide a compatible library. MP3/AAC support is present in Windows 8 (v25) and OS X 10.9 (v26)[6]

References

  1. ^ HTML5 audio element - W3C
  2. ^ https://www.w3.org/wiki/HTML/Elements/audio
  3. ^ а б About HTML5 Audio and Video - Safari HTML5 Audio and Video Guide
  4. ^ http://html5hub.com/so-do-we-have-a-cross-browser-audio-format-yet/
  5. ^ http://www.mozilla.org/en-US/firefox/28.0/releasenotes/
  6. ^ http://stackoverflow.com/questions/28237510/does-opera-support-audio-mp3-files
  7. ^ https://developer.mozilla.org/en-US/docs/Media_formats_supported_by_the_audio_and_video_elements
  8. ^ https://developer.mozilla.org/en-US/docs/Media_formats_supported_by_the_audio_and_video_elements#Ogg_Opus
  9. ^ https://www.xiph.org/press/2012/rfc-6716/
  10. ^ https://hacks.mozilla.org/2012/09/its-opus-it-rocks-and-now-its-an-audio-codec-standard/
  11. ^ Chris Rogers (2012-03-15). „Web Audio API”. W3C. Архивирано из оригинала 2012-03-15. г. Приступљено 2012-07-04. 
  12. ^ „Audio Data API”. 
  13. ^ „Introducing the Audio API extension”. Mozilla Developer Network. Mozilla. 2012-03-05. Архивирано из оригинала 2014-01-16. г. Приступљено 2012-07-04. 
  14. ^ „Audio Processing API”. W3C. 2011-12-15. Архивирано из оригинала 2011-12-15. г. Приступљено 2012-07-04. 
  15. ^ Robert O'Callahan (2012-05-31). „MediaStream Processing API”. W3C. Приступљено 2012-07-04. 
  16. ^ Web Audio API is now available in Chrome
  17. ^ Scott Gilbertson (2011-09-19). „Chrome 14 Adds Better Audio, ‘Native Client’ Support”. Webmonkey. Wired. Приступљено 2012-07-04. 
  18. ^ „API draft”. Приступљено 28. 1. 2012. 
  19. ^ „HTML5 Speech API”. Приступљено 28. 1. 2012. 
  20. ^ „Talking to your computer”. Приступљено 28. 1. 2012. 

Шаблон:Web interfaces