<audio>

You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!

HTML <audio> 요소는 문서에 소리 컨텐츠를 포함하기 위해 사용됩니다. 이것은 src 속성이나 <source> 요소를 통해 여러 오디오 소스를 포함할수 있으며, 브라우저는 그중에 가장 적합한 소스를 고를것입니다.

사용 문맥

  • 컨텐츠 범주 플로우 컨텐츠, 구문 컨텐츠, 포함된 컨텐츠.
    만약 controls 속성을 가지고 있다면: 대화형 컨텐츠, palpable 컨텐츠.
  • 허용된 컨텐츠If the element has a src attribute: zero or more <track> element, followed by transparent content that contains no media elements, that is no <audio> or <video>
    Else: zero or more <source> element, followed by zero or more <track> element, followed by transparent content that contains no media elements, that is no <audio> or <video>.
  • 태그 생략 None, both the starting and ending tag are mandatory.
  • 허용된 부모 요소 포함된 컨텐츠를 허용하는 모든 요소
  • DOM 인터페이스 HTMLAudioElement

속성

이 요소는 전역 속성만을 포함합니다.

autoplay
Boolean 속성; if specified (even if the value is "false"!), the audio will automatically begin to play back as soon as it can do so without stopping to finish loading the data.
autobuffer 안씀 Gecko 2.0
Boolean 속성; if specified, the audio will automatically begin being downloaded, even if not set to automatically play. This continues until the media cache is full, or the entire audio file has been downloaded, whichever comes first. This should only be used when it is expected that the user will choose to play the audio; for example, if the user has navigated to a page using a "Play this audio" link. This attribute was removed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) in favor of the preload attribute.
buffered
An attribute you can read to determine which time ranges of the media have been buffered. This attribute contains a TimeRanges object.
controls
If this attribute is present, the browser will offer controls to allow the user to control audio playback, including volume, seeking, and pause/resume playback.
loop
A Boolean attribute; if specified, we will, upon reaching the end of the audio, automatically seek back to the start.
mozCurrentSampleOffset
The offset, specified as the number of samples since the beginning of the audio stream, at which the audio is currently playing.
muted
A Boolean attribute which indicates whether the audio will be initially silenced. Its default value is false, meaning that the audio will be played.
played
A TimeRanges object indicating all the ranges of the audio that have been played.
preload
This enumerated attribute is intended to provide a hint to the browser about what the author thinks will lead to the best user experience. It may have one of the following values:
  • none: hints that either the author thinks that the user won't need to consult that audio or that the server wants to minimize its traffic; in others terms this hint indicates that the audio should not be cached;
  • metadata: hints that though the author thinks that the user won't need to consult that audio, fetching the metadata (e.g. length) is reasonable;
  • auto: hints that the user needs have priority; in others terms this hint indicated that, if needed, the whole audio could be downloaded, even if the user is not expected to use it;
  • the empty string: which is a synonym of the auto value.

If not set, its default value is browser-defined (i.e. each browser can choose its own default value), though the spec advises it to be set to metadata.

사용 참고:
  • The autoplay attribute has precedence over this one as if one wants to automatically play a audio, the browser will obviously need to download it. Setting both the autoplay and the preload attributes is allowed by the specification.
  • The browser is not forced by the specification to follow the value of this attribute; it is a mere hint.
src
포함될 오디오의 URL. This is subject to HTTP access controls. This is optional; you may instead use the <source> element within the audio block to specify the audio to embed.
volume
The playback volume of any audio portions, in the range 0.0 (silent) to 1.0 (loudest).

Time offsets are specified as float values indicating the number of seconds to offset.

Note: The time offset value definition has not yet been completed in the HTML5 specification and is subject to change.

이벤트

audio 요소는 events를 발생시킬수 있습니다.

예제

기본적인 사용법

<!-- Simple audio playback -->
<audio src="http://developer.mozilla.org/@api/deki/files/2926/=AudioTest_(1).ogg" autoplay>
  Your browser does not support the <code>audio</code> element.
</audio>

<!-- Audio playback with captions -->
<audio src="foo.ogg">
  <track kind="captions" src="foo.en.vtt" srclang="en" label="English">
  <track kind="captions" src="foo.sv.vtt" srclang="sv" label="Svenska">
</audio> 

source 요소와 함께 사용한 audio 요소

<audio controls="controls">
  Your browser does not support the <code>audio</code> element.
  <source src="foo.wav" type="audio/wav">
</audio>

명세

명세 상태 주석
HTML Living Standard
The definition of '<audio>' in that specification.
Living Standard  
HTML5
The definition of '<audio>' in that specification.
Recommendation  

브라우저 호환성

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
audioChrome Full support 3Edge Full support YesFirefox Full support 3.5
Notes
Full support 3.5
Notes
Notes For Firefox to play audio, the server must serve the file using the correct MIME type.
IE Full support 9Opera Full support 10.5Safari Full support 3.1WebView Android Full support 3Chrome Android Full support 18Firefox Android Full support 4
Notes
Full support 4
Notes
Notes For Firefox to play audio, the server must serve the file using the correct MIME type.
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0
autoplayChrome Full support 3Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 10.5Safari Full support 3.1WebView Android Full support 3Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0
bufferedChrome ? Edge Full support YesFirefox Full support 4IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?
controlsChrome Full support 3Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 10.5Safari Full support 3.1WebView Android Full support 3Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0
loopChrome Full support 3Edge Full support YesFirefox Full support 11IE Full support 9Opera Full support 10.5Safari Full support 3.1WebView Android Full support 3Chrome Android Full support 18Firefox Android Full support 14Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0
mozcurrentsampleoffset
Non-standard
Chrome No support NoEdge No support NoFirefox Full support 3.5IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android No support NoFirefox Android Full support 4Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No
mutedChrome ? Edge Full support YesFirefox Full support 11IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android Full support 14Opera Android ? Safari iOS ? Samsung Internet Android ?
playedChrome Full support 49Edge Full support 14Firefox Full support 15IE Full support 11Opera Full support 46Safari Full support 9.1WebView Android Full support 49Chrome Android Full support 49Firefox Android Full support 15Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 5.0
preloadChrome Full support 3
Notes
Full support 3
Notes
Notes Defaults to metadata in Chrome 64.
Edge Full support YesFirefox Full support 4
Full support 4
No support 3.5 — 4
Alternate Name
Alternate Name Uses the non-standard name: autobuffer
IE Full support 9Opera Full support 15
Notes
Full support 15
Notes
Notes Defaults to metadata in Opera 51.
No support 10.5 — 15
Alternate Name
Alternate Name Uses the non-standard name: autobuffer
Safari Full support 3.1WebView Android Full support 3
Notes
Full support 3
Notes
Notes Defaults to metadata in Chrome 64.
Chrome Android Full support 18
Notes
Full support 18
Notes
Notes Defaults to metadata in Chrome 64.
Firefox Android Full support 4Opera Android Full support 14
Notes
Full support 14
Notes
Notes Defaults to metadata in Opera 51.
No support ? — 14
Alternate Name
Alternate Name Uses the non-standard name: autobuffer
Safari iOS Full support YesSamsung Internet Android Full support 1.0
Notes
Full support 1.0
Notes
Notes Defaults to metadata in Samsung Internet 9.0.
srcChrome Full support 3Edge Full support YesFirefox Full support 3.5IE Full support 9Opera Full support 10.5Safari Full support 3.1WebView Android Full support 3Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 1.0
volumeChrome ? Edge Full support YesFirefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android ? Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
See implementation notes.
See implementation notes.
Uses a non-standard name.
Uses a non-standard name.

같이 보기