aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/mediarecorder/error_event/index.html
blob: 84e0d31fb91fa61a7bc33a86f5d0b1d633f1167e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
---
title: 'MediaRecorder: error イベント'
slug: Web/API/MediaRecorder/error_event
tags:
  - Event
translation_of: Web/API/MediaRecorder/error_event
---
<div>{{APIRef}}</div>

<p>{{domxref("MediaRecorder")}} インターフェイスの <code>error</code> イベントは、エラーが発生したときに発生します。 例えば、記録が許可されていない、またはサポートされていないコーデックを使用して試みられたなどです。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">バブル</th>
   <td>いいえ</td>
  </tr>
  <tr>
   <th scope="row">キャンセル可能</th>
   <td>いいえ</td>
  </tr>
  <tr>
   <th scope="row">インターフェイス</th>
   <td>{{domxref("MediaRecorderErrorEvent")}}</td>
  </tr>
  <tr>
   <th scope="row">イベントハンドラプロパティ</th>
   <td><code><a href="/ja/docs/Web/API/MediaRecorder/onerror">onerror</a></code></td>
  </tr>
 </tbody>
</table>

<p>考えられるすべてのエラーの詳細については、イベントハンドラプロパティ <code><a href="/ja/docs/Web/API/MediaRecorder/onerror">onerror</a></code> のドキュメントを参照してください。</p>

<h2 id="Examples" name="Examples"></h2>

<p><code><a href="/ja/docs/Web/API/EventTarget/addEventListener">addEventListener</a></code> を使って <code>error</code> イベントを監視します。</p>

<pre class="brush: js">async function record() {
    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
    const recorder = new MediaRecorder(stream);
    recorder.addEventListener('error', (event) =&gt; {
        console.error(`error recording stream: ${event.error.name}`)
    });
    recorder.start();
}

record();</pre>

<p>上と同じですが、<code>onerror</code> イベントハンドラプロパティを使用します。</p>

<pre class="brush: js">async function record() {
    const stream = await navigator.mediaDevices.getUserMedia({audio: true});
    const recorder = new MediaRecorder(stream);
    recorder.onerror = (event) =&gt; {
        console.error(`error recording stream: ${event.error.name}`)
    };
    recorder.start();
}

record();</pre>

<h2 id="Specifications" name="Specifications">仕様</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">仕様</th>
   <th scope="col">状態</th>
  </tr>
  <tr>
   <td>{{SpecName('MediaStream Recording', '#errorevent-section')}}</td>
   <td>{{Spec2('MediaStream Recording')}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>



<p>{{Compat("api.MediaRecorder.error_event")}}</p>

<h2 id="See_also" name="See_also">関連情報</h2>

<ul>
 <li><a href="/ja/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API">Media​Stream Recording API の使用</a></li>
</ul>