Skip to content

Commit 9238352

Browse files
fix: improvements from recordings 25.04.2025
1 parent d0a23da commit 9238352

File tree

8 files changed

+36
-6
lines changed

8 files changed

+36
-6
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4330,7 +4330,7 @@ function handleFile(event) {
43304330

43314331
[^115]CodeSandbox: File API.
43324332

4333-
[^115]:[CodeSandbox: File API](https://69c6jw.csb.app/), last access: October 6, 2024.
4333+
[^115]:[CodeSandbox: File API](https://69c6jw.csb.app/), last access: April 25, 2025.
43344334

43354335
- The code above demonstrates how to use the File API to read the contents of a file selected by the user.
43364336
- When a file is selected using the `<input type="file">` element, the `onchange` event is triggered, calling the `handleFile()` function.
@@ -4347,6 +4347,10 @@ navigator.mediaDevices.getUserMedia({ audio: true, video: true })
43474347
.then(function(stream) {
43484348
const videoElement = document.createElement("video");
43494349
videoElement.srcObject = stream;
4350+
videoElement.height = 240;
4351+
videoElement.width = 320;
4352+
videoElement.controls = true;
4353+
videoElement.muted = false;
43504354
document.body.appendChild(videoElement);
43514355
})
43524356
.catch(function(error) {
@@ -4359,7 +4363,7 @@ navigator.mediaDevices.getUserMedia({ audio: true, video: true })
43594363

43604364
[^116]CodeSandbox: WebRTC API.
43614365

4362-
[^116]:[CodeSandbox: WebRTC API](https://8kfdt8.csb.app/), last access: October 7, 2024.
4366+
[^116]:[CodeSandbox: WebRTC API](https://8kfdt8.csb.app/), last access: April 25, 2025.
43634367

43644368
- The code above demonstrates how to use the WebRTC API to access the user's audio and video devices and display a live video stream in the browser.
43654369
- The `getUserMedia()` method is called on the `mediaDevices` object to request access to the user's microphone and camera.
@@ -4370,14 +4374,14 @@ navigator.mediaDevices.getUserMedia({ audio: true, video: true })
43704374
The Media Capture and Streams API enables web applications to capture audio, video, and images from the user's device using the device's built-in camera and microphone. This API provides methods for accessing media devices, capturing media streams, and recording audio and video. It also allows for advanced features such as real-time audio and video processing and manipulation. The Media Capture and Streams API empowers developers to create rich multimedia experiences directly within the browser.
43714375

43724376
```html
4373-
<input type="file" accept="image/*" capture="camera">
4377+
<input type="file" accept="image/*" capture>
43744378
```
43754379

43764380
[![Edit 117-Media Capture and Streams API](images/codesandbox.svg)](https://codesandbox.io/p/sandbox/117-media-capture-and-streams-api-4s97wh)
43774381

43784382
[^117]CodeSandbox: Media Capture and Streams API.
43794383

4380-
[^117]:[CodeSandbox: Media Capture and Streams API](https://4s97wh.csb.app/), last access: October 7, 2024.
4384+
[^117]:[CodeSandbox: Media Capture and Streams API](https://4s97wh.csb.app/), last access: April 25, 2025.
43814385

43824386
- The code above demonstrates how to use the Media Capture API to enable image capture from the device's camera.
43834387
- The `<input>` element has the `type` attribute set to `file` to create a file input control.

__extra-resources/file-api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# File API and Related Topics
2+
3+
During the recording, I mentioned the **File API** class and referred to the MDN documentation for the `<input type="file">` element. You can read more about it here: [MDN Docs - `<input type="file>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/file).
4+
5+
Additionally, I demonstrated the `<pre>` HTML tag, which is useful for displaying preformatted text. You can find more details on this tag at [W3Schools - `<pre>` Tag](https://www.w3schools.com/tags/tag_pre.asp).
6+
7+
We also explored the `FileReader` API, specifically the `readAsDataURL` method, which allows you to convert an image to Base64 format. For more information, check out: [MDN Docs - FileReader.readAsDataURL](https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL).
8+
9+
Finally, we reviewed the Base64-encoded image using the [Base64 Guru](https://base64.guru/) website.

__extra-resources/file-api.pdf

80.5 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Media Capture and Streams API - Additional Resources
2+
3+
Here are some useful documentation links we visited during the recording. Feel free to explore and experiment with the options:
4+
5+
1. [MDN: HTML Attribute Reference - `accept`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/accept)
6+
2. [MDN: HTML Attribute Reference - `capture`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/capture)
7+
8+
Additionally, we referred to a popular Stack Overflow discussion where it was clarified that the `capture` attribute does not require the value `"camera"`:
9+
10+
- [Stack Overflow: HTML5 Input Type File Accept Image Capture Camera Display as Image](https://stackoverflow.com/questions/23916566/html5-input-type-file-accept-image-capture-camera-display-as-image-rat)
73.7 KB
Binary file not shown.

__extra-resources/webrtc-api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# WebRTC API
2+
3+
[Learn more about the WebRTC API and how to play with different settings using `getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia). This link provides detailed documentation and examples to help you explore the API further.

__extra-resources/webrtc-api.pdf

58.7 KB
Binary file not shown.

__presentation-slides/index.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,12 +3113,16 @@ <h1>Welcome to My Website</h1>
31133113

31143114
### WebRTC API <!-- .slide: data-transition="zoom" data-transition-speed="slow" -->
31153115

3116-
```html[|1|11|1,11|2|3|7|3,7|4|5|6|8|10|8,10|9]
3116+
```html[|1|15|1,15|2|3|11|3,11|4|5|10|12|14|12,14|13]
31173117
<script>
31183118
navigator.mediaDevices.getUserMedia({ audio: true, video: true })
31193119
.then(function (stream) {
31203120
const videoElement = document.createElement("video");
31213121
videoElement.srcObject = stream;
3122+
videoElement.height = 240;
3123+
videoElement.width = 320;
3124+
videoElement.controls = true;
3125+
videoElement.muted = false;
31223126
document.body.appendChild(videoElement);
31233127
})
31243128
.catch(function (error) {
@@ -3139,7 +3143,7 @@ <h1>Welcome to My Website</h1>
31393143
<input
31403144
type="file"
31413145
accept="image/*"
3142-
capture="camera"
3146+
capture
31433147
>
31443148
```
31453149

0 commit comments

Comments
 (0)