in the DOM.
- var progressBar = document.getElementById("percent-loaded");`
+// Find the progress bar
in the DOM.
+var progressBar = document.getElementById("percent-loaded");
-`// Set its ARIA roles and states,
-// so that assistive technologies know what kind of widget it is.`
+// Set its ARIA roles and states,
+// so that assistive technologies know what kind of widget it is.`;
progressBar.setAttribute("role", "progressbar");
progressBar.setAttribute("aria-valuemin", 0);
progressBar.setAttribute("aria-valuemax", 100);
@@ -32,7 +35,7 @@ progressBar.setAttribute("aria-valuemax", 100);
// Create a function that can be called at any time to update
// the value of the progress bar.
function updateProgress(percentComplete) {
-progressBar.setAttribute("aria-valuenow", percentComplete);
+ progressBar.setAttribute("aria-valuenow", percentComplete);
}
```
diff --git a/files/ko/web/guide/audio_and_video_delivery/adding_captions_and_subtitles_to_html5_video/index.md b/files/ko/web/guide/audio_and_video_delivery/adding_captions_and_subtitles_to_html5_video/index.md
index b3a92ec89fd4ab..d2338b3faecd32 100644
--- a/files/ko/web/guide/audio_and_video_delivery/adding_captions_and_subtitles_to_html5_video/index.md
+++ b/files/ko/web/guide/audio_and_video_delivery/adding_captions_and_subtitles_to_html5_video/index.md
@@ -46,11 +46,24 @@ HTML5에서는 {{ htmlelement("track") }}를 이용하여 자막을 특정해서
```html
-
-
-
-
-
+
+
+
+
+
```
@@ -66,18 +79,32 @@ In addition to adding the `
` elements, we have also added a new button to
```js
-
Play/Pause
-
Stop
-
-
Mute/Unmute
-
Vol+
-
Vol-
-
Fullscreen
-
CC
+
+ Play/Pause
+
+
+ Stop
+
+
+
+ Mute/Unmute
+
+
+ Vol+
+
+
+ Vol-
+
+
+ Fullscreen
+
+
+ CC
+
```
@@ -89,14 +116,14 @@ No image is used for the captions button, so it is simply styled as:
```css
.controls button[data-state="subtitles"] {
- height:85%;
- text-indent:0;
- font-size:16px;
- font-size:1rem;
- font-weight:bold;
- color:#666;
- background:#000;
- border-radius:2px;
+ height: 85%;
+ text-indent: 0;
+ font-size: 16px;
+ font-size: 1rem;
+ font-weight: bold;
+ color: #666;
+ background: #000;
+ border-radius: 2px;
}
```
@@ -113,14 +140,14 @@ Browsers do vary as to what they support, so we will be attempting to bring a mo
As with all the other buttons, one of the first things we need to do is store a handle to the subtitles' button:
```js
-var subtitles = document.getElementById('subtitles');
+var subtitles = document.getElementById("subtitles");
```
We also initially turn off all subtitles, in case the browser turns any of them on by default:
```js
for (var i = 0; i < video.textTracks.length; i++) {
- video.textTracks[i].mode = 'hidden';
+ video.textTracks[i].mode = "hidden";
}
```
@@ -139,14 +166,20 @@ All we need to do is to go through the video's `textTracks`, reading their prope
```js
var subtitlesMenu;
if (video.textTracks) {
- var df = document.createDocumentFragment();
- var subtitlesMenu = df.appendChild(document.createElement('ul'));
- subtitlesMenu.className = 'subtitles-menu';
- subtitlesMenu.appendChild(createMenuItem('subtitles-off', '', 'Off'));
- for (var i = 0; i < video.textTracks.length; i++) {
- subtitlesMenu.appendChild(createMenuItem('subtitles-' + video.textTracks[i].language, video.textTracks[i].language, video.textTracks[i].label));
- }
- videoContainer.appendChild(subtitlesMenu);
+ var df = document.createDocumentFragment();
+ var subtitlesMenu = df.appendChild(document.createElement("ul"));
+ subtitlesMenu.className = "subtitles-menu";
+ subtitlesMenu.appendChild(createMenuItem("subtitles-off", "", "Off"));
+ for (var i = 0; i < video.textTracks.length; i++) {
+ subtitlesMenu.appendChild(
+ createMenuItem(
+ "subtitles-" + video.textTracks[i].language,
+ video.textTracks[i].language,
+ video.textTracks[i].label,
+ ),
+ );
+ }
+ videoContainer.appendChild(subtitlesMenu);
}
```
@@ -156,37 +189,36 @@ The creation of each list item and button is done by the `createMenuItem()` func
```js
var subtitleMenuButtons = [];
-var createMenuItem = function(id, lang, label) {
- var listItem = document.createElement('li');
- var button = listItem.appendChild(document.createElement('button'));
- button.setAttribute('id', id);
- button.className = 'subtitles-button';
- if (lang.length > 0) button.setAttribute('lang', lang);
- button.value = label;
- button.setAttribute('data-state', 'inactive');
- button.appendChild(document.createTextNode(label));
- button.addEventListener('click', function(e) {
- // Set all buttons to inactive
- subtitleMenuButtons.map(function(v, i, a) {
- subtitleMenuButtons[i].setAttribute('data-state', 'inactive');
- });
- // Find the language to activate
- var lang = this.getAttribute('lang');
- for (var i = 0; i < video.textTracks.length; i++) {
- // For the 'subtitles-off' button, the first condition will never match so all will subtitles be turned off
- if (video.textTracks[i].language == lang) {
- video.textTracks[i].mode = 'showing';
- this.setAttribute('data-state', 'active');
- }
- else {
- video.textTracks[i].mode = 'hidden';
- }
+var createMenuItem = function (id, lang, label) {
+ var listItem = document.createElement("li");
+ var button = listItem.appendChild(document.createElement("button"));
+ button.setAttribute("id", id);
+ button.className = "subtitles-button";
+ if (lang.length > 0) button.setAttribute("lang", lang);
+ button.value = label;
+ button.setAttribute("data-state", "inactive");
+ button.appendChild(document.createTextNode(label));
+ button.addEventListener("click", function (e) {
+ // Set all buttons to inactive
+ subtitleMenuButtons.map(function (v, i, a) {
+ subtitleMenuButtons[i].setAttribute("data-state", "inactive");
+ });
+ // Find the language to activate
+ var lang = this.getAttribute("lang");
+ for (var i = 0; i < video.textTracks.length; i++) {
+ // For the 'subtitles-off' button, the first condition will never match so all will subtitles be turned off
+ if (video.textTracks[i].language == lang) {
+ video.textTracks[i].mode = "showing";
+ this.setAttribute("data-state", "active");
+ } else {
+ video.textTracks[i].mode = "hidden";
}
- subtitlesMenu.style.display = 'none';
- });
- subtitleMenuButtons.push(button);
- return listItem;
-}
+ }
+ subtitlesMenu.style.display = "none";
+ });
+ subtitleMenuButtons.push(button);
+ return listItem;
+};
```
This function builds the required {{ htmlelement("li") }} and {{ htmlelement("button") }} elements, and returns them so they can be added to the subtitles menu list. It also sets up the required event listeners on the button to toggle the relevant subtitle set on or off. This is done by simply setting the required subtlte's `mode` attribute to `showing`, and setting the others to `hidden`.
@@ -196,10 +228,11 @@ Once the menu is built, it is then inserted into the DOM at the bottom of the vi
Initially the menu is hidden by default, so an event listener needs to be added to our subtitles button to toggle it:
```js
-subtitles.addEventListener('click', function(e) {
- if (subtitlesMenu) {
- subtitlesMenu.style.display = (subtitlesMenu.style.display == 'block' ? 'none' : 'block');
- }
+subtitles.addEventListener("click", function (e) {
+ if (subtitlesMenu) {
+ subtitlesMenu.style.display =
+ subtitlesMenu.style.display == "block" ? "none" : "block";
+ }
});
```
@@ -209,31 +242,31 @@ We also added some rudimentary styling for the newly created subtitles menu:
```css
.subtitles-menu {
- display:none;
- position:absolute;
- bottom:14.8%;
- right:20px;
- background:#666;
- list-style-type:none;
- margin:0;
- padding:0;
- width:100px;
- padding:10px;
+ display: none;
+ position: absolute;
+ bottom: 14.8%;
+ right: 20px;
+ background: #666;
+ list-style-type: none;
+ margin: 0;
+ padding: 0;
+ width: 100px;
+ padding: 10px;
}
.subtitles-menu li {
- padding:0;
- text-align:center;
+ padding: 0;
+ text-align: center;
}
.subtitles-menu li button {
- border:none;
- background:#000;
- color:#fff;
- cursor:pointer;
- width:90%;
- padding:2px 5px;
- border-radius:2px;
+ border: none;
+ background: #000;
+ color: #fff;
+ cursor: pointer;
+ width: 90%;
+ padding: 2px 5px;
+ border-radius: 2px;
}
```
@@ -257,7 +290,7 @@ For example, to change the text colour of the text track cues you can write:
```css
::cue {
- color:#ccc;
+ color: #ccc;
}
```
@@ -272,9 +305,9 @@ If the WebVTT file uses [voice spans](http://dev.w3.org/html5/webvtt/#dfn-webvtt
Then this specific 'voice' will be stylable like so:
```css
-::cue(v[voice='Test']) {
- color:#fff;
- background:#0095dd;
+::cue(v[voice="Test"]) {
+ color: #fff;
+ background: #0095dd;
}
```
diff --git a/files/ko/web/guide/audio_and_video_delivery/index.md b/files/ko/web/guide/audio_and_video_delivery/index.md
index 18fc9345425efb..ef8361f78a1df6 100644
--- a/files/ko/web/guide/audio_and_video_delivery/index.md
+++ b/files/ko/web/guide/audio_and_video_delivery/index.md
@@ -23,10 +23,10 @@ To deliver video and audio, the general workflow is usually something like this:
```html
-
+
-
+
download audio
@@ -42,15 +42,25 @@ For further info see [Cross Browser Audio Basics (HTML5 Audio In Detail)](/en-US
### HTML Video
```html
-
-
+
+
-
+
-
-
+
+
download video
@@ -69,13 +79,19 @@ You can create a more comprehensive Fallback using Flash. [Using flashmediaeleme
```html
-
-
+
+
download audio
-
+
-
+
```
@@ -87,12 +103,12 @@ The process is very similar with video — just remember to set `isvideo=true` i
### JavaScript Audio
```js
-var myAudio = document.createElement('audio');
+var myAudio = document.createElement("audio");
-if (myAudio.canPlayType('audio/mpeg')) {
- myAudio.setAttribute('src','audiofile.mp3');
-} else if (myAudio.canPlayType('audio/ogg')) {
- myAudio.setAttribute('src','audiofile.ogg');
+if (myAudio.canPlayType("audio/mpeg")) {
+ myAudio.setAttribute("src", "audiofile.mp3");
+} else if (myAudio.canPlayType("audio/ogg")) {
+ myAudio.setAttribute("src", "audiofile.ogg");
}
myAudio.currentTime = 5;
@@ -114,12 +130,12 @@ It's also possible to feed an {{ htmlelement("audio") }} element a base64 encode
### JavaScript Video
```js
-var myVideo = document.createElement('video');
+var myVideo = document.createElement("video");
-if (myVideo.canPlayType('video/mp4')) {
- myVideo.setAttribute('src','videofile.mp4');
-} else if (myVideo.canPlayType('video/webm')) {
- myVideo.setAttribute('src','videofile.webm');
+if (myVideo.canPlayType("video/mp4")) {
+ myVideo.setAttribute("src", "videofile.mp4");
+} else if (myVideo.canPlayType("video/webm")) {
+ myVideo.setAttribute("src", "videofile.webm");
}
myVideo.width = 480;
@@ -131,31 +147,34 @@ We set the source of the video depending on the type of video file the browser s
## Web Audio API
```js
- var context;
- var request;
- var source;
-
- try {
- context = new AudioContext();
- request = new XMLHttpRequest();
- request.open("GET","http://jplayer.org/audio/mp3/RioMez-01-Sleep_together.mp3",true);
- request.responseType = "arraybuffer";
-
- request.onload = function() {
- context.decodeAudioData(request.response, function(buffer) {
- source = context.createBufferSource();
- source.buffer = buffer;
- source.connect(context.destination);
- // auto play
- source.start(0); // start was previously noteOn
- });
- };
-
- request.send();
-
- } catch(e) {
- alert('web audio api not supported');
- }
+var context;
+var request;
+var source;
+
+try {
+ context = new AudioContext();
+ request = new XMLHttpRequest();
+ request.open(
+ "GET",
+ "http://jplayer.org/audio/mp3/RioMez-01-Sleep_together.mp3",
+ true,
+ );
+ request.responseType = "arraybuffer";
+
+ request.onload = function () {
+ context.decodeAudioData(request.response, function (buffer) {
+ source = context.createBufferSource();
+ source.buffer = buffer;
+ source.connect(context.destination);
+ // auto play
+ source.start(0); // start was previously noteOn
+ });
+ };
+
+ request.send();
+} catch (e) {
+ alert("web audio api not supported");
+}
```
In this example we retrieve an MP3 file via XHR, load it into a source and play it ([Try it for yourself](http://jsbin.com/facutone/1/edit?js)). Find more about Web Audio API basics in [Using the Web Audio API](/ko/docs/Web/API/Web_Audio_API/Using_Web_Audio_API).
@@ -174,17 +193,20 @@ Next, if supported connect the webcam source to the video element:
```js
if (navigator.mediaDevices) {
- navigator.mediaDevices.getUserMedia({ video: true, audio: false })
- .then(function onSuccess(stream) {
- var video = document.getElementById('webcam');
- video.autoplay = true;
- video.srcObject = stream;
- })
- .catch(function onError() {
- alert('There has been a problem retreiving the streams - are you running on file:/// or did you disallow access?');
- });
+ navigator.mediaDevices
+ .getUserMedia({ video: true, audio: false })
+ .then(function onSuccess(stream) {
+ var video = document.getElementById("webcam");
+ video.autoplay = true;
+ video.srcObject = stream;
+ })
+ .catch(function onError() {
+ alert(
+ "There has been a problem retreiving the streams - are you running on file:/// or did you disallow access?",
+ );
+ });
} else {
- alert('getUserMedia is not supported in this browser.');
+ alert("getUserMedia is not supported in this browser.");
}
```
@@ -197,23 +219,24 @@ New standards are being rolled out to allow your browser to grab media from your
The main mechanism is outlined below:
```js
-navigator.mediaDevices.getUserMedia({audio:true})
+navigator.mediaDevices
+ .getUserMedia({ audio: true })
.then(function onSuccess(stream) {
var recorder = new MediaRecorder(stream);
var data = [];
- recorder.ondataavailable = function(e) {
+ recorder.ondataavailable = function (e) {
data.push(e.data);
};
recorder.start();
- recorder.onerror = function(e) {
+ recorder.onerror = function (e) {
throw e.error || new Error(e.name); // e.name is FF non-spec
- }
- recorder.onstop = function(e) {
- var audio = document.createElement('audio');
+ };
+ recorder.onstop = function (e) {
+ var audio = document.createElement("audio");
audio.src = window.URL.createObjectURL(new Blob(data));
- }
- setTimeout(function() {
+ };
+ setTimeout(function () {
rec.stop();
}, 5000);
})
@@ -259,17 +282,18 @@ You may detect click, touch and/or keyboard events to trigger actions such as pl
A quick example — first set up your audio and custom controls in HTML:
```html
-
- play
+
+play
```
add a bit of JavaScript to detect events to play and pause the audio:
```js
-window.onload = function() {
-
- var myAudio = document.getElementById('my-audio');
- var myControl = document.getElementById('my-control');
+window.onload = function () {
+ var myAudio = document.getElementById("my-audio");
+ var myControl = document.getElementById("my-control");
function switchState() {
if (myAudio.paused == true) {
@@ -282,17 +306,22 @@ window.onload = function() {
}
function checkKey(e) {
- if (e.keycode == 32 ) { //spacebar
+ if (e.keycode == 32) {
+ //spacebar
switchState();
}
}
- myControl.addEventListener('click', function() {
- switchState();
- }, false);
+ myControl.addEventListener(
+ "click",
+ function () {
+ switchState();
+ },
+ false,
+ );
- window.addEventListener( "keypress", checkKey, false );
-}
+ window.addEventListener("keypress", checkKey, false);
+};
```
You can [try this example out here](http://jsbin.com/jujeladu/2/edit). For more information, see [Creating your own custom audio player](/en-US/Apps/Build/Manipulating_media/Cross-browser_audio_basics#Creating_your_own_custom_audio_player).
@@ -322,11 +351,11 @@ Media elements provide support for moving the current playback position to speci
You can use the element's `seekable` property to determine the ranges of the media that are currently available for seeking to. This returns a {{ domxref("TimeRanges") }} object listing the ranges of times that you can seek to.
```js
-var mediaElement = document.querySelector('#mediaElementID');
-mediaElement.seekable.start(0); // Returns the starting time (in seconds)
-mediaElement.seekable.end(0); // Returns the ending time (in seconds)
+var mediaElement = document.querySelector("#mediaElementID");
+mediaElement.seekable.start(0); // Returns the starting time (in seconds)
+mediaElement.seekable.end(0); // Returns the ending time (in seconds)
mediaElement.currentTime = 122; // Seek to 122 seconds
-mediaElement.played.end(0); // Returns the number of seconds the browser has played
+mediaElement.played.end(0); // Returns the number of seconds the browser has played
```
### Specifying playback range
@@ -447,14 +476,18 @@ Another way to show the fallback content of a video, when none of the sources co
```
```js
-var v = document.querySelector('video'),
- sources = v.querySelectorAll('source'),
- lastsource = sources[sources.length-1];
-lastsource.addEventListener('error', function(ev) {
- var d = document.createElement('div');
- d.innerHTML = v.innerHTML;
- v.parentNode.replaceChild(d, v);
-}, false);
+var v = document.querySelector("video"),
+ sources = v.querySelectorAll("source"),
+ lastsource = sources[sources.length - 1];
+lastsource.addEventListener(
+ "error",
+ function (ev) {
+ var d = document.createElement("div");
+ d.innerHTML = v.innerHTML;
+ v.parentNode.replaceChild(d, v);
+ },
+ false,
+);
```
## Audio/Video JavaScript Libraries
diff --git a/files/ko/web/http/overview/index.md b/files/ko/web/http/overview/index.md
index bab50fd9fc0095..63d976904bc109 100644
--- a/files/ko/web/http/overview/index.md
+++ b/files/ko/web/http/overview/index.md
@@ -108,26 +108,26 @@ HTTP의 확장 가능한 특성은 수년 간에 걸쳐 웹의 점점 더 많은
1. TCP 연결을 엽니다. TCP 연결은 요청을 보내거나(혹은 여러 개의 요청) 응답을 받는데 사용됩니다. 클라이언트는 새 연결을 열거나, 기존 연결을 재사용하거나, 서버에 대한 여러 TCP 연결을 열 수 있습니다.
2. HTTP 메시지를 전송합니다. HTTP 메시지(HTTP/2 이전)는 인간이 읽을 수 있습니다. HTTP/2에서는 이런 간단한 메시지가 프레임 속으로 캡슐화되어 직접 읽는게 불가능하지만 원칙은 동일합니다.
- ```http
- GET / HTTP/1.1
- Host: developer.mozilla.org
- Accept-Language: fr
- ```
+ ```http
+ GET / HTTP/1.1
+ Host: developer.mozilla.org
+ Accept-Language: fr
+ ```
3. 서버에 의해 전송된 응답을 읽어들입니다
- ```http
- HTTP/1.1 200 OK
- Date: Sat, 09 Oct 2010 14:28:02 GMT
- Server: Apache
- Last-Modified: Tue, 01 Dec 2009 20:18:22 GMT
- ETag: "51142bc1-7449-479b075b2891b"
- Accept-Ranges: bytes
- Content-Length: 29769
- Content-Type: text/html
-
-