aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/mediadevices/devicechange_event/index.html
blob: 7ebc7fb71f006fcbeea240700ee92e3098f93957 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
---
title: devicechange
slug: Web/API/MediaDevices/devicechange_event
translation_of: Web/API/MediaDevices/devicechange_event
---
<p>每当媒体设备(例如相机,麦克风或扬声器)连接到系统或从系统中移除时,<code>devicechange </code>事件就会被发送到 {{domxref("MediaDevices")}}  实例。 这是一个没有附加属性的通用 {{domxref("Event")}}</p>

<h2 id="一般信息">一般信息</h2>

<dl>
 <dt style="float: left; text-align: right; width: 120px;">规范</dt>
 <dd style="margin: 0 0 0 120px;">{{SpecName('Media Capture')}}</dd>
 <dt style="float: left; text-align: right; width: 120px;">接口</dt>
 <dd style="margin: 0 0 0 120px;">Event</dd>
 <dt style="float: left; text-align: right; width: 120px;">是否冒泡</dt>
 <dd style="margin: 0 0 0 120px;">No</dd>
 <dt style="float: left; text-align: right; width: 120px;">是否可取消</dt>
 <dd style="margin: 0 0 0 120px;">No</dd>
 <dt style="float: left; text-align: right; width: 120px;">对象</dt>
 <dd style="margin: 0 0 0 120px;">{{domxref('MediaDevices')}}</dd>
 <dt style="float: left; text-align: right; width: 120px;">默认动作</dt>
 <dd style="margin: 0 0 0 120px;">None</dd>
</dl>

<h2 id="属性">属性</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Property</th>
   <th scope="col">Type</th>
   <th scope="col">Description</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code>target</code>{{readonlyinline}}</td>
   <td>{{domxref("EventTarget")}}</td>
   <td>事件对象 (位于DOM树最上面的元素).</td>
  </tr>
  <tr>
   <td><code>type</code> {{readonlyinline}}</td>
   <td>{{domxref("DOMString")}}</td>
   <td>事件类型.</td>
  </tr>
  <tr>
   <td><code>bubbles</code> {{readonlyinline}}</td>
   <td>{{domxref("Boolean")}}</td>
   <td>是否冒泡</td>
  </tr>
  <tr>
   <td><code>cancelable</code> {{readonlyinline}}</td>
   <td>{{domxref("Boolean")}}</td>
   <td>是否可被取消</td>
  </tr>
 </tbody>
</table>

<h2 id="相关事件">相关事件</h2>

<p><em></em>.</p>

<h2 id="样例">样例</h2>

<p>有关使用 <code>devicechange</code> 事件更新屏幕上设备列表的示例,请参阅 {{SectionOnPage("/en-US/docs/Web/API/MediaDevices/ondevicechange", "Example")}}</p>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('Media Capture', '#event-mediadevices-devicechange', 'devicechange') }}</td>
   <td>{{ Spec2('Media Capture') }}</td>
   <td>Initial specification.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Edge</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(52.0)}}</td>
   <td>{{CompatGeckoDesktop(51)}}<sup>[1]</sup></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>39</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>39</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Support for the <code>devicechange</code> event and for {{domxref("MediaDevices.ondevicechange")}} landed in Firefox 51, but <em>only for Mac</em>, and disabled by default. It can be enabled by setting the preference <code>media.ondevicechange.enabled</code> to <code>true</code>. Support for this event was added for Linux and Windows—and it was enabled by default—starting in Firefox 52.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("MediaDevices.ondevicechange")}}</li>
</ul>