forked from w3c/media-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media-source-respec.html
2415 lines (2264 loc) · 188 KB
/
media-source-respec.html
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Media Source Extensions™</title>
<script src="https://www.w3.org/Tools/respec/respec-w3c-common" class="remove"></script>
<!--<script src="respec-w3c-common.js" class="remove"></script>-->
<script src="media-source.js" class="remove"></script>
<script class="remove">
var respecConfig = {
// specification status (e.g., WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "ED",
useExperimentalStyles: true,
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "media-source",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c.github.io/media-source/",
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
/* Commented out to enable auto-updating of publishDate during respec execution
publishDate: "2016-07-26",
*/
previousMaturity: "PR",
previousPublishDate: "2016-10-04",
errata: "https://w3c.github.io/media-source/mse-1-errata.html",
// editors, add as many as you like
// only "name" is required
editors: [
{ name: "Matthew Wolenetz", url: "",
company: "Google Inc.", companyURL: "http://www.google.com/" },
{ name: "Jerry Smith", url: "",
company: "Microsoft Corporation", companyURL: "http://www.microsoft.com/" },
{ name: "Mark Watson", url: "",
company: "Netflix Inc.", companyURL: "http://www.netflix.com/" },
{ name: "Aaron Colwell (until April 2015)", url: "",
company: "Google Inc.", companyURL: "http://www.google.com/" },
{ name: "Adrian Bateman (until April 2015)", url: "",
company: "Microsoft Corporation", companyURL: "http://www.microsoft.com/" },
],
mseDefGroupName: "media-source",
mseContributors: [
"Bob Lund",
"Alex Giladi",
"Duncan Rowden",
"Mark Vickers",
"Glenn Adams",
"Frank Galligan",
"Steven Robertson",
"Matt Ward",
"David Dorwin",
"Kevin Streeter",
"Joe Steele",
"Michael Thornburgh",
"Philip Jägenstedt",
"John Simmons",
"Pierre Lemieux",
"Cyril Concolato",
"Ralph Giles",
"David Singer",
"Tatsuya Igarashi",
"Chris Poole",
"Jer Noble",
"Matthew Gregan"
],
// name of the WG
wg: "HTML Media Extensions Working Group",
// URI of the public WG page
wgURI: "https://www.w3.org/html/wg/",
// name (without the @w3c.org) of the public mailing to which comments are due
wgPublicList: "public-html-media",
license: 'w3c-software-doc',
// URI of the patent status for this WG, for Rec-track documents
// !!!! IMPORTANT !!!!
// This is important for Rec-track documents, do not copy a patent URI from a random
// document unless you know what you're doing. If in doubt ask your friendly neighbourhood
// Team Contact.
wgPatentURI: "https://www.w3.org/2004/01/pp-impl/40318/status",
lcEnd: "2016-08-10",
prEnd: "2016-11-01",
implementationReportURI: "http://tidoust.github.io/media-source-testcoverage/",
noIDLIn: true,
scheme: "https",
otherLinks: [{
key: 'Repository',
data: [{
value: 'We are on GitHub',
href: 'https://github.com/w3c/media-source/'
}, {
value: 'File a bug',
href: 'https://github.com/w3c/media-source/issues'
}, {
value: 'Commit history',
href: 'https://github.com/w3c/media-source/commits/gh-pages/media-source-respec.html'
}]
},{
key: 'Mailing list',
data: [{
value: 'public-html-media@w3.org',
href: 'https://lists.w3.org/Archives/Public/public-html-media/'
}]
},{
key: 'Implementation',
data: [{
value: 'Can I use Media Source Extensions?',
href: 'http://caniuse.com/#feat=mediasource'
}, {
value: 'Test Suite',
href: 'http://w3c-test.org/media-source/'
}, {
value: 'Test Suite repository',
href: 'https://github.com/w3c/web-platform-tests/tree/master/media-source'
}]
}],
preProcess: [ mediaSourcePreProcessor ],
// Empty definitions for objects declared in the document are here to
// prevent error messages from being displayed for references to these objects.
/*
definitionMap: {
MediaSource: function() {},
SourceBuffer: function() {},
SourceBufferList: function() {},
AppendMode: function() {},
ArrayBuffer: function() {},
ArrayBufferView: function() {},
},
*/
postProcess: [ mediaSourcePostProcessor ],
localBiblio: {
"INBANDTRACKS": {
title: "Sourcing In-band Media Resource Tracks from Media Containers into HTML",
href: "https://dev.w3.org/html5/html-sourcing-inband-tracks/",
authors: ["Bob Lund", "Silvia Pfeiffer"],
publisher: "W3C",
},
"MEDIA-PLAYBACK-QUALITY": {
title: "Media Playback Quality",
href: "https://wicg.github.io/media-playback-quality/",
authors: ["Mounir Lamouri"],
publisher: "W3C",
}
}
};
</script>
<!-- script to register bugs -->
<!-- Disabled unless/until it supports GitHub issues.
<script src="https://w3c.github.io/webcomponents/assets/scripts/bug-assist.js"></script>
<meta name="bug.short_desc" content="[MSE] ">
<meta name="bug.product" content="HTML WG">
<meta name="bug.component" content="Media Source Extensions">
-->
<link rel="stylesheet" href="mse.css">
</head>
<body>
<section id="sotd">
<p>The working group maintains <a href="https://github.com/w3c/media-source/issues">a list of all bug reports</a>. New features for this specification are expected to be incubated in the <a href='https://www.w3.org/community/wicg/'>Web Platform Incubator Community Group</a>.</p>
<p>One editorial issue (<a href='https://github.com/w3c/media-source/issues/168'>removing the exposure of <code>createObjectURL(mediaSource)</code> in workers</a>) was addressed since the previous publication. For the list of changes done since the previous version, see the <a href='https://github.com/w3c/media-source/commits/gh-pages'>commits</a>.</p>
<p>
By publishing this Recommendation, W3C expects the functionality specified in this Recommendation will not be affected by changes to File API. The Working Group will continue to track these specifications.
</p>
</section>
<section id="abstract">
This specification extends <a def-id="htmlmediaelement">HTMLMediaElement</a> [[!HTML51]] to allow
JavaScript to generate media streams for playback.
Allowing JavaScript to generate streams facilitates a variety of use
cases like adaptive streaming and time shifting live streams.
</section>
<section id="introduction" class="informative">
<h2>Introduction</h2>
<p>This specification allows JavaScript to dynamically construct media streams for <audio> and <video>. It defines a MediaSource object that can serve as a source of media data for an HTMLMediaElement. MediaSource objects have one or more <a>SourceBuffer</a> objects. Applications append data segments to the <a>SourceBuffer</a> objects, and can adapt the quality of appended data based on system performance and other factors. Data from the <a>SourceBuffer</a> objects is managed as track buffers for audio, video and text data that is decoded and played. Byte stream specifications used with these extensions are available in the byte stream format registry [[MSE-REGISTRY]].</p>
<img src="pipeline_model.svg" alt="Media Source Pipeline Model Diagram" longdesc='pipeline_model_description.html#pipelinedesc'>
<section id="goals">
<h3>Goals</h3>
<p>This specification was designed with the following goals in mind:</p>
<ul>
<li>Allow JavaScript to construct media streams independent of how the media is fetched.</li>
<li>Define a splicing and buffering model that facilitates use cases like adaptive streaming, ad-insertion, time-shifting, and video editing.</li>
<li>Minimize the need for media parsing in JavaScript.</li>
<li>Leverage the browser cache as much as possible.</li>
<li>Provide requirements for byte stream format specifications.</li>
<li>Not require support for any particular media format or codec.</li>
</ul>
<p>This specification defines:</p>
<ul>
<li>Normative behavior for user agents to enable interoperability between user agents and web applications when processing media data.</li>
<li>Normative requirements to enable other specifications to define media formats to be used within this specification.</li>
</ul>
</section>
<section id="definitions">
<h3>Definitions</h3>
<dl>
<dt id="active-track-buffers">Active Track Buffers</dt>
<dd><p>The <a def-id="track-buffers"></a> that provide <a def-id="coded-frames"></a> for the <a def-id="audiotrack-enabled"></a>
<a def-id="audiotracks"></a>, the <a def-id="videotrack-selected"></a> <a def-id="videotracks"></a>, and the
<a def-id="texttrackmode-showing"></a> or <a def-id="texttrackmode-hidden"></a> <a def-id="texttracks"></a>. All these tracks are associated with
<a>SourceBuffer</a> objects in the <a def-id="activeSourceBuffers"></a> list.</p>
</dd>
<dt id="append-window">Append Window</dt>
<dd><p>A <a def-id="presentation-timestamp"></a> range used to filter out <a def-id="coded-frames"></a> while appending. The append window represents a single
continuous time range with a single start time and end time. Coded frames with <a def-id="presentation-timestamp"></a> within this range are allowed to be appended
to the <a>SourceBuffer</a> while coded frames outside this range are filtered out. The append window start and end times are controlled by
the <a def-id="appendWindowStart"></a> and <a def-id="appendWindowEnd"></a> attributes respectively.</p></dd>
<dt id="coded-frame">Coded Frame</dt>
<dd><p>A unit of media data that has a <a def-id="presentation-timestamp"></a>, a <a def-id="decode-timestamp"></a>, and a <a def-id="coded-frame-duration"></a>.</p></dd>
<dt id="coded-frame-duration">Coded Frame Duration</dt>
<dd>
<p>The duration of a <a def-id="coded-frame"></a>. For video and text, the duration indicates how long the video frame or text SHOULD be displayed. For audio, the duration represents the sum of all the samples contained within the coded frame. For example, if an audio frame contained 441 samples @44100Hz the frame duration would be 10 milliseconds.</p>
</dd>
<dt id="coded-frame-end-timestamp">Coded Frame End Timestamp</dt>
<dd>
<p>The sum of a <a def-id="coded-frame"></a> <a def-id="presentation-timestamp"></a> and its
<a def-id="coded-frame-duration"></a>. It represents the <a def-id="presentation-timestamp"></a> that immediately follows the coded frame.</p>
</dd>
<dt id="coded-frame-group">Coded Frame Group</dt>
<dd><p>A group of <a def-id="coded-frames"></a> that are adjacent and have monotonically increasing <a def-id="decode-timestamps"></a> without any gaps. Discontinuities detected by the
<a def-id="coded-frame-processing-algorithm"></a> and <a def-id="abort"></a> calls trigger the start of a new coded frame group.</p>
</dd>
<dt id="decode-timestamp">Decode Timestamp</dt>
<dd>
<p> The decode timestamp indicates the latest time at which the frame needs to be decoded assuming instantaneous decoding and rendering of this and any dependant frames (this is equal to the <a def-id="presentation-timestamp"></a> of the earliest frame, in <a def-id="presentation-order"></a>, that is dependant on this frame). If frames can be decoded out of <a def-id="presentation-order"></a>, then the decode timestamp MUST be present in or derivable from the byte stream. The user agent MUST run the <a def-id="append-decode-error-algorithm"></a> if this is not the case. If frames cannot be decoded out of <a def-id="presentation-order"></a> and a decode timestamp is not present in the byte stream, then the decode timestamp is equal to the <a def-id="presentation-timestamp"></a>.</p>
</dd>
<dt id="init-segment">Initialization Segment</dt>
<dd>
<p>A sequence of bytes that contain all of the initialization information required to decode a sequence of <a def-id="media-segments"></a>. This includes codec initialization data, <a def-id="track-id"></a> mappings for multiplexed segments, and timestamp offsets (e.g., edit lists).</p>
<p class="note">The <a def-id="byte-stream-format-specs"></a> in the byte stream format registry [[MSE-REGISTRY]] contain format specific examples.</p>
</dd><dt id="media-segment">Media Segment</dt>
<dd>
<p>A sequence of bytes that contain packetized & timestamped media data for a portion of the <a def-id="media-timeline"></a>. Media segments are always associated with the most recently appended <a def-id="init-segment"></a>.</p>
<p class="note">The <a def-id="byte-stream-format-specs"></a> in the byte stream format registry [[MSE-REGISTRY]] contain format specific examples.</p>
</dd>
<dt id="mediasource-object-url">MediaSource object URL</dt>
<dd>
<p>A MediaSource object URL is a unique <a def-id="blob-uri"></a> [[!FILE-API]] created by <a def-id="createObjectURL"></a>. It is used to attach a <a>MediaSource</a> object to an HTMLMediaElement.</p>
<p>These URLs are the same as a <a def-id="blob-uri"></a>, except that anything in the definition of that feature that refers to <a def-id="File"></a> and <a def-id="Blob"></a> objects is hereby extended to also apply to <a>MediaSource</a> objects.</p>
<p>The <a def-id="origin">origin</a> of the MediaSource object URL is the <a def-id="relevant-settings-object"></a> of <code>this</code> during the call to <a def-id="createObjectURL"></a>.</p>
<p class="note">For example, the <a def-id="origin"></a> of the MediaSource object URL affects the way that the media element is <a href="https://www.w3.org/TR/html51/semantics-scripting.html#security-with-canvas-elements">consumed by canvas</a>.</p>
</dd>
<dt id="parent-media-source">Parent Media Source</dt>
<dd><p>The parent media source of a <a>SourceBuffer</a> object is the <a>MediaSource</a> object that created it.</p></dd>
<dt id="presentation-start-time">Presentation Start Time</dt>
<dd><p>The presentation start time is the earliest time point in the presentation and specifies the <a def-id="videoref" name="initial-playback-position">initial playback position</a> and <a def-id="videoref" name="earliest-possible-position">earliest possible position</a>. All presentations created using this specification have a presentation start time of 0.</p>
<p class="note">For the purposes of determining if <a def-id="hme-buffered"></a> contains a <a def-id="timerange"></a> that includes the current playback position, implementations MAY choose to allow a current playback position at or after <a def-id="presentation-start-time"></a> and before the first <a def-id="timerange"></a> to play the first <a def-id="timerange"></a> if that <a def-id="timerange"></a> starts within a reasonably short time, like 1 second, after <a def-id="presentation-start-time"></a>. This allowance accommodates the reality that muxed streams commonly do not begin all tracks precisely at <a def-id="presentation-start-time"></a>. Implementations MUST report the actual buffered range, regardless of this allowance.</p>
</dd>
<dt id="presentation-interval">Presentation Interval</dt>
<dd>
<p>The presentation interval of a <a def-id="coded-frame"></a> is the time interval from its <a def-id="presentation-timestamp"></a> to the <a def-id="presentation-timestamp"></a> plus the <a def-id="coded-frames-duration"></a>. For example, if a coded frame has a presentation timestamp of 10 seconds and a <a def-id="coded-frame-duration"></a> of 100 milliseconds, then the presentation interval would be [10-10.1). Note that the start of the range is inclusive, but the end of the range is exclusive.</p>
</dd>
<dt id="presentation-order">Presentation Order</dt>
<dd>
<p>The order that <a def-id="coded-frames"></a> are rendered in the presentation. The presentation order is achieved by ordering <a def-id="coded-frames"></a> in monotonically increasing order by their <a def-id="presentation-timestamps"></a>.</p>
</dd>
<dt id="presentation-timestamp">Presentation Timestamp</dt>
<dd>
<p>A reference to a specific time in the presentation. The presentation timestamp in a <a def-id="coded-frame"></a> indicates when the frame SHOULD be rendered.</p>
</dd>
<dt id="random-access-point">Random Access Point</dt>
<dd><p>A position in a <a def-id="media-segment"></a> where decoding and continuous playback can begin without relying on any previous data in the segment. For video this tends to be the location of I-frames. In the case of audio, most audio frames can be treated as a random access point. Since video tracks tend to have a more sparse distribution of random access points, the location of these points are usually considered the random access points for multiplexed streams.</p></dd>
<dt id="sourcebuffer-byte-stream-format-spec">SourceBuffer byte stream format specification</dt>
<dd><p>The specific <a def-id="byte-stream-format-spec"></a> that describes the format of the byte stream accepted by a <a>SourceBuffer</a> instance. The
<a def-id="byte-stream-format-spec"></a>, for a <a>SourceBuffer</a> object, is selected based on the <var>type</var> passed to the
<a def-id="addSourceBuffer"></a> call that created the object.</p></dd>
<dt id="sourcebuffer-configuration">SourceBuffer configuration</dt>
<dd><p>A specific set of tracks distributed across one or more <a>SourceBuffer</a>
objects owned by a single <a>MediaSource</a> instance.</p>
<p>Implementations MUST support at least 1 <a>MediaSource</a> object with the following
configurations:</p>
<ul>
<li>A single SourceBuffer with 1 audio track and/or 1 video track.</li>
<li>Two SourceBuffers with one handling a single audio track and the other handling a single video track.</li>
</ul>
<p>MediaSource objects MUST support each of the configurations above, but they are only
required to support one configuration at a time. Supporting multiple configurations at once
or additional configurations is a quality of implementation issue.</p>
</dd>
<dt id="track-description">Track Description</dt>
<dd><p>A byte stream format specific structure that provides the <a def-id="track-id"></a>, codec configuration, and other metadata for a single track. Each track description inside a single <a def-id="init-segment"></a> has a unique <a def-id="track-id"></a>. The user agent MUST run the <a def-id="append-decode-error-algorithm"></a> if the <a def-id="track-id"></a> is not unique within the <a def-id="init-segment"></a>.</p></dd>
<dt id="track-id">Track ID</dt>
<dd><p>A Track ID is a byte stream format specific identifier that marks sections of the byte stream as being part of a specific track. The Track ID in a <a def-id="track-description"></a> identifies which sections of a <a def-id="media-segment"></a> belong to that track.</p></dd>
</dl>
</section>
</section>
<section id="mediasource">
<h2>MediaSource Object</h2>
<p>The MediaSource object represents a source of media data for an HTMLMediaElement. It keeps track of the <a def-id="readyState"></a> for this source as well as a list of <a>SourceBuffer</a> objects that can be used to add media data to the presentation. MediaSource objects are created by the web application and then attached to an HTMLMediaElement. The application uses the <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a> to add media data to this source. The HTMLMediaElement fetches this media data from the <a>MediaSource</a> object when it is needed during playback.</p>
<p>Each <a>MediaSource</a> object has a <dfn id="live-seekable-range">live seekable range</dfn> variable that stores a <a def-id="normalized-timeranges-object"></a>. This variable is initialized to an empty <a def-id="timeranges"></a> object when the <a>MediaSource</a> object is created, is maintained by <a def-id="setLiveSeekableRange"></a> and <a def-id="clearLiveSeekableRange"></a>, and is used in <a href="#htmlmediaelement-extensions">HTMLMediaElement Extensions</a> to modify <a def-id="hme-seekable"></a> behavior.</p>
<div><pre class="idl">enum ReadyState {
"closed",
"open",
"ended"
};</pre><table class="simple" data-dfn-for="ReadyState" data-link-for="ReadyState"><tbody><tr><th colspan="2">Enumeration description</th></tr><tr><td><dfn><code id="idl-def-ReadyState.closed">closed</code></dfn></td><td>
Indicates the source is not currently attached to a media element.
</td></tr><tr><td><dfn><code id="idl-def-ReadyState.open">open</code></dfn></td><td>
The source has been opened by a media element and is ready for data to be appended to the <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a>.
</td></tr><tr><td><dfn><code id="idl-def-ReadyState.ended">ended</code></dfn></td><td>
The source is still attached to a media element, but <a def-id="endOfStream"></a> has been called.
</td></tr></tbody></table></div>
<div><pre class="idl">enum EndOfStreamError {
"network",
"decode"
};</pre><table class="simple" data-dfn-for="EndOfStreamError" data-link-for="EndOfStreamError"><tbody><tr><th colspan="2">Enumeration description</th></tr><tr><td><dfn><code id="idl-def-EndOfStreamError.network">network</code></dfn></td><td>
<p>Terminates playback and signals that a network error has occured.</p>
<p class="note">JavaScript applications SHOULD use this status code to terminate playback with a network error. For example, if a network error occurs while fetching media data.</p>
</td></tr><tr><td><dfn><code id="idl-def-EndOfStreamError.decode">decode</code></dfn></td><td>
<p>Terminates playback and signals that a decoding error has occured.</p>
<p class="note">JavaScript applications SHOULD use this status code to terminate playback with a decode error. For example, if a parsing error occurs while processing out-of-band media data.</p>
</td></tr></tbody></table></div>
<pre class="idl">[Constructor]
interface MediaSource : EventTarget {
readonly attribute SourceBufferList sourceBuffers;
readonly attribute SourceBufferList activeSourceBuffers;
readonly attribute ReadyState readyState;
attribute unrestricted double duration;
attribute EventHandler onsourceopen;
attribute EventHandler onsourceended;
attribute EventHandler onsourceclose;
SourceBuffer addSourceBuffer (DOMString type);
void removeSourceBuffer (SourceBuffer sourceBuffer);
void endOfStream (optional EndOfStreamError error);
void setLiveSeekableRange (double start, double end);
void clearLiveSeekableRange ();
static boolean isTypeSupported (DOMString type);
};</pre>
<section>
<h3>Attributes</h3>
<dl class="attributes" data-dfn-for="MediaSource" data-link-for="MediaSource"><dt><dfn><code>sourceBuffers</code></dfn> of type <span class="idlAttrType"><a>SourceBufferList</a></span>, readonly </dt><dd>
Contains the list of <a>SourceBuffer</a> objects associated with this <a>MediaSource</a>. When <a def-id="readyState"></a> equals <a def-id="closed"></a> this list will be empty. Once <a def-id="readyState"></a> transitions to <a def-id="open"></a> SourceBuffer objects can be added to this list by using <a def-id="addSourceBuffer"></a>.
</dd><dt><dfn><code>activeSourceBuffers</code></dfn> of type <span class="idlAttrType"><a>SourceBufferList</a></span>, readonly </dt><dd>
<p>Contains the subset of <a def-id="sourceBuffers"></a> that are providing the
<a def-id="videoref" name="dom-videotrack-selected">selected video track</a>, the
<a def-id="videoref" name="dom-audiotrack-enabled">enabled audio track(s)</a>, and the
<a def-id="texttrackmode-showing"></a> or <a def-id="texttrackmode-hidden"></a> text track(s).
</p>
<p><a>SourceBuffer</a> objects in this list MUST appear in the same order as they appear in
the <a def-id="sourceBuffers"></a> attribute; e.g., if only sourceBuffers[0] and
sourceBuffers[3] are in <a def-id="activeSourceBuffers"></a>, then activeSourceBuffers[0] MUST
equal sourceBuffers[0] and activeSourceBuffers[1] MUST equal sourceBuffers[3].
</p>
<p class="note">The <a href="#active-source-buffer-changes">Changes to selected/enabled track state</a> section describes how this attribute gets
updated.</p>
</dd><dt><dfn><code>readyState</code></dfn> of type <span class="idlAttrType"><a>ReadyState</a></span>, readonly </dt><dd>
<p>Indicates the current state of the <a>MediaSource</a> object. When the <a>MediaSource</a> is created <a def-id="readyState"></a> MUST be set to <a def-id="closed"></a>.
</p></dd><dt><dfn><code>duration</code></dfn> of type <span class="idlAttrType"><a>unrestricted double</a></span></dt><dd>
<p>Allows the web application to set the presentation duration. The duration is initially set to NaN when the <a>MediaSource</a> object is created.</p>
<p>On getting, run the following steps:</p>
<ol>
<li>If the <a def-id="readyState"></a> attribute is <a def-id="closed"></a> then return NaN and abort these steps.</li>
<li>Return the current value of the attribute.</li>
</ol>
<p>On setting, run the following steps:</p>
<ol>
<li>If the value being set is negative or NaN then throw a <a def-id="type-error"></a> exception and abort these steps.</li>
<li>If the <a def-id="readyState"></a> attribute is not <a def-id="open"></a> then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>If the <a def-id="updating"></a> attribute equals true on any <a>SourceBuffer</a> in <a def-id="sourceBuffers"></a>, then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>Run the <a def-id="duration-change-algorithm"></a> with <var>new duration</var> set to the value being assigned to this attribute.
<p class="note">The <a def-id="duration-change-algorithm"></a> will adjust <var>new duration</var> higher if there is any currently buffered coded frame with a higher end time.</p>
<p class="note"><a def-id="appendBuffer"></a> and <a def-id="endOfStream"></a> can update the duration under certain circumstances.</p>
</li>
</ol>
</dd><dt><dfn><code>onsourceopen</code></dfn> of type <span class="idlAttrType"><a>EventHandler</a></span></dt><dd>
<p>The event handler for the <a def-id="sourceopen"></a> event.</p>
</dd><dt><dfn><code>onsourceended</code></dfn> of type <span class="idlAttrType"><a>EventHandler</a></span></dt><dd>
<p>The event handler for the <a def-id="sourceended"></a> event.</p>
</dd><dt><dfn><code>onsourceclose</code></dfn> of type <span class="idlAttrType"><a>EventHandler</a></span></dt><dd>
<p>The event handler for the <a def-id="sourceclose"></a> event.</p>
</dd></dl></section><section><h2>Methods</h2><dl class="methods" data-dfn-for="MediaSource" data-link-for="MediaSource"><dt><dfn><code>addSourceBuffer</code></dfn></dt><dd>
<p>Adds a new <a>SourceBuffer</a> to <a def-id="sourceBuffers"></a>.</p>
<ol class="method-algorithm">
<li>If <var>type</var> is an empty string then throw a <a def-id="type-error"></a> exception and abort these steps.</li>
<li>If <var>type</var> contains a MIME type that is not supported or contains a MIME type that is not supported with the types specified for the other <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a>, then throw a <a def-id="not-supported-error"></a> exception and abort these steps.</li>
<li>If the user agent can't handle any more SourceBuffer objects or if creating a SourceBuffer
based on <var>type</var> would result in an unsupported <a def-id="sourcebuffer-configuration"></a>,
then throw a <a def-id="quota-exceeded-error"></a> exception and abort these steps.
<p class="note">For example, a user agent MAY throw a <a def-id="quota-exceeded-error"></a> exception if the media element has reached the
<a def-id="have-metadata"></a> readyState. This can occur if the user agent's media engine does not support adding more tracks during
playback.
</p>
</li>
<li>If the <a def-id="readyState"></a> attribute is not in the <a def-id="open"></a> state then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>Create a new <a>SourceBuffer</a> object and associated resources.</li>
<li>Set the <a def-id="generate-timestamps-flag"></a> on the new object to the value in the
"Generate Timestamps Flag" column of the byte stream format registry [[MSE-REGISTRY]] entry
that is associated with <var>type</var>.
</li><li>
<dl class="switch">
<dt>If the <a def-id="generate-timestamps-flag"></a> equals true:</dt>
<dd>
Set the <a def-id="mode"></a> attribute on the new object to
<a def-id="AppendMode-sequence"></a>.
</dd>
<dt>Otherwise:</dt>
<dd>
Set the <a def-id="mode"></a> attribute on the new object to
<a def-id="AppendMode-segments"></a>.
</dd>
</dl>
</li>
<li>Add the new object to <a def-id="sourceBuffers"></a> and <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="addsourcebuffer"></a> at <a def-id="sourceBuffers"></a>.</li>
<li>Return the new object.</li>
</ol>
<table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">type</td><td class="prmType"><code>DOMString</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><a>SourceBuffer</a></div></dd><dt><dfn><code>removeSourceBuffer</code></dfn></dt><dd>
<p>Removes a <a>SourceBuffer</a> from <a def-id="sourceBuffers"></a>.</p>
<ol class="method-algorithm">
<li>If <var>sourceBuffer</var> specifies an object that is not in <a def-id="sourceBuffers"></a> then throw a <a def-id="not-found-error"></a> exception and abort these steps.</li>
<li>If the <var>sourceBuffer</var>.<a def-id="updating"></a> attribute equals true, then run the following steps:
<ol>
<li>Abort the <a def-id="buffer-append"></a> algorithm if it is running.</li>
<li>Set the <var>sourceBuffer</var>.<a def-id="updating"></a> attribute to false.</li>
<li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="updateabort"></a> at <var>sourceBuffer</var>.</li>
<li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="updateend"></a> at <var>sourceBuffer</var>.</li>
</ol>
</li>
<li>Let <var>SourceBuffer audioTracks list</var> equal the <a def-id="audio-track-list"></a> object returned by <var>sourceBuffer</var>.<a def-id="sourcebuffer-audioTracks"></a>.</li>
<li>If the <var>SourceBuffer audioTracks list</var> is not empty, then run the following steps:
<ol>
<li>Let <var>HTMLMediaElement audioTracks list</var> equal the <a def-id="audio-track-list"></a> object returned by the <a def-id="audiotracks"></a> attribute on the HTMLMediaElement.</li>
<li>For each <a def-id="audio-track"></a> object in the <var>SourceBuffer audioTracks list</var>, run the following steps:
<ol>
<li>Set the <a def-id="audiotrack-sourceBuffer"></a> attribute on the <a def-id="audio-track"></a> object to null.</li>
<li>Remove the <a def-id="audio-track"></a> object from the <var>HTMLMediaElement audioTracks list</var>.
<p class="note">
This should trigger <a def-id="audio-track-list"></a> [[HTML51]] logic to <a def-id="queue-and-fire-media-removetrack-with-track-attr-initialized-to"></a> the <a def-id="audio-track"></a> object, at the <var>HTMLMediaElement audioTracks list</var>.
If the <a def-id="audiotrack-enabled"></a> attribute on the <a def-id="audio-track"></a> object was true at the beginning of this removal step, then this should also trigger <a def-id="audio-track-list"></a> [[HTML51]] logic to <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="mediatracklist-change"></a> at the <var>HTMLMediaElement audioTracks list</var>
</p>
</li>
<li>Remove the <a def-id="audio-track"></a> object from the <var>SourceBuffer audioTracks list</var>.
<p class="note">
This should trigger <a def-id="audio-track-list"></a> [[HTML51]] logic to <a def-id="queue-and-fire-media-removetrack-with-track-attr-initialized-to"></a> the <a def-id="audio-track"></a> object, at the <var>SourceBuffer audioTracks list</var>.
If the <a def-id="audiotrack-enabled"></a> attribute on the <a def-id="audio-track"></a> object was true at the beginning of this removal step, then this should also trigger <a def-id="audio-track-list"></a> [[HTML51]] logic to <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="mediatracklist-change"></a> at the <var>SourceBuffer audioTracks list</var>
</p>
</li>
</ol>
</li>
</ol>
</li>
<li>Let <var>SourceBuffer videoTracks list</var> equal the <a def-id="video-track-list"></a> object returned by <var>sourceBuffer</var>.<a def-id="sourcebuffer-videoTracks"></a>.</li>
<li>If the <var>SourceBuffer videoTracks list</var> is not empty, then run the following steps:
<ol>
<li>Let <var>HTMLMediaElement videoTracks list</var> equal the <a def-id="video-track-list"></a> object returned by the <a def-id="videotracks"></a> attribute on the HTMLMediaElement.</li>
<li>For each <a def-id="video-track"></a> object in the <var>SourceBuffer videoTracks list</var>, run the following steps:
<ol>
<li>Set the <a def-id="videotrack-sourceBuffer"></a> attribute on the <a def-id="video-track"></a> object to null.</li>
<li>Remove the <a def-id="video-track"></a> object from the <var>HTMLMediaElement videoTracks list</var>.
<p class="note">
This should trigger <a def-id="video-track-list"></a> [[HTML51]] logic to <a def-id="queue-and-fire-media-removetrack-with-track-attr-initialized-to"></a> the <a def-id="video-track"></a> object, at the <var>HTMLMediaElement videoTracks list</var>.
If the <a def-id="videotrack-selected"></a> attribute on the <a def-id="video-track"></a> object was true at the beginning of this removal step, then this should also trigger <a def-id="video-track-list"></a> [[HTML51]] logic to <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="mediatracklist-change"></a> at the <var>HTMLMediaElement videoTracks list</var>
</p>
</li>
<li>Remove the <a def-id="video-track"></a> object from the <var>SourceBuffer videoTracks list</var>.
<p class="note">
This should trigger <a def-id="video-track-list"></a> [[HTML51]] logic to <a def-id="queue-and-fire-media-removetrack-with-track-attr-initialized-to"></a> the <a def-id="video-track"></a> object, at the <var>SourceBuffer videoTracks list</var>.
If the <a def-id="videotrack-selected"></a> attribute on the <a def-id="video-track"></a> object was true at the beginning of this removal step, then this should also trigger <a def-id="video-track-list"></a> [[HTML51]] logic to <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="mediatracklist-change"></a> at the <var>SourceBuffer videoTracks list</var>
</p>
</li>
</ol>
</li>
</ol>
</li>
<li>Let <var>SourceBuffer textTracks list</var> equal the <a def-id="text-track-list"></a> object returned by <var>sourceBuffer</var>.<a def-id="sourcebuffer-textTracks"></a>.</li>
<li>If the <var>SourceBuffer textTracks list</var> is not empty, then run the following steps:
<ol>
<li>Let <var>HTMLMediaElement textTracks list</var> equal the <a def-id="text-track-list"></a> object returned by the <a def-id="texttracks"></a> attribute on the HTMLMediaElement.</li>
<li>For each <a def-id="text-track"></a> object in the <var>SourceBuffer textTracks list</var>, run the following steps:
<ol>
<li>Set the <a def-id="texttrack-sourceBuffer"></a> attribute on the <a def-id="text-track"></a> object to null.</li>
<li>Remove the <a def-id="text-track"></a> object from the <var>HTMLMediaElement textTracks list</var>.
<p class="note">
This should trigger <a def-id="text-track-list"></a> [[HTML51]] logic to <a def-id="queue-and-fire-text-removetrack-with-track-attr-initialized-to"></a> the <a def-id="text-track"></a> object, at the <var>HTMLMediaElement textTracks list</var>.
If the <a def-id="texttrack-mode"></a> attribute on the <a def-id="text-track"></a> object was <a def-id="texttrackmode-showing"></a> or <a def-id="texttrackmode-hidden"></a> at the beginning of this removal step, then this should also trigger <a def-id="text-track-list"></a> [[HTML51]] logic to <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="texttracklist-change"></a> at the <var>HTMLMediaElement textTracks list</var>.
</p>
</li>
<li>Remove the <a def-id="text-track"></a> object from the <var>SourceBuffer textTracks list</var>.
<p class="note">
This should trigger <a def-id="text-track-list"></a> [[HTML51]] logic to <a def-id="queue-and-fire-text-removetrack-with-track-attr-initialized-to"></a> the <a def-id="text-track"></a> object, at the <var>SourceBuffer textTracks list</var>.
If the <a def-id="texttrack-mode"></a> attribute on the <a def-id="text-track"></a> object was <a def-id="texttrackmode-showing"></a> or <a def-id="texttrackmode-hidden"></a> at the beginning of this removal step, then this should also trigger <a def-id="text-track-list"></a> [[HTML51]] logic to <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="texttracklist-change"></a> at the <var>SourceBuffer textTracks list</var>.
</p>
</li>
</ol>
</li>
</ol>
</li>
<li>If <var>sourceBuffer</var> is in <a def-id="activeSourceBuffers"></a>, then remove <var>sourceBuffer</var> from <a def-id="activeSourceBuffers"></a> and
<a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at the <a>SourceBufferList</a> returned by <a def-id="activeSourceBuffers"></a>.</li>
<li>Remove <var>sourceBuffer</var> from <a def-id="sourceBuffers"></a> and <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at
the <a>SourceBufferList</a> returned by <a def-id="sourceBuffers"></a>.</li>
<li>Destroy all resources for <var>sourceBuffer</var>.</li>
</ol>
<table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">sourceBuffer</td><td class="prmType"><code>SourceBuffer</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><a>void</a></div></dd><dt><dfn><code>endOfStream</code></dfn></dt><dd>
<p>Signals the end of the stream.</p>
<ol class="method-algorithm">
<li>If the <a def-id="readyState"></a> attribute is not in the <a def-id="open"></a> state then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>If the <a def-id="updating"></a> attribute equals true on any <a>SourceBuffer</a> in <a def-id="sourceBuffers"></a>, then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>Run the <a def-id="end-of-stream-algorithm"></a> with the <var>error</var> parameter set to <var>error</var>.</li>
</ol>
<table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">error</td><td class="prmType"><code>EndOfStreamError</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptTrue"><span role="img" aria-label="True">✔</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><a>void</a></div></dd><dt><dfn><code>setLiveSeekableRange</code></dfn></dt><dd>
<p>Updates the <a def-id="live-seekable-range"></a> variable used in <a href="#htmlmediaelement-extensions">HTMLMediaElement Extensions</a> to modify <a def-id="hme-seekable"></a> behavior.</p>
<ol class="method-algorithm">
<li>If the <a def-id="readyState"></a> attribute is not <a def-id="open"></a> then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>If <var>start</var> is negative or greater than <var>end</var>, then throw a <a def-id="type-error"></a> exception and abort these steps.</li>
<li>Set <a def-id="live-seekable-range"></a> to be a new <a def-id="normalized-timeranges-object"></a> containing a single range whose start position is <var>start</var> and end position is <var>end</var>.
</li></ol>
<table class="parameters">
<tbody>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Nullable</th>
<th>Optional</th>
<th>Description</th>
</tr>
<tr>
<td class="prmName">start</td>
<td class="prmType"><code>double</code></td>
<td class="prmNullFalse"><span aria-label="False" role=
"img">✘</span></td>
<td class="prmOptFalse"><span aria-label="False" role=
"img">✘</span></td>
<td class="prmDesc">The start of the range, in seconds measured from <a def-id="presentation-start-time"></a>. While set, and if <a def-id="duration"></a> equals positive Infinity, <a def-id="hme-seekable"></a> will return a non-empty TimeRanges object with a lowest range start timestamp no greater than <var>start</var>.</td>
</tr>
<tr>
<td class="prmName">end</td>
<td class="prmType"><code>double</code></td>
<td class="prmNullFalse"><span aria-label="False" role=
"img">✘</span></td>
<td class="prmOptFalse"><span aria-label="False" role=
"img">✘</span></td>
<td class="prmDesc">The end of range, in seconds measured from <a def-id="presentation-start-time"></a>. While set, and if <a def-id="duration"></a> equals positive Infinity, <a def-id="hme-seekable"></a> will return a non-empty TimeRanges object with a highest range end timestamp no less than <var>end</var>.</td>
</tr>
</tbody>
</table>
<div><em>Return type: </em><a>void</a></div></dd><dt><dfn><code>clearLiveSeekableRange</code></dfn></dt><dd>
<p>Updates the <a def-id="live-seekable-range"></a> variable used in <a href="#htmlmediaelement-extensions">HTMLMediaElement Extensions</a> to modify <a def-id="hme-seekable"></a> behavior.</p>
<ol class="method-algorithm">
<li>If the <a def-id="readyState"></a> attribute is not <a def-id="open"></a> then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>If <a def-id="live-seekable-range"></a> contains a range, then set <a def-id="live-seekable-range"></a> to be a new empty <a def-id="timeranges"></a> object.
</li></ol>
<div><em>No parameters.</em></div><div><em>Return type: </em><a>void</a></div></dd><dt><dfn><code>isTypeSupported</code></dfn>, static</dt><dd>
<p>Check to see whether the <a>MediaSource</a> is capable of creating <a>SourceBuffer</a> objects for the specified MIME type.</p>
<ol class="method-algorithm">
<li>If <var>type</var> is an empty string, then return false.</li>
<li>If <var>type</var> does not contain a valid MIME type string, then return false.</li>
<li>If <var>type</var> contains a media type or media subtype that the MediaSource does not support, then return false.</li>
<li>If <var>type</var> contains a codec that the MediaSource does not support, then return false.</li>
<li>If the MediaSource does not support the specified combination of media type, media subtype, and codecs then return false.</li>
<li>Return true.</li>
</ol>
<p class="note">
If true is returned from this method, it only indicates that the <a>MediaSource</a> implementation is capable of creating <a>SourceBuffer</a> objects for the specified MIME type. An <a def-id="addSourceBuffer"></a> call SHOULD still fail if sufficient resources are not available to support the addition of a new <a>SourceBuffer</a>.
</p>
<p class="note">
This method returning true implies that HTMLMediaElement.canPlayType() will return "maybe" or "probably" since it does not make sense for a <a>MediaSource</a> to support a type the HTMLMediaElement knows it cannot play.
</p>
<table class="parameters"><tbody><tr><th>Parameter</th><th>Type</th><th>Nullable</th><th>Optional</th><th>Description</th></tr><tr><td class="prmName">type</td><td class="prmType"><code>DOMString</code></td><td class="prmNullFalse"><span role="img" aria-label="False">✘</span></td><td class="prmOptFalse"><span role="img" aria-label="False">✘</span></td><td class="prmDesc"></td></tr></tbody></table><div><em>Return type: </em><a><code>boolean</code></a></div></dd></dl>
</section>
<section id="mediasource-events">
<h3>Event Summary</h3>
<table class="old-table">
<thead>
<tr>
<th>Event name</th>
<th>Interface</th>
<th>Dispatched when...</th>
</tr>
</thead>
<tbody>
<tr>
<td><a def-id="eventdfn">sourceopen</a></td>
<td><code>Event</code></td>
<td><a def-id="readyState"></a> transitions from <a def-id="closed"></a> to <a def-id="open"></a> or from <a def-id="ended"></a> to <a def-id="open"></a>.</td>
</tr>
<tr>
<td><a def-id="eventdfn">sourceended</a></td>
<td><code>Event</code></td>
<td><a def-id="readyState"></a> transitions from <a def-id="open"></a> to <a def-id="ended"></a>.</td>
</tr>
<tr>
<td><a def-id="eventdfn">sourceclose</a></td>
<td><code>Event</code></td>
<td><a def-id="readyState"></a> transitions from <a def-id="open"></a> to <a def-id="closed"></a> or <a def-id="ended"></a> to <a def-id="closed"></a>.</td>
</tr>
</tbody>
</table>
</section>
<section id="mediasource-algorithms">
<h3>Algorithms</h3>
<section id="mediasource-attach">
<h4>Attaching to a media element</h4>
<p> A <a>MediaSource</a> object can be attached to a media element by assigning a <a def-id="MediaSource-object-URL"></a> to the media element <a def-id="media-src"></a> attribute or the src attribute of a <source> inside a media element. A <a def-id="MediaSource-object-URL"></a> is created by passing a MediaSource object to <a def-id="createObjectURL"></a>.</p>
<p>If the <a def-id="resource-fetch-algorithm"></a> was invoked with
a media provider object that is a MediaSource object or a URL record whose object is a MediaSource object,
then let mode be local, skip the first step in the <a def-id="resource-fetch-algorithm"></a>
(which may otherwise set mode to remote) and add the steps and clarifications below to the <a def-id="Otherwise-mode-is-local"></a> section of the <a def-id="resource-fetch-algorithm"></a>.
<p class="note">The <a def-id="resource-fetch-algorithm"></a>'s first step is expected to eventually align with selecting local mode for URL records whose objects are media provider objects. The intent is that if the HTMLMediaElement's <code>src</code> attribute or selected child <code><source></code>'s <code>src</code> attribute is a <code>blob:</code> URL matching a <a def-id="MediaSource-object-URL"></a> when the respective <code>src</code> attribute was last changed, then that MediaSource object is used as the media provider object and current media resource in the local mode logic in the <a def-id="resource-fetch-algorithm"></a>. This also means that the remote mode logic that includes observance of any preload attribute is skipped when a MediaSource object is attached. Even with that eventual change to [[HTML51]], the execution of the following steps at the beginning of the local mode logic is still required when the current media resource is a MediaSource object.</p>
<p class="note">Relative to the action which triggered the media element's resource selection algorithm, these steps are asynchronous. The resource fetch algorithm is run after the task that invoked the resource selection algorithm is allowed to continue and a stable state is reached. Implementations may delay the steps in the "<i>Otherwise</i>" clause, below, until the MediaSource object is ready for use.</p>
<dl class="switch">
<dt>If <a def-id="readyState"></a> is NOT set to <a def-id="closed"></a></dt>
<dd>Run the <a def-id="media-data-cannot-be-fetched"></a> steps of the <a def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
<dt>Otherwise</dt>
<dd>
<ol>
<li>Set the media element's <a def-id="delaying-the-load-event-flag"></a> to false.</li>
<li>Set the <a def-id="readyState"></a> attribute to <a def-id="open"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="sourceopen"></a> at the <a>MediaSource</a>.</li>
<li>Continue the <a def-id="resource-fetch-algorithm"></a> by running the remaining <a def-id="Otherwise-mode-is-local"></a> steps, with these clarifications:
<ol>
<li>Text in the <a def-id="resource-fetch-algorithm"></a> or the <a def-id="media-data-processing-steps-list"></a> that refers to "the download", "bytes received", or "whenever new data for the current media resource becomes available" refers to data passed in via <a def-id="appendBuffer"></a>.</li>
<li>References to HTTP in the <a def-id="resource-fetch-algorithm"></a> and the <a def-id="media-data-processing-steps-list"></a> do not apply because the HTMLMediaElement does not fetch media data via HTTP when a <a>MediaSource</a> is attached.</li>
</ol>
</li>
</ol>
</dd>
</dl>
<p class="note">An attached MediaSource does not use the remote mode steps in the <a def-id="resource-fetch-algorithm"></a>, so the media element will not fire "suspend" events. Though future versions of this specification will likely remove "progress" and "stalled" events from a media element with an attached MediaSource, user agents conforming to this version of the specification may still fire these two events as these [[HTML51]] references changed after implementations of this specification stabilized.</p>
</section>
<section id="mediasource-detach">
<h4>Detaching from a media element</h4>
<p>The following steps are run in any case where the media element is going to transition to <a def-id="videoref" name="dom-htmlmediaelement-network_empty">NETWORK_EMPTY</a> and <a def-id="queue-a-task-to-fire-an-event-named"></a> <a def-id="videoref" name="eventdef-media-emptied">emptied</a> at the media element. These steps SHOULD be run right before the transition.</p>
<ol>
<li>Set the <a def-id="readyState"></a> attribute to <a def-id="closed"></a>.</li>
<li>Update <a def-id="duration"></a> to NaN.</li>
<li>Remove all the <a>SourceBuffer</a> objects from <a def-id="activeSourceBuffers"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>.</li>
<li>Remove all the <a>SourceBuffer</a> objects from <a def-id="sourceBuffers"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at <a def-id="sourceBuffers"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="sourceclose"></a> at the <a>MediaSource</a>.</li>
</ol>
<p class="note">Going forward, this algorithm is intended to be externally called and run in any case where the attached <a>MediaSource</a>, if any, must be detached from the media element. It MAY be called on HTMLMediaElement [[HTML51]] operations like load() and resource fetch algorithm failures in addition to, or in place of, when the media element transitions to <a def-id="videoref" name="dom-htmlmediaelement-network_empty">NETWORK_EMPTY</a>. Resource fetch algorithm failures are those which abort either the resource fetch algorithm or the resource selection algorithm, with the exception that the "Final step" [[HTML51]] is not considered a failure that triggers detachment.</p>
</section>
<section id="mediasource-seeking">
<h4>Seeking</h4>
<p>Run the following steps as part of the "<i>Wait until the user agent has established whether or not the media data for the new playback position is available, and, if it is, until it has decoded enough data to play back that position"</i> step of the <a def-id="hme-seek-algorithm"></a>:</p>
<ol>
<li>
<p class="note">The media element looks for <a def-id="media-segments"></a> containing the <var>new playback position</var> in each <a>SourceBuffer</a> object in <a def-id="activeSourceBuffers"></a>.
Any position within a <a def-id="timerange"></a> in the current value of the <a def-id="hme-buffered"></a> attribute has all necessary media segments buffered for that position.</p>
<dl class="switch">
<dt>If <var>new playback position</var> is not in any <a def-id="timerange"></a> of <a def-id="hme-buffered"></a></dt>
<dd>
<ol>
<li>If the <a def-id="ready-state"></a> attribute is greater than
<a def-id="have-metadata"></a>, then set the <a def-id="ready-state"></a> attribute
to <a def-id="have-metadata"></a>.
<p class="note">Per <a def-id="ready-states"></a> [[HTML51]] logic, <a def-id="ready-state"></a> changes may trigger events on the HTMLMediaElement.</p>
</li>
<li>The media element waits until an <a def-id="appendBuffer"></a> call causes the <a def-id="coded-frame-processing-algorithm"></a> to set
the <a def-id="ready-state"></a> attribute to a value greater than <a def-id="have-metadata"></a>.
<p class="note">The web application can use <a def-id="buffered"></a> and <a def-id="hme-buffered"></a> to determine what the media element needs to resume playback.</p>
</li>
</ol>
</dd>
<dt>Otherwise</dt>
<dd>Continue
<p class="note">If the <a def-id="readyState"></a> attribute is <a def-id="ended"></a> and the <var>new playback position</var> is within a <a def-id="timerange"></a> currently in <a def-id="hme-buffered"></a>, then the seek operation must continue to completion here even if one or more currently selected or enabled track buffers' largest range end timestamp is less than <var>new playback position</var>. This condition should only occur due to logic in <a def-id="buffered"></a> when <a def-id="readyState"></a> is <a def-id="ended"></a>.</p>
</dd>
</dl>
</li>
<li>The media element resets all decoders and initializes each one with data from the appropriate <a def-id="init-segment"></a>.</li>
<li>The media element feeds <a def-id="coded-frames"></a> from the <a def-id="active-track-buffers"></a> into the decoders starting with the
closest <a def-id="random-access-point"></a> before the <var>new playback position</var>.</li>
<li>Resume the <a def-id="hme-seek-algorithm"></a> at the "<i>Await a stable state</i>" step.</li>
</ol>
</section>
<section id="buffer-monitoring">
<h4>SourceBuffer Monitoring</h4>
<p>The following steps are periodically run during playback to make sure that all of the <a>SourceBuffer</a> objects in <a def-id="activeSourceBuffers"></a> have <a def-id="enough-data"></a>. Changes to <a def-id="activeSourceBuffers"></a> also cause these steps to run because they affect the conditions that trigger state transitions.</p>
<p>Having <dfn id="enough-data">enough data to ensure uninterrupted playback</dfn> is an implementation specific condition where the user agent
determines that it currently has enough data to play the presentation without stalling for a meaningful period of time. This condition is
constantly evaluated to determine when to transition the media element into and out of the <a def-id="have-enough-data"></a> ready state.
These transitions indicate when the user agent believes it has enough data buffered or it needs more data respectively.</p>
<p class="note">An implementation MAY choose to use bytes buffered, time buffered, the append rate, or any other metric it sees fit to
determine when it has enough data. The metrics used MAY change during playback so web applications SHOULD only rely on the value of
<a def-id="ready-state"></a> to determine whether more data is needed or not.</p>
<p class="note">When the media element needs more data, the user agent SHOULD transition it from <a def-id="have-enough-data"></a> to
<a def-id="have-future-data"></a> early enough for a web application to be able to respond without causing an interruption in playback.
For example, transitioning when the current playback position is 500ms before the end of the buffered data gives the application roughly
500ms to append more data before playback stalls.</p>
<dl class="switch">
<dt>If the the <a def-id="ready-state"></a> attribute equals <a def-id="have-nothing"></a>:</dt>
<dd>
<ol>
<li>Abort these steps.</li>
</ol>
</dd>
<dt>If <a def-id="hme-buffered"></a> does not contain a <a def-id="timerange"></a> for the current playback position:</dt>
<dd>
<ol>
<li>Set the <a def-id="ready-state"></a> attribute to <a def-id="have-metadata"></a>.
<p class="note">Per <a def-id="ready-states"></a> [[HTML51]] logic, <a def-id="ready-state"></a> changes may trigger events on the HTMLMediaElement.</p></li>
<li>Abort these steps.</li>
</ol>
</dd>
<dt>If <a def-id="hme-buffered"></a> contains a <a def-id="timerange"></a> that includes the current playback position and <a def-id="enough-data"></a>:</dt>
<dd>
<ol>
<li>Set the <a def-id="ready-state"></a> attribute to <a def-id="have-enough-data"></a>.
<p class="note">Per <a def-id="ready-states"></a> [[HTML51]] logic, <a def-id="ready-state"></a> changes may trigger events on the HTMLMediaElement.</p></li>
<li>Playback may resume at this point if it was previously suspended by a transition to <a def-id="have-current-data"></a>.</li>
<li>Abort these steps.</li>
</ol>
</dd>
<dt>If <a def-id="hme-buffered"></a> contains a <a def-id="timerange"></a> that includes the current playback position and some time beyond the current playback position, then run the following steps:</dt>
<dd>
<ol>
<li>Set the <a def-id="ready-state"></a> attribute to <a def-id="have-future-data"></a>.
<p class="note">Per <a def-id="ready-states"></a> [[HTML51]] logic, <a def-id="ready-state"></a> changes may trigger events on the HTMLMediaElement.</p>
</li>
<li>Playback may resume at this point if it was previously suspended by a transition to <a def-id="have-current-data"></a>.</li>
<li>Abort these steps.</li>
</ol>
</dd>
<dt>If <a def-id="hme-buffered"></a> contains a <a def-id="timerange"></a> that ends at the current playback position and does not have a range covering the time immediately after the current position:</dt>
<dd>
<ol>
<li>Set the <a def-id="ready-state"></a> attribute to <a def-id="have-current-data"></a>.
<p class="note">Per <a def-id="ready-states"></a> [[HTML51]] logic, <a def-id="ready-state"></a> changes may trigger events on the HTMLMediaElement.</p>
</li>
<li>Playback is suspended at this point since the media element doesn't have enough data to advance the <a def-id="media-timeline"></a>.</li>
<li>Abort these steps.</li>
</ol>
</dd>
</dl>
</section>
<section id="active-source-buffer-changes">
<h4>Changes to selected/enabled track state</h4>
<p>During playback <a def-id="activeSourceBuffers"></a> needs to be updated if the <a def-id="videoref" name="dom-videotrack-selected">selected video track</a>, the <a def-id="videoref" name="dom-audiotrack-enabled">enabled audio track(s)</a>, or a text track <a def-id="videoref" name="dom-texttrack-mode">mode</a> changes. When one or more of these changes occur the following steps need to be followed.</p>
<dl class="switch">
<dt>If the selected video track changes, then run the following steps:</dt>
<dd>
<ol>
<li>If the <a>SourceBuffer</a> associated with the previously selected video track is not associated with any other enabled tracks, run the following steps:
<ol>
<li>Remove the <a>SourceBuffer</a> from <a def-id="activeSourceBuffers"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>
</li>
</ol>
</li>
<li>If the <a>SourceBuffer</a> associated with the newly selected video track is not already in <a def-id="activeSourceBuffers"></a>, run the following steps:
<ol>
<li>Add the <a>SourceBuffer</a> to <a def-id="activeSourceBuffers"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="addsourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>
</li>
</ol>
</li>
</ol>
</dd>
<dt>If an audio track becomes disabled and the <a>SourceBuffer</a> associated with this track is not associated with any other enabled or selected track, then run the following steps:</dt>
<dd>
<ol>
<li>Remove the <a>SourceBuffer</a> associated with the audio track from <a def-id="activeSourceBuffers"></a>
</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>
</li>
</ol>
</dd>
<dt>If an audio track becomes enabled and the <a>SourceBuffer</a> associated with this track is not already in <a def-id="activeSourceBuffers"></a>, then run the following steps:
</dt>
<dd>
<ol>
<li>Add the <a>SourceBuffer</a> associated with the audio track to <a def-id="activeSourceBuffers"></a>
</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="addsourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>
</li>
</ol>
</dd>
<dt>If a text track <a def-id="videoref" name="dom-texttrack-mode">mode</a> becomes <a def-id="texttrackmode-disabled"></a> and the <a>SourceBuffer</a> associated with this track is not associated with any other enabled or selected track, then run the following steps:</dt>
<dd>
<ol>
<li>Remove the <a>SourceBuffer</a> associated with the text track from <a def-id="activeSourceBuffers"></a>
</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="removesourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>
</li>
</ol>
</dd>
<dt>If a text track <a def-id="videoref" name="dom-texttrack-mode">mode</a> becomes <a def-id="texttrackmode-showing"></a> or <a def-id="texttrackmode-hidden"></a> and the <a>SourceBuffer</a> associated with this track is not already in <a def-id="activeSourceBuffers"></a>, then run the following steps:
</dt>
<dd>
<ol>
<li>Add the <a>SourceBuffer</a> associated with the text track to <a def-id="activeSourceBuffers"></a>
</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="addsourcebuffer"></a> at <a def-id="activeSourceBuffers"></a>
</li>
</ol>
</dd>
</dl>
</section>
<section id="duration-change-algorithm">
<h4>Duration change</h4>
<p>Follow these steps when <a def-id="duration"></a> needs to change to a <var>new duration</var>.</p>
<ol>
<li>If the current value of <a def-id="duration"></a> is equal to <var>new duration</var>, then return.</li>
<li>If <var>new duration</var> is less than the highest <a def-id="presentation-timestamp"></a> of any buffered <a def-id="coded-frames"></a> for all <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a>, then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.
<p class="note">Duration reductions that would truncate currently buffered media are disallowed. When truncation is necessary, use <a def-id="remove"></a> to reduce the buffered range before updating <a def-id="duration"></a>.</p>
</li>
<li>Let <var>highest end time</var> be the largest <a def-id="track-buffer-ranges"></a> end time across all the <a def-id="track-buffers"></a> across all <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a>.</li>
<li>If <var>new duration</var> is less than <var>highest end time</var>, then
<p class="note">This condition can occur because the <a def-id="coded-frame-removal-algorithm"></a> preserves coded frames that start before the start of the removal range.</p>
<ol>
<li>Update <var>new duration</var> to equal <var>highest end time</var>.</li>
</ol>
</li>
<li>Update <a def-id="duration"></a> to <var>new duration</var>.</li>
<li>Update the <a def-id="hme-duration"></a> to <var>new duration</var> and run the <a def-id="hme-duration-change-algorithm"></a>.</li>
</ol>
</section>
<section id="end-of-stream-algorithm">
<h4>End of stream algorithm</h4>
<p>This algorithm gets called when the application signals the end of stream via an <a def-id="endOfStream"></a> call or an algorithm needs to
signal a decode error. This algorithm takes an <var>error</var> parameter that indicates whether an error will be signalled.</p>
<ol>
<li>Change the <a def-id="readyState"></a> attribute value to <a def-id="ended"></a>.</li>
<li>
<a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="sourceended"></a> at the <a>MediaSource</a>.</li>
<li><dl class="switch">
<dt>If <var>error</var> is not set</dt>
<dd>
<ol>
<li>Run the <a def-id="duration-change-algorithm"></a> with <var>new duration</var> set to
the largest <a def-id="track-buffer-ranges"></a> end time across all the <a def-id="track-buffers"></a> across all <a>SourceBuffer</a> objects in <a def-id="sourceBuffers"></a>.
<p class="note">This allows the duration to properly reflect the end of the appended media segments. For example, if the duration was explicitly set to 10 seconds and only media segments for 0 to 5 seconds were appended before endOfStream() was called, then the duration will get updated to 5 seconds.</p>
</li>
<li>Notify the media element that it now has all of the media data.</li>
</ol>
</dd>
<dt>If <var>error</var> is set to <a def-id="network"></a>
</dt>
<dd>
<dl class="switch">
<dt>If the <a def-id="ready-state"></a> attribute equals <a def-id="have-nothing"></a>
</dt>
<dd>Run the <a def-id="media-data-cannot-be-fetched"></a> steps of the <a def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
<dt>If the <a def-id="ready-state"></a> attribute is greater than <a def-id="have-nothing"></a>
</dt>
<dd>Run the "<i>If the connection is interrupted after some media data has been received, causing the user agent to give up trying to fetch the resource</i>" steps of the <a def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
</dl>
</dd>
<dt>If <var>error</var> is set to <a def-id="decode"></a>
</dt>
<dd>
<dl class="switch">
<dt>If the <a def-id="ready-state"></a> attribute equals <a def-id="have-nothing"></a>
</dt>
<dd>Run the "<i>If the media data can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all</i>" steps of the <a def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
<dt>If the <a def-id="ready-state"></a> attribute is greater than <a def-id="have-nothing"></a>
</dt>
<dd>Run the <a def-id="media-data-is-corrupted"></a> steps of the <a def-id="resource-fetch-algorithm"></a>'s <a def-id="media-data-processing-steps-list"></a>.</dd>
</dl>
</dd>
</dl>
</li>
</ol>
</section>
</section>
</section>
<section id="sourcebuffer">
<h2>SourceBuffer Object</h2>
<pre class="idl">enum AppendMode {
"segments",
"sequence"
};</pre><table class="simple" data-dfn-for="AppendMode" data-link-for="AppendMode"><tbody><tr><th colspan="2">Enumeration description</th></tr><tr><td><dfn><code id="idl-def-AppendMode.segments">segments</code></dfn></td><td>
<p>The timestamps in the media segment determine where the <a def-id="coded-frames"></a> are placed in the presentation. Media segments can be appended in any order.</p>
</td></tr><tr><td><dfn><code id="idl-def-AppendMode.sequence">sequence</code></dfn></td><td>
<p>Media segments will be treated as adjacent in time independent of the timestamps in the media segment. Coded frames in a new media segment will be placed immediately after the coded
frames in the previous media segment. The <a def-id="timestampOffset"></a> attribute will be updated if a new offset is needed to make the new media segments adjacent to the previous media segment.
Setting the <a def-id="timestampOffset"></a> attribute in <a def-id="AppendMode-sequence"></a> mode allows a media segment to be placed at a specific position in the timeline without any knowledge
of the timestamps in the media segment.
</p>
</td></tr></tbody></table>
<pre class="idl">interface SourceBuffer : EventTarget {
attribute AppendMode mode;
readonly attribute boolean updating;
readonly attribute TimeRanges buffered;
attribute double timestampOffset;
readonly attribute AudioTrackList audioTracks;
readonly attribute VideoTrackList videoTracks;
readonly attribute TextTrackList textTracks;
attribute double appendWindowStart;
attribute unrestricted double appendWindowEnd;
attribute EventHandler onupdatestart;
attribute EventHandler onupdate;
attribute EventHandler onupdateend;
attribute EventHandler onerror;
attribute EventHandler onabort;
void appendBuffer (BufferSource data);
void abort ();
void remove (double start, unrestricted double end);
};</pre><section><h2>Attributes</h2><dl class="attributes" data-dfn-for="SourceBuffer" data-link-for="SourceBuffer"><dt><dfn><code>mode</code></dfn> of type <span class="idlAttrType"><a>AppendMode</a></span></dt><dd>
<p>Controls how a sequence of <a def-id="media-segments"></a> are handled. This attribute is initially set by <a def-id="addSourceBuffer"></a> after the object is created.</p>
<p>On getting, Return the initial value or the last value that was successfully set.</p>
<p>On setting, run the following steps:</p>
<ol>
<li>If this object has been removed from the <a def-id="sourceBuffers"></a> attribute of the <a def-id="parent-media-source"></a>, then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>If the <a def-id="updating"></a> attribute equals true, then throw an <a def-id="invalid-state-error"></a> exception and abort these steps.</li>
<li>Let <var>new mode</var> equal the new value being assigned to this attribute.</li>
<li>If <a def-id="generate-timestamps-flag"></a> equals true and <var>new mode</var> equals
<a def-id="AppendMode-segments"></a>, then throw a <a def-id="type-error"></a>
exception and abort these steps.</li>
<li>
<p>If the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> is in the <a def-id="ended"></a> state then run the following steps:</p>
<ol>
<li>Set the <a def-id="readyState"></a> attribute of the <a def-id="parent-media-source"></a> to <a def-id="open"></a></li>
<li><a def-id="Queue-a-task-to-fire-an-event-named"></a> <a def-id="sourceopen"></a> at the <a def-id="parent-media-source"></a>.</li>
</ol>
</li>
<li>If the <a def-id="append-state"></a> equals <a def-id="parsing-media-segment"></a>, then throw an <a def-id="invalid-state-error"></a> and abort these steps.</li>
<li>If the <var>new mode</var> equals <a def-id="AppendMode-sequence"></a>, then set the <a def-id="group-start-timestamp"></a> to the <a def-id="group-end-timestamp"></a>.</li>
<li>Update the attribute to <var>new mode</var>.</li>
</ol>
</dd><dt><dfn><code>updating</code></dfn> of type <span class="idlAttrType"><a>boolean</a></span>, readonly </dt><dd>
<p>Indicates whether the asynchronous continuation of an <a def-id="appendBuffer"></a> or <a def-id="remove"></a>
operation is still being processed. This attribute is initially set to false when the object is created.</p>
</dd><dt><dfn><code>buffered</code></dfn> of type <span class="idlAttrType"><a>TimeRanges</a></span>, readonly </dt><dd>
<p>Indicates what <a def-id="timeranges"></a> are buffered in the <a>SourceBuffer</a>. This
attribute is initially set to an empty <a def-id="timeranges"></a> object when the object is