-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
1899 lines (1718 loc) · 70.7 KB
/
index.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>
<title>TV Manager API</title>
<meta charset='utf-8'>
<script src='https://www.w3.org/Tools/respec/respec-w3c-common'
async class='remove'></script>
<script class="remove">
var respecConfig = {
specStatus: "unofficial", // "ED",
shortName: "TV Manager API", // needed for generated URLs
editors: [{
name: "Gene Lian",
company: "Mozilla",
companyURL: "http://www.mozilla.org",
// mailto: "[email protected]"
}],
publishDate: "", // no needed for "ED" or "unofficial"
edDraftURI: "http://airpingu.github.io/tv-tuner-api/index.html", // needed for "ED"
previousPublishDate: "", // needed for "WD", "LC", "CR"
previousMaturity: "", // needed for "WD", "LC", "CR"
lcEnd: "", // needed for "LC"
crEnd: "", // needed for "CR"
// wg: "System Applications Working Group",
// wgURI: "http://www.w3.org/2012/sysapps/",
// wgPublicList: "public-sysapps",
// wgPatentURI: "http://www.w3.org/2004/01/pp-impl/43696/status",
otherLinks: [{
key: "Repository",
data: [{
value: "We are on GitHub.",
href: "https://github.com/airpingu/tv-tuner-api/"
}, {
value: "File a bug.",
href: "https://github.com/airpingu/tv-tuner-api/issues"
}, {
value: "Commit history.",
href: "https://github.com/airpingu/tv-tuner-api/commits/gh-pages"
}]
}],
inlineCSS: true,
noIDLIn: true,
noIDLSorting: true
};
</script>
</head>
<!-----------------------------------------------------------------------------
Style guide to contributors:
============================
- this document uses ReSpec, see
http://dev.w3.org/2009/dap/ReSpec.js/documentation.html
- use 80 characters wide lines, whenever possible (except long links)
- keep sections 2 empty lines apart
- put comments in front of sections, for better readability with syntax coloring
editors
- use indentation with care: it may improve readability, but at the expense of
line lenght
- when descriptions of attributes is short, use the <dd> elements even when
the text also contains conformance statements (e.g. MUST, SHOULD, MAY).
No use repeating the same information in a separate paragraph.
------------------------------------------------------------------------------>
<body>
<!-- - - - - - - - - - - - - - - Abstract - - - - - - - - - - - - - - - - - -->
<section id="abstract">
The TV Manager API allows an application to manage the TV device.
</section>
<!-- - - - - - - - - - - - - - - Status of this document - - - - - - - - - - -->
<section id="sotd">
<font size=4 color="red">
This document is no longer maintained. Please refer to the
<a href="http://seanyhlin.github.io/tv-tuner-api/index.html">link</a>
for the latest specification.
</font>
</section>
<!-- - - - - - - - - - - - - - - Introduction - - - - - - - - - - - - - - - -->
<section class="informative">
<h2>Introduction</h2>
<p>
The TV Manager API interfaces provide a bunch of properties and a set of
operations to allow Web applications to acquire the information of TV
sources, TV channels and TV programs as well as to manage the native TV
hardwares (i.e., TV tuners) or the TV Web services.
</p>
<section>
<h3>User Cases</h3>
<p>
The TV Manager API is aimed to cover the following user cases:
</p>
<ul>
<li>
The web content is able to control the TV channel of the TV device
with the TV tuner.
</li>
<li>
One TV can have multiple TV tuners. For example, one is for watching
TV and the other is for recording.
</li>
<li>
TV Tuner can scan broadcasting channels, where each TV tuner can
have its own scanning algorithm provided by the vendor.
</li>
<li>
Web content needs to know which broadcasting types are supported by
the TV tuners.
</li>
<li>
Web content needs to know the information of Electronic Program
Guide (EPG) that is being broadcasted.
</li>
<li>
Users can navigate through the EPG and selects a program to watch.
</li>
<li>
Users can watch the broadcasting program while browsing through the
list of other programs that are currently broadcasted.
</li>
<li>
Web content needs to know if the currently displayed TV channel has
bad or no signal. Can be covered by VideoElement?
</li>
<li>
One TV channel can have multiple video/audio tracks in the
same broadcasting stream.
</li>
<li>
Emergency broadcasting for earthquake, tsunami... etc.
</li>
<li>
In the first step, only certified apps are allowed to use the TV
Manager API.
</li>
<li>
The DTV can keep track of the multiple TV tuners that a TV channel
can belong to, so that web content can do more flexible services
like: when the user is using the TV tuner A to watch and record a
certain TV channel at the same time, supposing the user wants to
switch to other channels to watch, the DTV should use the TV tuner
B to switch channels so that it won't stop the original recording
task on the TV tuner A.
</li>
<li>
EPG can be dynamically updated by the broadcasters. We need a way
to notify the web contents to update its EPG menu from time to time.
</li>
<li>
It is necessary to support multiple channels that can be
concurrently displayed on the TV (i.e. Picture-in-Picture).
</li>
<li>
DTV needs to connect to the broadcasters' remote servers to provide
more TV services through the Web. To do this, the web content needs
a universal way to identify the TV program.
</li>
</ul>
</section>
<section>
<h3>Examples</h3>
<p>
If an application has the privilege to use the TV Manager API, it can
use a bunch of basic methods defined in the <a>TVManager</a> to
manage the TV device.
</p>
<p>
The following example shows how to get all the TV tuners that are
currently available on the TV device and how to listen to the events
for the TV tuner changes.
</p>
<pre class="example highlight">
// An array which saves all the currently available TV tuners.
var curTuners = [];
// Set the 'ontunerchanged' event handler.
navigator.mozTV.ontunerchanged = function ontunerchanged(event) {
var operation = event.operation;
var changedTuner = event.tuner;
switch (operation) {
case "added":
curTuners.push(changedTuner);
break;
case "removed":
curTuners.some(function findTuner(tuner, index) {
if (tuner.id == changedTuner.id) {
curTuners.splice(index, 1);
return true;
}
return false;
});
break;
default:
break;
}
};
// Retrieve all the currently available TV tuners.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
curTuners = tuners;
tuners.forEach(function setEventHandler(tuner) {
// Set the 'oncurrentsourcechanged' event handler.
tuner.oncurrentsourcechanged = function oncurrentsourcechanged(event) {
alert("The current TV source of TV tuner: " + tuner.id +
" is configured to: " + event.source.type);
};
});
}, function onerror(error) {
alert(error);
});
</pre>
<p>
The following example shows how to get all the TV channels that are
currently available in the currently configured TV source of a TV
tuner and how to listen to the events for the TV channel changes.
</p>
<pre class="example highlight">
// A matrix which maps the TV tuner to its corresponding array of TV
// channels based on the currently configured TV source.
// E.g., { "tunerId1": [...], "tunerId2": [...] }.
var curChannelsOfTuners = {};
// Retrieve all the currently available TV tuners in the TV device.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
tuners.forEach(function getChannelsByTuner(tuner) {
var tunerId = tuner.id;
var currentSource = tuner.currentSource;
if (!currentSource) {
return;
}
// Set the 'onscanningstatechanged' event handler.
currentSource.onscanningstatechanged = function onscanningstatechanged(event) {
var state = event.state;
var scannedChannel = event.channel;
switch (state) {
case "cleared":
if (curChannelsOfTuners[tunerId]) {
delete curChannelsOfTuners[tunerId];
}
break;
case "scanned":
var channels = curChannelsOfTuners[tunerId];
if (channels) {
channels.push(scannedChannel);
} else {
curChannelsOfTuners[tunerId] = [scannedChannel];
}
break;
default:
break;
}
};
// Retrieve all the currently available TV channels in the
// currently configured TV source of the TV tuner.
currentSource.getChannels().then(function onsuccess(channels) {
curChannelsOfTuners[tunerId] = channels;
channels.forEach(function setEventHandler(channel) {
// Set the 'onprotectionstatechanged' event handler.
channel.onprotectionstatechanged = function onprotectionstatechanged(event) {
alert("The current protection state of TV channel: " + channel.name +
" is configured to: " + event.isProtected);
};
});
}, function onerror(error) {
alert(error);
});
});
}, function onerror(error) {
alert(error);
});
</pre>
<p>
The following example shows how to get all the TV programs that are
currently available in the TV channel and how to listen to the events
for the TV program changes.
</p>
<pre class="example highlight">
// A matrix which maps the TV channel to its corresponding array of TV
// programs. E.g., { "channelNumber1": [...], "channelNumber2": [...] }.
var curProgramsOfChannels = {};
// Retrieve all the currently available TV tuners in the TV device.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
if (tuners.length == 0) {
return;
}
// Just use the first TV tuner.
var tuner = tuners[0];
var currentSource = tuner.currentSource;
if (!currentSource) {
return;
}
// Set the 'oneitbroadcasted' event handler.
currentSource.oneitbroadcasted = function oneitbroadcasted(event) {
var newPrograms = event.programs;
// Flush the EPG because a new EIT is broadcasted by the TV source.
curProgramsOfChannels = {};
newPrograms.forEach(function addProgram(program) {
var channelNumber = program.channel.number;
var programs = curProgramsOfChannels[channelNumber];
if (programs) {
programs.push(program);
} else {
curProgramsOfChannels[channelNumber] = [program];
}
});
};
// Retrieve all the currently available TV channels in the currently
// configured TV source of the TV tuner.
currentSource.getChannels().then(function onsuccess(channels) {
channels.forEach(function getProgramsByChannel(channel) {
var channelNumber = channel.number;
// Retrieve all the currently available TV programs in the TV
// channel.
channel.getPrograms().then(function onsuccess(programs) {
curProgramsOfChannels[channelNumber] = programs;
}, function onerror(error) {
alert(error);
});
});
}, function onerror(error) {
alert(error);
});
});
</pre>
<p>
The following example shows how to play the <code>MediaStream</code>
of a TV source by assigning the <code>MediaStream</code> to a
<code>HTMLMediaElement</code>.
</p>
<pre class="example highlight">
<!DOCTYPE html>
<html>
<head>
<script>
// Retrieve all the currently available TV tuners first.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
if (tuners.length == 0) {
return;
}
// Just use the first TV tuner.
var tuner = tuners[0];
var video = document.getElementById("video-player");
video.srcObject = tuner.stream;
}, function onerror(error) {
alert(error);
});
</script>
</head>
<body>
<p><video id="video-player" autoplay></video></p>
</body>
</html>
</pre>
<p>
The following example shows how to scan and get all the TV channels
that are available in the currently configured TV source of the TV tuner.
</p>
<pre class="example highlight">
// Retrieve all the currently available TV tuners in the TV device.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
if (tuners.length == 0) {
return;
}
// Just use the first TV tuner.
var tuner = tuners[0];
var currentSource = tuner.currentSource;
if (!currentSource) {
return;
}
// Set the 'onscanningstatechanged' event handler.
currentSource.onscanningstatechanged = function onscanningstatechanged(event) {
var state = event.state;
var scannedChannel = event.channel;
switch (state) {
case "cleared":
alert("All the TV channels are cleared for rescanning.");
break;
case "scanned":
alert("A new TV channel is scanned: " + scannedChannel.name);
break;
case "completed":
alert("The scanning process is completed.");
break;
case "stopped":
alert("The scanning process is stopped.");
break;
default:
break;
}
};
if (currentSource.isScanning) {
return;
}
// Ask the currently configured TV source to scan the TV channels.
currentSource.startScanning({
isRescanned: true
}).then(function onsuccess() {
// Retrieve all the currently available TV channels in the
// currently configured TV source of the TV tuner.
currentSource.getChannels().then(function onsuccess(channels) {
alert("Succeeded to scan and get all the TV channels.");
}, function onerror(error) {
alert(error);
});
}, function onerror(error) {
alert(error);
});
});
</pre>
<p>
The following example shows how to tune the TV channel by the TV
channel number.
</p>
<pre class="example highlight">
// Retrieve all the currently available TV tuners.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
if (tuners.length == 0) {
return;
}
// Just use the first TV tuner.
var tuner = tuners[0];
var currentSource = tuner.currentSource;
if (!currentSource) {
return;
}
// Retrieve all the currently available TV channels in the currently
// configured TV source of the TV tuner.
currentSource.getChannels().then(function onsuccess(channels) {
if (channels.length == 0) {
return;
}
// Just use the first TV channel.
var channel = channels[0];
var channelNumber = channel.number.
// Tune the currently streamed TV channel based on the TV channel
// number.
currentSource.setCurrentChannel(channelNumber).then(function onsuccess() {
alert("Succeeded to tune the currently streamed TV channel.");
}, function onerror(error) {
alert(error);
});
}, function onerror(error) {
alert(error);
});
}, function onerror(error) {
alert(error);
});
</pre>
<p>
The following example shows how to unlock the TV parental control.
</p>
<pre class="example highlight">
// Retrieve all the currently available TV tuners.
navigator.mozTV.getTuners().then(function onsuccess(tuners) {
if (tuners.length == 0) {
return;
}
// Just use the first TV tuner.
var tuner = tuners[0];
var currentSource = tuner.currentSource;
if (!currentSource) {
return;
}
// This event handler will be triggered when the TV channel is tuned.
currentSource.oncurrentchannelchanged = function oncurrentchannelchanged(event) {
var changedCurrentChannel = event.channel;
if (navigator.mozTV.isParentalControlLocked &&
changedCurrentChannel.isProtected) {
// If the TV parental control is locked and the currently tuned
// TV channel is protected, the |tuner.stream|'s media tracks
// will be disabled (i.e. black screen). The UA can then pop up
// a prompt to ask the user to enter the password to unlock it.
alert("Parental control is locked. Please enter the password.");
// Unlock the TV parental control which will be applied system-wisely.
navigator.mozTV.unlockParentalControl().then(function onsuccess() {
alert("Parental control is unlocked until the next reboot.");
}, function onerror(error) {
alert(error);
});
}
};
// Retrieve all the currently available TV channels in the currently
// configured TV source of the TV tuner.
currentSource.getChannels().then(function onsuccess(channels) {
if (channels.length == 0) {
return;
}
// Just use the first TV channel.
var channel = channels[0];
var channelNumber = channel.number;
// Tune the currently streamed TV channel based on the TV channel
// number.
currentSource.setCurrentChannel(channelNumber).then(function onsuccess() {
alert("Succeeded to tune the currently streamed TV channel.");
}, function onerror(error) {
alert(error);
});
}, function onerror(error) {
alert(error);
});
}, function onerror(error) {
alert(error);
});
</pre>
</section>
</section>
<!-- - - - - - - - - - - - - - - Conformance - - - - - - - - - - - - - - - - -->
<section id="conformance">
<p>
This specification defines conformance criteria that apply to a single
product: the <dfn>user agent</dfn> that implements the interfaces that
it contains.
</p>
<p>
Implementations that use ECMAScript to implement the APIs defined in
this specification MUST implement them in a manner consistent with the
ECMAScript Bindings defined in the Web IDL specification [[!WEBIDL]], as
this specification uses that specification and terminology.
</p>
</section>
<!-- - - - - - - - - - - - - - - Terminology - - - - - - - - - - - - - - - -->
<section>
<h2>Terminology</h2>
<p>
The <dfn><a
href="http://dev.w3.org/html5/spec/webappapis.html#eventhandler">
EventHandler</a></dfn> interface represents a callback used for event
handlers as defined in [[!HTML5]].
</p>
<p>
The concepts <dfn><a
href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task"> queue
a task</a></dfn> and <dfn><a
href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">
fire an event</a></dfn> are defined in [[!HTML5]].
</p>
<p>
The terms <a
href="http://dev.w3.org/html5/spec/webappapis.html#event-handlers"><dfn
id="dfn-eventhandler">event handler</dfn></a> and <a
href="http://dev.w3.org/html5/spec/webappapis.html#event-handler-event-type">
<dfn id="dfn-eventtypes"> event handler event types</dfn></a> are
defined in [[!HTML5]].
</p>
<p>
The <dfn><a href="http://dom.spec.whatwg.org/#promise">Promise</a></dfn>
interface, the concepts of a <a href=
"http://dom.spec.whatwg.org/#concept-resolver"><dfn>resolver</dfn></a>, a
<dfn id="dfn-fulfill-algorithm"><a
href="http://dom.spec.whatwg.org/#concept-resolver-fulfill"> resolver's
fulfill algorithm</a></dfn> and a <dfn id="dfn-reject-algorithm"><a
href="http://dom.spec.whatwg.org/#concept-resolver-reject"> resolver's
reject algorithm</a></dfn> are defined in [[DOM4]].
</p>
</section>
<!-- - - - - - - - - - - - - Extended Interface Navigator - - - - - - - - - -->
<section>
<h2><a>Navigator</a> Interface</h2>
<dl title="partial interface Navigator" class="idl">
<dt>readonly attribute TVManager mozTV</dt>
<dd>
MUST return the object that exposes the interface to the TV service.
</dd>
</dl>
</section>
<!-- - - - - - - - - - - - - Interface TVManager - - - - - - - - - - - - - -->
<section>
<h2><a>TVManager</a> Interface</h2>
<p>
The <a>TVManager</a> interface represents a bunch of properties and
a set of operations that can be used to manage the TV device.
</p>
<dl title="interface TVManager : EventTarget" class="idl">
<dt>Promise getTuners ()</dt>
<dd>
This method makes a request to retrieve all the TV tuners that are
available in the TV device. It returns a new <code>Promise</code>
that will be used to notify the caller about the result of the
operation, which is an array of <a>TVTuner</a> elements.
</dd>
<dt>Promise unlockParentalControl ()</dt>
<dd>
This method makes a request to unlock the TV parental control by
popping up a prompt to ask the user to input the correct password.
Once the TV parental control is unlocked, it won't be locked until
the next reboot. It returns a new <code>Promise</code> that will be
used to notify the caller about the result of the operation.
</dd>
<dt>readonly attribute boolean isParentalControlLocked</dt>
<dd>
MUST return the current lock state of the TV parental control, which
is system-widely applied to the TV device (i.e., once the parental
control is unlocked, all the protected TV channels/programs will be
unlocked until the next reboot).
</dd>
<dt class="no-docs">
attribute EventHandler onparentalcontrolchanged
</dt>
<dd>
Handles the <code>onparentalcontrolchanged</code> event of type
<a>TVParentalControlChangedEvent</a>, fired when the method
<a><code>unlockParentalControl</code></a> is invoked to unlock the
TV parental control.
</dd>
<dt class="no-docs">
attribute EventHandler ontunerchanged
</dt>
<dd>
Handles the <code>ontunerchanged</code> event of type
<a>TVTunerChangedEvent</a>, fired when the TV device detects a TV
tuner is added/removed.
</dd>
</dl>
<section>
<h3>Steps</h3>
<p>
The <dfn><code>getTuners</code></dfn> method when invoked MUST run
the following steps:
</p>
<ol>
<li>
Let <var>promise</var> be a new <code>Promise</code> object and
<var>resolver</var> be its associated <code>resolver</code>.
</li>
<li>
Return <var>promise</var> to the caller.
</li>
<li>
Make a request to the TV device to retrieve all the TV tuners that
are available in the TV device.
</li>
<li>
If an <var>error</var> occurs invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-reject-algorithm">reject algorithm</a>
with <em>error</em> as the <code>value</code> argument.
</li>
<li>
When the request has been successfully completed:
</li>
<ol>
<li>
Let <var>tuners</var> be the array of the retrieved <a>TVTuner</a>
elements.
</li>
<li>
Invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-fulfill-algorithm"> fulfill algorithm</a>
with <em>tuners</em> as the <code>value</code> argument.
</li>
</ol>
</ol>
<p>
The <dfn><code>unlockParentalControl</code></dfn> method when invoked
MUST run the following steps:
</p>
<ol>
<li>
Let <var>promise</var> be a new <code>Promise</code> object and
<var>resolver</var> be its associated <code>resolver</code>.
</li>
<li>
Return <var>promise</var> to the caller.
</li>
<li>
Make a request to the TV device to unlock the TV parental control.
The <a class="internalDFN" href="#dfn-user-agent">user agent</a> has
to pop up a prompt to ask the user to input the password to unlock
the TV parental control.
</li>
<li>
If an <var>error</var> occurs invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-reject-algorithm">reject algorithm</a>
with <em>error</em> as the <code>value</code> argument.
</li>
<li>
When the request has been successfully completed:
</li>
<ol>
<li>
Invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-fulfill-algorithm"> fulfill algorithm</a>
without assigning a value to the <code>value</code> argument.
</li>
</ol>
</ol>
</section>
<section>
<h2>Event handlers</h2>
<p>The following are the <a class="internalDFN"
href="#dfn-eventhandler">event handlers</a> (and their corresponding <a
class="internalDFN" href="#dfn-eventtypes">event types</a>) that MUST be
supported as attributes by the <a>TVManager</a> object.
<table class="simple">
<thead>
<tr>
<th>Event handler</th>
<th>Event name</th>
<th>Event type</th>
<th>Short description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>ontunerchanged</code></strong></td>
<td><code><dfn id="dfn-change-event">tunerchanged</dfn></code></td>
<td><a><code>TVTunerChangedEvent</code></a></td>
<td>
Handles the information of the TV tuner that is added/removed
by the TV device.
</td>
</tr>
<tr>
<td><strong><code>onparentalcontrolchanged</code></strong></td>
<td><code><dfn id="dfn-change-event">parentalcontrolchanged</dfn></code></td>
<td><a><code>TVParentalControlChangedEvent</code></a></td>
<td>
Handles the information of the changed state of the TV parental
control.
</td>
</tr>
</tbody>
</table>
</section>
</section>
<!-- - - - - - - - - - - - Interface TVTuner - - - - - - - - - - - - -->
<section>
<h2><a>TVTuner</a> Interface</h2>
<p>
The <a>TVTuner</a> interface represents a bunch of properties and
a set of operations related to the TV tuner.
</p>
<dl title="interface TVTuner : EventTarget" class="idl">
<dt>Promise getSources ()</dt>
<dd>
This method makes a request to retrieve all the TV sources that are
available in the TV tuner. It returns a new <code>Promise</code>
that will be used to notify the caller about the result of the
operation, which is an array of <a>TVSource</a> elements that belong
to the TV tuner.
</dd>
<dt>Promise setCurrentSource ()</dt>
<dd>
This method makes a request to configure the current TV source of
the TV tuner by the <code>sourceType</code> parameter. It returns a
new <code>Promise</code> that will be used to notify the caller
about the result of the operation.
<dl class='parameters'>
<dt>TVSourceType sourceType</dt>
<dd>
Specifies the TV source type for configuring the current TV
source.
</dd>
</dl>
</dd>
<dt>readonly attribute DOMString id</dt>
<dd>
MUST return the ID of the TV tuner.
</dd>
<dt>readonly attribute TVSourceType[] supportedSourceTypes</dt>
<dd>
MUST return the types of the supported TV sources.
</dd>
<dt>readonly attribute TVSource? currentSource</dt>
<dd>
MUST return the currently configured TV source. MUST return
<em>null</em> if the TV source is not configured.
</dd>
<dt>readonly attribute MediaStream? stream</dt>
<dd>
MUST return a <a href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastream">MediaStream</a>
object that is currently streamed by the TV tuner, which can be
played by the <a href="http://dev.w3.org/html5/spec-preview/the-video-element.html#the-video-element">video</a>
element by assigning the <code>MediaStream</code> to the
<code>HTMLMediaElement</code> (<a href="http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreams-as-media-elements">details</a>) and can be recorded by the
<a href="https://dvcs.w3.org/hg/dap/raw-file/tip/media-stream-capture/MediaRecorder.html#MediaRecorderAPI">MediaRecorder</a>. MUST
return <em>null</em> if the TV tuner is not streaming any data,
which happens when the streaming signal is broken or due to
any other reasons that the TV tuner fails to stream the data.
</dd>
<dt class="no-docs">
attribute EventHandler oncurrentsourcechanged
</dt>
<dd>
Handles the <code>oncurrentsourcechanged</code> event of type
<a>TVCurrentSourceChangedEvent</a>, fired when the method
<a><code>setCurrentSource</code></a> is invoked to configure the
current TV source.
</dd>
</dl>
<section>
<h3>Steps</h3>
<p>
The <dfn><code>getSources</code></dfn> method when invoked MUST run
the following steps:
</p>
<ol>
<li>
Let <var>promise</var> be a new <code>Promise</code> object and
<var>resolver</var> be its associated <code>resolver</code>.
</li>
<li>
Return <var>promise</var> to the caller.
</li>
<li>
Make a request to the TV tuner to retrieve all the TV sources that
are available in the TV tuner.
</li>
<li>
If an <var>error</var> occurs invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-reject-algorithm">reject algorithm</a>
with <em>error</em> as the <code>value</code> argument.
</li>
<li>
When the request has been successfully completed:
</li>
<ol>
<li>
Let <var>sources</var> be the array of the retrieved
<a>TVSource</a> elements.
</li>
<li>
Invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-fulfill-algorithm"> fulfill algorithm</a>
with <em>channels</em> as the <code>value</code> argument.
</li>
</ol>
</ol>
<p>
The <dfn><code>setCurrentSource</code></dfn> method when invoked MUST
run the following steps:
</p>
<ol>
<li>
Let <var>promise</var> be a new <code>Promise</code> object and
<var>resolver</var> be its associated <code>resolver</code>.
</li>
<li>
Return <var>promise</var> to the caller.
</li>
<li>
Make a request to the TV tuner to configure the current TV source
according to the <code>sourceType</code> parameter.
</li>
<li>
If an <var>error</var> occurs invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-reject-algorithm">reject algorithm</a>
with <em>error</em> as the <code>value</code> argument.
</li>
<li>
When the request has been successfully completed:
</li>
<ol>
<li>
Invoke <em>resolver</em>'s <a
class="internalDFN" href="#dfn-fulfill-algorithm"> fulfill algorithm</a>
without assigning a value to the <code>value</code> argument.
</li>
</ol>
</ol>
</section>
<section>
<h2>Event handlers</h2>
<p>The following are the <a class="internalDFN"
href="#dfn-eventhandler">event handlers</a> (and their corresponding <a
class="internalDFN" href="#dfn-eventtypes">event types</a>) that MUST be
supported as attributes by the <a>TVTuner</a> object.
<table class="simple">
<thead>
<tr>
<th>Event handler</th>
<th>Event name</th>
<th>Event type</th>
<th>Short description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>oncurrentsourcechanged</code></strong></td>
<td><code><dfn id="dfn-change-event">currentsourcechanged</dfn></code></td>
<td><a><code>TVCurrentSourceChangedEvent</code></a></td>
<td>
Handles the information of the current TV source that is
configured by the method <a><code>setCurrentSource</code></a>.
</td>
</tr>
</tbody>
</table>
</section>
</section>
<!-- - - - - - - - - - - - Interface TVSource - - - - - - - - - - - - -->
<section>
<h2><a>TVSource</a> Interface</h2>
<p>
The <a>TVSource</a> interface represents a bunch of properties and a set
of operations related to the TV source.
</p>
<dl title="interface TVSource : EventTarget" class="idl">
<dt>Promise getChannels ()</dt>
<dd>
This method makes a request to retrieve all the TV channels that are
available in the TV source. It returns a new <code>Promise</code>
that will be used to notify the caller about the result of the
operation, which is an array of <a>TVChannel</a> elements that
belong to the TV source.
</dd>
<dt>Promise setCurrentChannel ()</dt>
<dd>