Changes to this document may be tracked at https://github.com/w3c/tvapi.
Note: To be constructed.
This specification may not only focus on video channels but also include pure audio ones.
The EventHandler interface represents a callback used for event handlers as defined in [[!HTML5]].
The Event and EventTarget interfaces are defined in [[!DOM]].
The concepts queue a task and fire an event are defined in [[!HTML5]].
The terms event handler and event handler event types are defined in [[!HTML5]].
The Promise interface, the concepts of a resolver, a resolver's fulfill algorithm and a resolver's reject algorithm are defined in [[ECMAScript]].
The MediaStream interface is defined in [[!MediaCapture-Streams]].
The MediaRecorder interface is defined in [[MediaStream-Recording]].
The video element, and HTMLMediaElement, TimeRanges interfaces are defined in [[!HTML5]].
The TextTrack, TextTrackCue, and TrackEvent interfaces are defined in [[!HTML5]]
The TVManager interface represents a bunch of properties and a set of operations that can be used to manage the TV device.
Promise
that will be used to notify the caller about the result of the
operation, which is an array of TVTuner elements.
Promise
that will be used to notify the caller
about the result of the operation, which is a newly-created
TVRecording object.Promise
should be rejected. Applications may handle this situation with
their own strategy, such as explicitly removing the conflicts and
re-adding the one to conserve.
Promise
that will be used to notify the
caller about the result of the operation.
Promise
that will be used to notify the caller
about the result of the operation.
Promise
that will be used to notify the caller about
the result of the operation. Note that the Promise
may be rejected with an InvalidAccessError
if the old PIN
does not match the current one.
Promise
that will be used to notify
the caller about the result of the operation. Note that the
Promise
may be rejected with an
InvalidAccessError
if the PIN does not match the current one.
Promise
that will be used to notify
the caller about the result of the operation, which is an array of TVCICard elements.
tunerchanged
event of type
TVTunerChangedEvent, fired when the TV device detects a TV
tuner is added/removed.
recordingchanged
event of type
TVRecordingChangedEvent, fired when the recording time frame
or the state of the TV recording has been changed.
parentalcontrolchanged
event, fired when
the parental control status is changed.
cicardchanged
event, fired when
the CI (Common Interface) card status is changed.
The getTuners
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The addRecording
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
options
parameter.
value
argument.
value
argument.
The removeRecording
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The getRecordings
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
options
parameter.
value
argument.
value
argument.
The setParentalControlPin
method when invoked
MUST run the following steps:
Promise
object and
resolver be its associated resolver
.
newPin
parameter.
value
argument.
value
argument.
The setParentalControl
method when invoked
MUST run the following steps:
Promise
object and
resolver be its associated resolver
.
isLocked
parameter.
value
argument.
value
argument.
The getCICards
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The following are the event handlers (and their corresponding event types) that MUST be supported as attributes by the TVManager object.
Event handler | Event name | Event type | Short description |
---|---|---|---|
ontunerchanged |
tunerchanged |
TVTunerChangedEvent |
Handles the information of the TV tuner that is added/removed by the TV device. |
onrecordingchanged |
recordingchanged |
TVRecordingChangedEvent |
Handles the information of the updates for TV recordings. |
onparentalcontrolchanged |
parentalcontrolchanged |
Event |
Handles the information of the status changes for parental control. |
oncicardchanged |
cicardchanged |
TVCICardChangedEvent |
Handles the information of the status changes of the TV CI (Common Interface) card in the TV device. |
The TVTuner interface represents a bunch of properties and a set of operations related to the TV tuner.
Promise
that will be used to notify the caller about the result of the
operation, which is an array of TVSource elements that belong
to the TV tuner.
sourceType
parameter. It returns a
new Promise
that will be used to notify the caller
about the result of the operation.
TVMediaStream
object extended from
MediaStream
and currently streamed by the TV tuner,
which can be played by the video
element by
assigning
the TVMediaStream
(MediaStream
)
to the HTMLMediaElement
's srcObject
attribute and can be recorded by the MediaRecorder
.currentsourcechanged
event of type
TVCurrentSourceChangedEvent, fired when the method
setCurrentSource
is invoked to configure the
current TV source.
The getSources
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
TVSource
elements.
value
argument.
The setCurrentSource
method when invoked MUST
run the following steps:
Promise
object and
resolver be its associated resolver
.
sourceType
parameter.
value
argument.
value
argument.
The following are the event handlers (and their corresponding event types) that MUST be supported as attributes by the TVTuner object.
Event handler | Event name | Event type | Short description |
---|---|---|---|
oncurrentsourcechanged |
currentsourcechanged |
TVCurrentSourceChangedEvent |
Handles the information of the current TV source that is
configured by the method setCurrentSource .
|
The TVSource interface represents a bunch of properties and a set of operations related to the TV source.
Promise
that will be used to notify the caller about the result of the
operation, which is an array of TVChannel elements that
belong to the TV source. And if parental control is enabled, the
array of TVChannel elements should exclude the locked channels.
Note that the Promise
may be rejected with an
InvalidStateError
if this method gets called during
channel scanning.
channelNumber
parameter. It returns a
new Promise
that will be used to notify the caller
about the result of the operation. Note that the Promise
may be rejected with an InvalidStateError
if this
method is called during channel scanning, or be rejected with an
InvalidAccessError
if parental control is enabled and
the channel is locked.
options
parameter. It returns a new Promise
that will be used
to notify the caller about the result of the operation. Note that
this method has to be called first at some setup stages, so that the
method getChannels
can retrieve the channels
that have successfully been scanned by the TV source. Besides, due
to some constraints of tuner modules, scanning and streaming are not
encouraged to run at the same time.
isRescanned
option in the options
parameter specifies whether or not the process of scanning the
TV channels has to clear the currently scanned TV channels
before scanning; if it is not passed, this method will rescan
all the TV channels as if it is passed as true
.
Promise
that will be used
to notify the caller about the result of the operation.
currentchannelchanged
event of type
TVCurrentChannelChangedEvent, fired when the method
setCurrentChannel
is invoked to tune the
currently streamed TV channel.
eitbroadcasted
event of type
TVEITBroadcastedEvent, fired when the Event Information Table
(EIT) is broadcasted by the TV source.
emergencyalerted
event of type
TVEmergencyAlertedEvent, fired when an emergency, such as
earthquake or tsunami, occurs and is broadcasted by the TV source.
scanningstatechanged
event of type
TVScanningStateChangedEvent, fired when the state of scanning
the TV channels is changed by the TV source. E.g., it can be fired
when the method startScanning
or the method
stopScanning
starts or stops scanning the TV
channels, or when a channel is found during the channel scan.
The getChannels
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The setCurrentChannel
method when invoked MUST
run the following steps:
Promise
object and
resolver be its associated resolver
.
channelNumber
parameter.
value
argument.
value
argument.
The startScanning
method when invoked MUST
run the following steps:
Promise
object and
resolver be its associated resolver
.
options
parameter. If
the isRescanned
option in the options
parameter is not passed or it is passed as true
, the
user agent MUST
clear the currently scanned TV channels before scanning; if it is
passed as false
, the
user agent will
simply scan additional TV channels which haven't been scanned yet.
value
argument.
value
argument.
The stopScanning
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The following are the event handlers (and their corresponding event types) that MUST be supported as attributes by the TVSource object.
Event handler | Event name | Event type | Short description |
---|---|---|---|
oncurrentchannelchanged |
currentchannelchanged |
TVCurrentChannelChangedEvent |
Handles the information of the currently streamed TV channel
that is tuned by the method
setCurrentChannel .
|
oneitbroadcasted |
eitbroadcasted |
TVEITBroadcastedEvent |
Handles the information of the available TV programs in the EIT that is broadcasted by the TV source. |
onemergencyalerted |
emergencyalerted |
TVEmergencyAlertedEvent |
Handles the information of the emergency alert when an emergency, such as earthquake or tsunami, occurs and is broadcasted by the TV source. |
onscanningstatechanged |
scanningstatechanged |
TVScanningStateChangedEvent |
Handles the information of the state of scanning the TV channels, which is changed by the TV source. |
The TVChannel interface represents a bunch of properties and a set of operations related to the TV channel.
options
parameter.
It returns a new Promise
that will be used to notify
the caller about the result of the operation, which is an array of
TVProgram elements that belong to the TV channel.
Promise
that will be used to notify the caller about the result of the
operation, which is a TVProgram element that belongs to the
TV channel.
Promise
that will be used
to notify the caller about the result of the operation.
networkId
corresponds to an operator. On cable and terrestrial, where
different radio frequencies might be used in different regions,
operators typically use one networkId
per such region.
"CNN"
,
"NHK"
, etc.
"12-1"
, "12-2"
, etc.
parentallockchanged
event, fired when
the parental lock status of the TV channel is changed.
The getPrograms
method when invoked
MUST run the following steps:
Promise
object and
resolver be its associated resolver
.
options
parameter.
value
argument.
value
argument.
The getCurrentProgram
method when invoked
MUST run the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The setParentalLock
method when invoked MUST run the
following steps:
Promise
object and
resolver be its associated resolver
.
isLocked
parameter.
pin
parameter does not match the current PIN
or an error occurs invoke resolver's
reject algorithm
with error as the value
argument.
value
argument.
The following are the event handlers (and their corresponding event types) that MUST be supported as attributes by the TVChannel object.
Event handler | Event name | Event type | Short description |
---|---|---|---|
onparentallockchanged |
parentallockchanged |
Event |
Handles the information of the parental control status change for the TV channel. |
The TVProgram interface represents a bunch of properties and a set of operations related to the TV program.
The TVTriggerCue interface represents a bunch of properties and
a set of operations related to the TV trigger, which may be used to
carry some information via in-band or out-of-band mechanism based on the
current playing content. It's inherited from the
TextTrackCue
interface, which requires
startTime
and endTime
, and can be accessed by
the video
element by adding the
TextTrackCue
to the TextTrack
associated with the HTMLMediaElement
. Besides, the
TextTrack
can rely on its
oncuechange
event to realize a TV trigger becomes active or dismissed.
The TVRecording interface represents a bunch of properties and
a set of operations related to the TV recording. The recording should
automatically start recording at the specified start time. And it may
stop either at the specified end time, by an explicit stop()
call, or be interrupted by the user agent due to a channel switch
against the required underlying resource (i.e. the same tuner which the
recording channel belongs to since watching takes priority over
recording), or an error.
MediaStream
and can be played by the
video
element by
assigning
the TVMediaStream to the HTMLMediaElement
's
srcObject
attribute.
MUST return null if the TV recording hasn't actually
recorded anything. Note that the Promise
may be rejected with an InvalidAccessError
if parental
control is enabled and the recorded channel is locked.
stopped
.
recordingchanged
event of type
TVRecordingChangedEvent, fired when the recording time frame
or the state of the TV recording has been changed.
The getStream
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The stop
method when invoked MUST run
the following steps:
Promise
object and
resolver be its associated resolver
.
value
argument.
value
argument.
The following are the event handlers (and their corresponding event types) that MUST be supported as attributes by the TVRecording object.
Event handler | Event name | Event type | Short description |
---|---|---|---|
onrecordingchanged |
recordingchanged |
TVRecordingChangedEvent |
Handles the information of the updates for TV recordings. |
The TVMediaStream interface is an extended
MediaStream
with a buffering mechanism to support
basic seekability. It can be played by the video
element by
assigning
the TVMediaStream to the HTMLMediaElement
's
srcObject
attribute.
HTMLMediaElement
Attributes When Playing a TVMediaStream
The nature of no buffering of the MediaStream
places certain
restrictions
on the behavior and attribute values of the associated
HTMLMediaElement
and on the operations that can be
performed on it. Yet since TVMediaStream is with a
buffered mechanism to support basic seekability, it may be less
restrictive to some extent, as shown below:
Attribute Name | Attribute Type | Valid Values When Using a TVMediaStream | Additional considerations |
---|---|---|---|
currentSrc |
DOMString |
The empty string | When srcObject is specified the User Agent MUST set this to the empty string. (Same as MediaStream .) |
preload |
DOMString |
none | A TVMediaStream cannot be preloaded. (Same as MediaStream .) |
buffered |
TimeRanges |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
networkState |
unsigned short |
NETWORK_IDLE | The media element does not fetch the TVMediaStream so there is no network traffic. (Same as MediaStream .) |
readyState |
unsigned short |
HAVE_NOTHING, HAVE_ENOUGH_DATA | A TVMediaStream may be created before there is
any data available, for example when a stream is received from
a remote peer. The value of the readyState of the
media element MUST be HAVE_NOTHING before the first
media arrives and HAVE_ENOUGH_DATA once the first
media has arrived. (Same as MediaStream .) |
currentTime |
double |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
duration |
unrestricted double |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
seeking |
boolean |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
defaultPlaybackRate |
double |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
playbackRate |
double |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
played |
TimeRanges |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
seekable |
TimeRanges |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
loop |
boolean |
Same as HTMLMediaElement . |
Unlock the restriction applied by MediaStream . |
Applications may utilize TVRecording and TVMediaStream
to fulfill time-shifting scenarios. When time-shifting is enabled, it
may add a TV recording for the current playing channel without specifying
start time, which makes the recording starts from now on, or instead by
specifying the live TV program. (The user agent should be able to play
and record the same channel at the same time.) Then when it comes to
switch to the time-shifted content, the TVMediaStream
generated from the TV recording can be assigned to the video
element used for playing the current MediaStream
.
So the application may play with the video
element
to set proper playback rates, seek to specific time, play/pause the
buffered stream, and listen to some correspondent events. And when
time-shifting is switched off (i.e. the recorded content has been fast
forwarded to the current end), the application should assign the original
MediaStream
back to the video
element. Please note applications may need to regularly clean up old
TV recordings used for time-shifting.
The TVCICard interface represents a bunch of properties related to CI (Common Interface) card which is used to decrypt encrypted TV channel.
The TVStartScanningOptions dictionary contains the information for scanning the TV channels.
The TVGetProgramsOptions dictionary contains the information for retrieving the TV programs.
The TVAddRecordingOptions dictionary contains the information for adding a TV recording.
startTime
and endTime
.
program
is specified.
stop()
call of TVRecording or the user agent forces it to stop due to
resource control. Please note this could also be ommited and auto
determined if program
is specified.
The TVGetRecordingsOptions dictionary contains the information for retrieving the TV recordings.
The TVTunerChangedEvent interface represents the event related to the TV tuner that is added/removed by the TV device.
The TVCurrentSourceChangedEvent interface represents the event
related to the current TV source that is configured by the method
setCurrentSource
.
The TVEITBroadcastedEvent interface represents the event related to the available TV programs in the EIT that is broadcasted by the TV source.
TVProgram
instances. The cached value for this array
needs to go into an internal slot for the object, and it should be
cached there until the next time that the underlying array changes
when the cached value will be updated.
The TVEmergencyAlertedEvent interface represents the event related to the emergency alert that is broadcasted by the TV source.
The TVScanningStateChangedEvent interface represents the event related to the state of channel scanning, which is changed by the TV source.
state
is not
"scanned"
.
The TVCurrentChannelChangedEvent interface represents the event
related to the currently streamed TV channel that is tuned by the method
setCurrentChannel
.
The TVRecordingChangedEvent interface represents the event related to the update of a TV recording.
The TVCICardChangedEvent interface represents the event related to the changes in the state of the CI (Common Interface) card.
The attribute type
in the TVSource can have the
following values:
The attribute type
in a TVChannel can have the
following values:
The attribute operation
in the TVTunerChangedEvent
can have the following values:
The attribute state
in the
TVScanningStateChangedEvent can have the following values:
channel
attribute in the
TVScanningStateChangedEvent
object references the
channel found.
The attribute type
in the TVTriggerCue can have the
following values:
The attribute state
in TVRecording can have the
following values:
scheduled
or
canceled from recording
.
The attribute state
in TVCICard can have the
following values:
The following people have contributed to this draft specification through their participation in the TV Control API Community Group: Kazayuki Ashimura, Marco Chen, Daniel Davis, Francois Daoust, Yoshiharu Dewa, Paul Higgs, Bin Hu, Shelly Lin, Sangwhan Moon, Chris Needham, John Piesing.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes.
This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.
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.