Skip to content

Commit 6c0aa31

Browse files
Add changes to configurationchange event
1 parent f885c2a commit 6c0aa31

File tree

1 file changed

+49
-9
lines changed

1 file changed

+49
-9
lines changed

index.html

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -619,30 +619,41 @@ <h4>Processing considerations</h4>
619619
</section>
620620
<section>
621621
<h2>Exposing change of MediaStreamTrack configuration</h2>
622+
<p>The configuration (capabilities, constraints or settings) of a {{MediaStreamTrack}} may be changed dynamically
623+
outside the control of web applications. One example is when a user decides to switch on background blur through
624+
the operating system. Web applications might want to know that the configuration
625+
of a particular {{MediaStreamTrack}} has changed. For that purpose, a new event is defined below.
626+
</p>
627+
<h3>MediaStreamTrack Interface Extensions</h3>
622628
<div>
623-
<p>The configuration (capabilities, constraints or settings) of a {{MediaStreamTrack}} may be changed dynamically
624-
outside the control of web applications. One example is when a user decides to switch on background blur through
625-
the operating system. Web applications might want to know that the configuration
626-
of a particular {{MediaStreamTrack}} has changed. For that purpose, a new event is defined below.
627-
</p>
628-
<pre class="idl">
629+
<pre class="idl">
629630
partial interface MediaStreamTrack {
630631
attribute EventHandler onconfigurationchange;
631632
};</pre>
633+
<p>The <dfn data-dfn-for="MediaStreamTrack">onconfigurationchange</dfn> attribute
634+
is an [=event handler IDL attribute=] for the `onconfigurationchange`
635+
[=event handler=], whose [=event handler event type=] is
636+
<dfn event for=MediaStreamTrack>configurationchange</dfn>.
637+
</p>
632638
<p>
633639
<p>When the [=User Agent=] detects <dfn data-export id="change-track-configuration">a change of configuration</dfn>
634640
in a <var>track</var>'s underlying source, the [=User Agent=] MUST run the following steps:</p>
635641
<ol>
636642
<li><p>If <var>track</var>.{{MediaStreamTrack/muted}} is <code>true</code>, wait for <var>track</var>.{{MediaStreamTrack/muted}}
637643
to become <code>false</code> or <var>track</var>.{{MediaStreamTrack/readyState}} to be "ended".</p></li>
638644
<li><p>If <var>track</var>.{{MediaStreamTrack/readyState}} is "ended", abort these steps.</p></li>
639-
<li><p>If <var>track</var>'s capabilities, constraints and settings are matching <var>source</var> configuration, abort these steps.
645+
<li><p>If <var>track</var>'s capabilities, constraints and settings are matching <var>source</var> configuration, abort these steps.</li>
640646
<li>
641647
<!-- FIXME: Export capabilities, constraints and settings so that we can use them here. -->
642648
<p>Update <var>track</var>'s capabilities, constraints and settings according <var>track</var>'s underlying source.</p>
643649
</li>
644-
<li>
645-
<p>[=Fire an event=] named <var>configurationchange</var> on <var>track</var>.</p>
650+
<li><p>Let <var>changes</var> be an empty [=sequence=].</p></li>
651+
<li><p>For each change in <var>track</var>'s capabilities and settings, add its name to <var>changes</var>.</p></li>
652+
<li>
653+
<p>[=Fire an event=] named {{MediaStreamTrack/configurationchange}}
654+
at <var>track</var> using {{ConfigurationChangeEvent}}, with its
655+
{{ConfigurationChangeEvent.changes}} attribute initialized to
656+
<var>changes</var>.</p>
646657
</li>
647658
</ol>
648659
</p>
@@ -653,6 +664,35 @@ <h2>Exposing change of MediaStreamTrack configuration</h2>
653664
</div>
654665
</p>
655666
</div>
667+
<h3>ConfigurationChangeEvent Interface</h3>
668+
<div>
669+
<pre class="idl">
670+
[Exposed=Window]
671+
interface ConfigurationChangeEvent : Event {
672+
constructor(DOMString type, ConfigurationChangeEventInit changeEventInitDict);
673+
readonly attribute FrozenArray&lt;DOMString&gt; changes;
674+
};
675+
676+
dictionary ConfigurationChangeEventInit : EventInit {
677+
required sequence&lt;DOMString&gt; changes;
678+
};</pre>
679+
<p>The <dfn data-dfn-for="ConfigurationChangeEvent">changes</dfn> getter
680+
steps are to return the value that the corresponding attribute was
681+
initialized to.
682+
</p>
683+
</div>
684+
<h3>Example</h3>
685+
<div>
686+
<p>This example shows how to monitor external background blur changes.</p>
687+
<pre class="example">
688+
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
689+
const [track] = stream.getVideoTracks();
690+
track.addEventListener("configurationchange", (event) => {
691+
if (event.changes.includes("backgroundBlur")) {
692+
// Background blur configuration has changed.
693+
}
694+
});</pre>
695+
</div>
656696
</section>
657697
</body>
658698
</html>

0 commit comments

Comments
 (0)