This API provides a way to embed a video source in a Tizen Web Application running on a device associated with the TV. It allows an available video source to be selected and shown on or hidden from the display in a Tizen Web Application. There will be a tizen.tvwindow object that allows access to the functionality of the TV Window API. To show a TV signal, execute the show function. A TV source is controlled by the user or by you with the Tizen Web Device APIs. You do not have to implement any routines if you do not want to interact with the TV image.
Since: 2.4
Code example:
- -
- -
-
------------------------
| |
| +---------+ |
| |TV window| |
| +---------+ |
| |
| YOUR APPLICATION |
| |
| |
------------------------
enum WindowType {
"MAIN",
};
Since: 2.4
enum MeasurementUnit {
"px",
"%"
};
Since: 2.4
enum AspectRatio{
"ASPECT_RATIO_1x1",
"ASPECT_RATIO_4x3",
"ASPECT_RATIO_16x9",
"ASPECT_RATIO_221x100"
};
Since: 2.4
enum ZPosition{
"FRONT",
"BEHIND"
};
Since: 2.4
[NoInterfaceObject] interface TVWindowManagerObject {
readonly attribute TVWindowManager tvwindow;
};
Tizen implements TVWindowManagerObject;
Since: 2.4
There will be a tizen.tvwindow object that allows access to the functionality of the TV Window API.
[NoInterfaceObject] interface TVWindowManager {
void getAvailableWindows(AvailableWindowListCallback successCallback,
optional ErrorCallback? errorCallback) raises(WebAPIException);
void setSource(SystemInfoVideoSourceInfo videoSource,
SourceChangedSuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional WindowType? type) raises (WebAPIException);
SystemInfoVideoSourceInfo getSource(optional WindowType? type) raises(WebAPIException);
void show(WindowRectangleSuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional DOMString[]? rectangle,
optional WindowType? type,
optional ZPosition? zPosition) raises(WebAPIException);
void hide(SuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional WindowType? type) raises(WebAPIException);
void getRect(WindowRectangleSuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional MeasurementUnit? unit,
optional WindowType? type) raises(WebAPIException);
VideoResolution getVideoResolution(optional WindowType? type) raises(WebAPIException);
long addVideoResolutionChangeListener(VideoResolutionChangeCallback callback,
optional WindowType? type) raises(WebAPIException);
void removeVideoResolutionChangeListener(long listenerId) raises(WebAPIException);
};
Since: 2.4
getAvailableWindows
void getAvailableWindows(AvailableWindowListCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
function successCB(availableWindows) {
for (var i = 0; i < availableWindows.length; i++) {
console.log("Window ["+ i + "] = " + availableWindows[i]);
}
}
try {
tizen.tvwindow.getAvailableWindows(successCB);
} catch (error) {
console.log("Error name = "+ error.name + ", Error message = " + error.message);
}
setSource
void setSource(SystemInfoVideoSourceInfo videoSource, SourceChangedSuccessCallback successCallback, optional ErrorCallback? errorCallback, optional WindowType? type);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError if any other error occurs.
Code example:
var connectedVideoSources;
function successCB(source, type) {
console.log("setSource() is successfully done. source name = " + source.name + ", source port number = " + source.number);
}
function errorCB(error) {
console.log("setSource() is failed. Error name = "+ error.name + ", Error message = " + error.message);
}
function systemInfoSuccessCB(videoSource) {
connectedVideoSources = videoSource.connected;
for (var i = 0; i < connectedVideoSources.length; i++) {
console.log("--------------- Source " + i + " ---------------");
console.log("type = " + connectedVideoSources[i].type);
console.log("number = " + connectedVideoSources[i].number);
if (connectedVideoSources[i].type === "HDMI") {
// set HDMI as input source of the TV window
tizen.tvwindow.setSource(connectedVideoSources[i], successCB, errorCB);
break;
}
}
}
function systemInfoErrorCB(error) {
console.log("getPropertyValue(VIDEOSOURCE) is failed. Error name = "+ error.name + ", Error message = " + error.message);
}
try {
tizen.systeminfo.getPropertyValue("VIDEOSOURCE", systemInfoSuccessCB, systemInfoErrorCB);
} catch (error) {
console.log("Error name = "+ error.name + ", Error message = " + error.message);
}
getSource
SystemInfoVideoSourceInfo getSource(optional WindowType? type);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Return value:
SystemInfoVideoSourceInfo The information about the current video sourceExceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError if any other error occurs.
Code example:
try {
var source = tizen.tvwindow.getSource();
console.log("type = " + source.type);
console.log("number = " + source.number);
} catch (error) {
console.log("Error name = "+ error.name + ", Error message = " + error.message);
}
show
void show(WindowRectangleSuccessCallback successCallback, optional ErrorCallback? errorCallback, optional DOMString[]? rectangle, optional WindowType? type, optional ZPosition? zPosition);
Since: 2.4
The rectangle array requires exactly four elements which are described below:
Each element of rectangle can be described in either absolute value by using pixel units "px" or relative value by using percentage units "%". If you do not specify any unit after a value then it will be taken as an absolute value.
The errorCallback is invoked with these error types:
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError if any other error occurs.
Code example:
function successCB(windowRect, type) {
// You will get exactly what you put as rectangle argument of show() through windowRect.
// expected result : ["0", "0px", "50%", "540px"]
console.log("Rectangle : [" + windowRect[0] + ", " + windowRect[1] + ", " + windowRect[2] + ", " + windowRect[3] + "]");
}
try {
tizen.tvwindow.show(successCB, null, ["0", "0px", "50%", "540px"], "MAIN");
} catch(error) {
console.log("error: " + error.name);
}
Code example:
function successCB(windowRect, type) {
// expected result : ["0", "0", "50%", "50%"]
console.log("Rectangle : [" + windowRect[0] + ", " + windowRect[1] + ", " + windowRect[2] + ", " + windowRect[3] + "]");
}
try {
tizen.tvwindow.show(successCB, null, ["0", "0", "50%", "50%"], "MAIN");
} catch(error) {
console.log("error: " + error.name);
}
Code example:
function successCB(windowRect, type) {
// expected result : ["10.5%", "10%", "900", "500px"]
console.log("Rectangle : [" + windowRect[0] + ", " + windowRect[1] + ", " + windowRect[2] + ", " + windowRect[3] + "]");
}
try {
tizen.tvwindow.show(successCB, null, ["10.5%", "10%", "900", "500px"]);
} catch(error) {
console.log("error: " + error.name);
}
hide
void hide(SuccessCallback successCallback, optional ErrorCallback? errorCallback, optional WindowType? type);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError if any other error occurs.
getRect
void getRect(WindowRectangleSuccessCallback successCallback, optional ErrorCallback? errorCallback, optional MeasurementUnit? unit, optional WindowType? type);
Since: 2.4
According to the specified unit, information about the area will be passed to an array that contains 4 strings through WindowRectangleSuccessCallback as follows :
If you omit unit, the pixel("px") unit will be used as a default unit.
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError if any other error occurs.
Code example:
function rectangleCB(windowRect, type) {
// You call getRect() without specifying a unit, it expresses the area information with pixel unit.
// expected result : ["0px", "0px", "960px", "540px"] if the screen resolution of a device is 1920 x 1080.
console.log("Rectangle : [" + windowRect[0] + ", " + windowRect[1] + ", " + windowRect[2] + ", " + windowRect[3] + "]");
}
function successCB(windowRect, type) {
// You will get exactly what you put as rectangle argument through windowRect.
// expected result : ["0", "0", "50%", "50%"]
console.log("Rectangle : [" + windowRect[0] + ", " + windowRect[1] + ", " + windowRect[2] + ", " + windowRect[3] + "]");
tizen.tvwindow.getRect(rectangleCB);
}
try {
tizen.tvwindow.show(successCB, null, ["0", "0", "50%", "50%"]);
} catch(error) {
console.log("error: " + error.name);
}
getVideoResolution
VideoResolution getVideoResolution(optional WindowType? type);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Return value:
VideoResolution current video resolution informationExceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError if any other error occurs.
Code example:
var res = tizen.tvwindow.getVideoResolution();
console.log("Video resolution: " + res.width + "x" + res.height + " pixels");
console.log("Frequency: " + res.frequency +"Hz");
if (res.aspectRatio === "ASPECT_RATIO_16x9") {
console.log("Widescreen on");
}
addVideoResolutionChangeListener
long addVideoResolutionChangeListener(VideoResolutionChangeCallback callback, optional WindowType? type);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Return value:
long The identifier of the resolution change listener.Exceptions:
with error type TypeMismatchError, if any input attribute is not compatible with the expected type for this attribute.
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError, if it fails to register a listener.
Code example:
function change(res, type) {
console.log("Switched to new resolution: " + res.width + "x" + res.height);
console.log("New frequency: " + res.frequency);
if (res.aspectRatio === "ASPECT_RATIO_16x9") {
console.log("Widescreen is now turned on");
}
}
try {
var watch = tizen.tvwindow.addVideoResolutionChangeListener(change);
} catch (error) {
console.log("Error name = "+ error.name + ", Error message = " + error.message);
}
removeVideoResolutionChangeListener
void removeVideoResolutionChangeListener(long listenerId);
Since: 2.4
Privilege level: public
Privilege: http://tizen.org/privilege/tv.window
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type UnknownError in any other error case.
[NoInterfaceObject] interface VideoResolution {
readonly attribute long width;
readonly attribute long height;
readonly attribute long frequency;
readonly attribute AspectRatio aspectRatio;
};
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
Since: 2.4
[Callback = FunctionOnly, NoInterfaceObject] interface VideoResolutionChangeCallback {
void onchanged(VideoResolution resolution, WindowType type);
};
Since: 2.4
onchanged
void onchanged(VideoResolution resolution, WindowType type);
Since: 2.4
Parameters:
[Callback = FunctionOnly, NoInterfaceObject] interface AvailableWindowListCallback {
void onsuccess(WindowType[] type);
};
Since: 2.4
onsuccess
void onsuccess(WindowType[] type);
Since: 2.4
Parameters:
[Callback = FunctionOnly, NoInterfaceObject] interface WindowRectangleSuccessCallback {
void onsuccess(DOMString[] windowRect, WindowType type);
};
Since: 2.4
onsuccess
void onsuccess(DOMString[] windowRect, WindowType type);
Since: 2.4
This method returns information windowRect and type. For more detailed information about windowRect, see the description of show().
Parameters:
[Callback = FunctionOnly, NoInterfaceObject] interface SourceChangedSuccessCallback {
void onsuccess(SystemInfoVideoSourceInfo source, WindowType type);
};
Since: 2.4
onsuccess
void onsuccess(SystemInfoVideoSourceInfo source, WindowType type);
Since: 2.4
This method returns information source and type.
Parameters:
To guarantee the running of this application on a device with a TV picture-in-picture support, define the following requirements in the config file:
For more information, see Application Filtering.
module TVWindow {
enum WindowType {
"MAIN",
};
enum MeasurementUnit {
"px",
"%"
};
enum AspectRatio{
"ASPECT_RATIO_1x1",
"ASPECT_RATIO_4x3",
"ASPECT_RATIO_16x9",
"ASPECT_RATIO_221x100"
};
enum ZPosition{
"FRONT",
"BEHIND"
};
[NoInterfaceObject] interface TVWindowManagerObject {
readonly attribute TVWindowManager tvwindow;
};
Tizen implements TVWindowManagerObject;
[NoInterfaceObject] interface TVWindowManager {
void getAvailableWindows(AvailableWindowListCallback successCallback,
optional ErrorCallback? errorCallback) raises(WebAPIException);
void setSource(SystemInfoVideoSourceInfo videoSource,
SourceChangedSuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional WindowType? type) raises (WebAPIException);
SystemInfoVideoSourceInfo getSource(optional WindowType? type) raises(WebAPIException);
void show(WindowRectangleSuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional DOMString[]? rectangle,
optional WindowType? type,
optional ZPosition? zPosition) raises(WebAPIException);
void hide(SuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional WindowType? type) raises(WebAPIException);
void getRect(WindowRectangleSuccessCallback successCallback,
optional ErrorCallback? errorCallback,
optional MeasurementUnit? unit,
optional WindowType? type) raises(WebAPIException);
VideoResolution getVideoResolution(optional WindowType? type) raises(WebAPIException);
long addVideoResolutionChangeListener(VideoResolutionChangeCallback callback,
optional WindowType? type) raises(WebAPIException);
void removeVideoResolutionChangeListener(long listenerId) raises(WebAPIException);
};
[NoInterfaceObject] interface VideoResolution {
readonly attribute long width;
readonly attribute long height;
readonly attribute long frequency;
readonly attribute AspectRatio aspectRatio;
};
[Callback = FunctionOnly, NoInterfaceObject] interface VideoResolutionChangeCallback {
void onchanged(VideoResolution resolution, WindowType type);
};
[Callback = FunctionOnly, NoInterfaceObject] interface AvailableWindowListCallback {
void onsuccess(WindowType[] type);
};
[Callback = FunctionOnly, NoInterfaceObject] interface WindowRectangleSuccessCallback {
void onsuccess(DOMString[] windowRect, WindowType type);
};
[Callback = FunctionOnly, NoInterfaceObject] interface SourceChangedSuccessCallback {
void onsuccess(SystemInfoVideoSourceInfo source, WindowType type);
};
};