The Media Controller API provides functions for communication between the media controller server and the media controller client.
It helps to transfer the information like playback info, shuffle/repeat mode and metadata from media controller server to client. Allows to control server state by sending commands from client.
The media controller simple ability types. Simple means, that each ability is described by a single MediaControllerAbilitySupport value and is not a part of a complex ability structure.
Object representing features related to display rotation control of a media controller server.
Since: 5.5
Methods
getAllClientsInfo
Returns all existing clients info.
MediaControllerClientInfo[] getAllClientsInfo();
Since: 5.5
Remark: Code example available at sendEvent() method documentation.
Return value:
MediaControllerClientInfo[]: All existing clients info.
Exceptions:
WebAPIException
with error type UnknownError, if any platform error occurs.
updatePlaybackState
Updates playback state and send notification to the listening clients. See MediaControllerServerInfo.addPlaybackInfoChangeListener to check how to receive playback info changes from server on client side.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackState("PLAY");
console.log("Current playback state is: " + mcServer.playbackInfo.state);
Output example:
Current playback state is: PLAY
updateIconURI
Updates server icon URI.
void updateIconURI(DOMString? iconURI);
Since: 5.5
Parameters:
iconURI [nullable]: URI of the icon to be set.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackState("PLAY");
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
mcServer.updateIconURI("http://example.com/res/icon2.ico");
console.log(mcServerInfo.iconURI);
Output example:
http://example.com/res/icon2.ico
updatePlaybackPosition
Updates playback position and send notification to the listening clients.
void updatePlaybackPosition(unsigned long long position);
Since: 5.0
Parameters:
position: Playback position.
Exceptions:
WebAPIException
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackPosition(164);
console.log("Current playback position is: " + mcServer.playbackInfo.position);
Output example:
Current playback position is: 164
updatePlaybackAgeRating
Sets content age rating for current playback item.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackAgeRating("10");
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
console.log("Only viewers older than " + mcServerInfo.playbackInfo.ageRating +
" are allowed to access this content.");
Output example:
Only viewers older than 10 are allowed to access this content.
type: New content type for the current playback item.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackContentType("MUSIC");
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
console.log("Content type of current item is " + mcServerInfo.playbackInfo.contentType);
Output example:
Content type of current item is MUSIC
updateShuffleMode
Updates shuffle mode and send notification to the listening clients.
void updateShuffleMode(boolean mode);
Since: 5.0
Parameters:
mode: Shuffle mode.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updateShuffleMode(true);
console.log("Current shuffle mode is: " + mcServer.playbackInfo.shuffleMode);
Output example:
Current shuffle mode is: true
updateRepeatMode
Updates repeat mode and send notification to the listening clients.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
mcServer.updateRepeatState("REPEAT_ONE");
console.log("Current repeat state is: " + mcServer.playbackInfo.repeatState);
Output example:
Current repeat state is: REPEAT_ONE
updateMetadata
Updates metadata and send notification to the listening clients.
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
var metadata = mcServer.playbackInfo.metadata;
metadata.artist = "Artist Name";
mcServer.updateMetadata(metadata);
console.log("Current metadata is: " + JSON.stringify(mcServer.playbackInfo.metadata));
Output example:
Current metadata is: {"title":"","artist":"Artist Name","album":"","author":"","genre":"",
"duration":"","date":"","copyright":"","description":"","trackNum":"","picture":"",
"seasonNumber":0,"seasonTitle":"","episodeNumber":0,"episodeTitle":"","resolutionWidth":0,"resolutionHeight":0}
addChangeRequestPlaybackInfoListener
Adds the listener for a media playback info requests from client. See MediaControllerServerInfo to check how to send playback info change requests from client.
long addChangeRequestPlaybackInfoListener(MediaControllerChangeRequestPlaybackInfoCallback listener);
Since: 5.0
Parameters:
listener: Change request listener to add.
Return value:
long: The identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var playbackRequestListener =
{
onplaybackstaterequest: function(state, clientName)
{
console.log("Playback state requested to: " + state + " by " + clientName);
},
onplaybackpositionrequest: function(position, clientName)
{
console.log("Playback position requested to: " + position + " by " + clientName);
},
onshufflemoderequest: function(mode, clientName)
{
console.log("Shuffle mode requested to: " + mode + " by " + clientName);
},
onrepeatstaterequest: function(state, clientName)
{
console.log("Repeat state requested to: " + state + " by " + clientName);
},
onplaybackitemrequest: function(playlistName, index, state, position, clientName)
{
console.log("Playlist: " + playlistName + " index: " + index + " state: " + state +
" position " + position + " requested by " + clientName);
}
};
/* Registers to receive playback info change requests from client. */
watcherId = mcServer.addChangeRequestPlaybackInfoListener(playbackRequestListener);
removeChangeRequestPlaybackInfoListener
Removes the listener, so stop receiving playback state requests from clients.
listener: Function to be called for each search command received.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any of the arguments has invalid type.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
function searchRequestListener(clientName, request)
{
console.log("name of the client application which sent the request: " + clientName);
console.log("search command received.");
request.forEach(filter =>
{
console.log("filter: " + JSON.stringify(filter));
});
}
mcServer.setSearchRequestListener(searchRequestListener);
unsetSearchRequestListener
Unsets search request listener.
void unsetSearchRequestListener();
Since: 5.5
Calling this function has no effect if the listener was not set.
Exceptions:
WebAPIException
with error type UnknownError, if unknown error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
function searchRequestListener(clientName, request)
{
console.log("search command received.");
}
mcServer.setSearchRequestListener(searchRequestListener);
mcServer.unsetSearchRequestListener();
addCommandListener
Adds the listener for receiving custom commands from client. See MediaControllerServerInfo to check how to send custom commands from client.
long addCommandListener(MediaControllerReceiveCommandCallback listener);
Since: 5.0
Parameters:
listener: Custom commands listener to add.
Return value:
long: The identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var commandReceiveListener = function(clientName, command, data)
{
console.log("Command " + command + " received from: " + clientName + " with data: " +
JSON.stringify(data));
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({myReply: "someValue"}), 0);
};
/* Registers to receive custom commands from client. */
watcherId = mcServer.addCommandListener(commandReceiveListener);
removeCommandListener
Removes the listener, so stop receiving custom commands from clients.
void removeCommandListener(long watchId);
Since: 5.0
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Subscription identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var commandReceiveListener = function(clientName, command, data)
{
console.log("Command " + command + " received from: " + clientName + " with data: " +
JSON.stringify(data));
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({myReply: "someValue"}), 0);
};
/* Registers to receive custom commands from client. */
watcherId = mcServer.addCommandListener(commandReceiveListener);
/* Cancels the watch operation. */
mcServer.removeCommandListener(watcherId);
Remark: Please note that there is a need to use savePlaylist(), otherwise playlist creation will have no effect on a device. All playlists will be deleted after application is closed.
Parameters:
name: Name of the new playlist.
Return value:
MediaControllerPlaylist: New empty MediaControllerPlaylist object with given name.
Exceptions:
WebAPIException
with error type InvalidValuesError, if playlist with given name already exists.
with error type UnknownError, if any other error occurs.
Code example:
var mcServer = tizen.mediacontroller.createServer();
var playlist = mcServer.createPlaylist("testPlaylistName");
The media controller client API and functions related with handling media control. Functions include operations to get the latest status of the media controller servers.
successCallback: The method to invoke when all of the registered media controller servers have been found.
errorCallback [optional][nullable]: The method to invoke on failure of retrieving servers list.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcClient;
try
{
mcClient = tizen.mediacontroller.getClient();
}
catch (err)
{
console.log(err.name + " error: " + err.message);
}
function successCallback(list)
{
for (var s in list)
{
console.log("Found server: " + list\[s\].name + ", state: " + list\[s\].state);
}
}
function errorCallback(err)
{
console.log(err.name + " error: " + err.message);
}
mcClient.findServers(successCallback, errorCallback);
Output example:
Found server: og8WN4XlLg.BasicUIStudio, state: ACTIVE
getLatestServerInfo
Gets the latest activated media controller server info.
MediaControllerServerInfo? getLatestServerInfo();
Since: 5.0
Remark: If there is no activated media controller server, null value is returned.
Return value:
MediaControllerServerInfo [nullable]: Server info or null.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
/\* Access latest server info. */
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
console.log(
"Latest server name is: " + mcServerInfo.name + ", server state: " + mcServerInfo.state);
Output example:
Latest server name is: 2cpQcelP8a.HelloTizen, server state: INACTIVE
addAbilityChangeListener
Adds a listener to be invoked when ability of the media controller server is changed.
long addAbilityChangeListener(MediaControllerAbilityChangeCallback listener);
Since: 5.5
Remark: Implicitly the media controller client will receive information about ability changes of every active media controller server. To receive information only from selected servers, calling function subscribe() is required.
Parameters:
listener: Function to call on mediacontroller server's ability change.
Return value:
long: The identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
The ErrorCallback may be triggered for one of the following errors:
UnknownError: if any error prevents function from successful completion.
Parameters:
successCallback: The method to invoke when all of subscribed media controller servers have been found.
errorCallback [optional][nullable]: The method to invoke on failure of retrieving servers list.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcClient = tizen.mediacontroller.getClient();
var listener =
{
onsimpleabilitychanged: function(server, type, ability)
{
console.log(type + " ability changed, server name: " + server.name + ", ability: " + ability);
}
};
var watchId = mcClient.addAbilityChangeListener(listener);
function errorCB(err)
{
console.log(err.name + " error: " + err.message);
}
function subscribedSuccessCB(list)
{
console.log("Subscribed servers:");
for (var s in list)
{
console.log(" server name: " + list\[s\].name + ", state: " + list\[s\].state);
}
}
function findSuccessCB(list)
{
console.log("Found servers:");
for (var s in list)
{
console.log(" server name: " + list\[s\].name + ", state: " + list\[s\].state);
}
if (list.length > 0)
{
list\[0\].abilities.subscribe();
mcClient.findSubscribedServers(subscribedSuccessCB, errorCB);
}
}
mcClient.findServers(findSuccessCB, errorCB);
Output example:
Found servers:
server name: XX8qUW5iFF.MediaControllerServerOne, state: ACTIVE
server name: 2cpQcelP8a.MediaControllerServerTwo, state: ACTIVE
server name: To0BJCUxbR.MediaControllerServerThree, state: ACTIVE
Subscribed servers:
server name: XX8qUW5iFF.MediaControllerServerOne, state: ACTIVE
setCustomEventListener
Sets the media controller client's listener for custom events from the server.
If the listener has already been set, calling this method will override it.
Parameters:
listener: Event handling function.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any of the arguments has invalid types.
with error type UnknownError, if any other error occurs.
Code example:
/\* this example assumes that the server and client objects already exist. */
mcClient.setCustomEventListener(function(serverName, eventName, data)
{
return new tizen.mediacontroller.RequestReply({"reply": "data"}, 123);
});
mcClient.unsetCustomEventListener();
unsetCustomEventListener
Removes the server's events listener.
void unsetCustomEventListener();
Since: 5.5
Calling this function has no effect, if the listener is not set.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
/\* this example assumes that the server and client already exist. */
mcClient.setCustomEventListener(function(serverName, eventName, data)
{
return new tizen.mediacontroller.RequestReply({"reply": "data"}, 123);
});
mcClient.unsetCustomEventListener();
2.5. MediaControllerServerInfo
This interface provides media controller server state and playback info. Provides methods to send commands to server and listen for server status change.
Remark: See addCommandListener() method to check how to receive and respond to custom commands.
Parameters:
command: Custom command name which is handled on server side.
data [nullable]: Additional data for custom command which is send to server.
successCallback: The method to invoke when server responded to custom command.
errorCallback [optional][nullable]: The method to invoke on operation failure.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
var exampleCustomCommandData = new tizen.Bundle({myFilter: "rock"});
mcServerInfo.sendCommand("myPlaylistFilter", exampleCustomCommandData,
function(data, code)
{
console.log(
"Server replied with return data: " + JSON.stringify(data) + " and code: " + code);
},
function(e)
{
console.log("Error executing command: " + e.message);
});
addServerStatusChangeListener
Adds the listener for a media controller server status change.
long addServerStatusChangeListener(MediaControllerServerStatusChangeCallback listener);
Since: 5.0
Parameters:
listener: Status change listener to add.
Return value:
long: The identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
/\* Registers to be notified when server status changes. */
watcherId = mcServerInfo.addServerStatusChangeListener(function(status)
{
console.log(mcServerInfo.name + " server status changed to " + status);
});
removeServerStatusChangeListener
Removes the listener, so stop receiving notifications about media controller server status.
void removeServerStatusChangeListener(long watchId);
Since: 5.0
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Subscription identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
/\* Registers to be notified when server status changes. */
watcherId = mcServerInfo.addServerStatusChangeListener(function(status)
{
console.log(mcServerInfo.name + " server status changed to " + status);
});
/\* Cancels the watch operation. */
mcServerInfo.removeServerStatusChangeListener(watcherId);
addPlaybackInfoChangeListener
Adds the listener for a media playback info changes.
long addPlaybackInfoChangeListener(MediaControllerPlaybackInfoChangeCallback listener);
Since: 5.0
Parameters:
listener: Status change listener to add.
Return value:
long: The identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
var playbackListener =
{
onplaybackchanged: function(state, position)
{
console.log("Current playback state: " + state);
console.log("Current playback position: " + position);
},
onshufflemodechanged: function(mode)
{
console.log("Shuffle mode changed to: " + mode);
},
onrepeatstatechanged: function(state)
{
console.log("Repeat state changed to: " + state);
},
onmetadatachanged: function(metadata)
{
console.log("Playback metadata changed: " + JSON.stringify(metadata));
}
};
/* Registers to be notified when playback state changes. */
watcherId = mcServerInfo.addPlaybackInfoChangeListener(playbackListener);
removePlaybackInfoChangeListener
Removes the listener, so stop receiving notifications about media playback info changes.
Deprecated. Deprecated since 5.5. Instead, use repeatState.
Any change in value of repeatMode will also change the value of repeatState.
The repeatMode equal to true is equivalent to repeatState equal to REPEAT_ALL and repeatMode equal to false is equivalent to repeatState equal to REPEAT_OFF.
Since: 5.0
readonly MediaControllerRepeatState repeatState
Current repeat state.
Any change in value of repeatState will also change the value of repeatMode, except the REPEAT_ONE value. In this case the repeatMode value will not change.
The repeatState equals to REPEAT_ALL is equivalent to repeatMode equals to true and repeatState equals to REPEAT_OFF is equivalent to repeatMode equals to false.
Default value is REPEAT_ALL.
Since: 5.5
readonly MediaControllerMetadata metadata
Current playback metadata.
Since: 5.0
readonly DOMString index [nullable]
Current item index.
Since: 5.5
Remark: Null if no item currently in playback.
readonly DOMString playlistName [nullable]
Current playlist name.
Since: 5.5
Remark: Null if no item currently in playback.
2.7. MediaControllerAbilities
Server-side object representing abilities of the media controller server.
Remark: Calling saveAbilities() is required to update playback abilities on the media controller server.
Attributes
DOMString play
Represents server's ability to perform PLAY action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString pause
Represents server's ability to perform PAUSE action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString stop
Represents server's ability to perform STOP action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString next
Represents server's ability to perform NEXT action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString prev
Represents server's ability to perform PREV action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString forward
Represents server's ability to perform FORWARD action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString rewind
Represents server's ability to perform REWIND action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
DOMString togglePlayPause
Represents server's ability to perform TOGGLE_PLAY_PAUSE action.
Default value is UNDECIDED.
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if set value will not be compatible with MediaControllerAbilitySupport enum.
with error type InvalidValuesError, if set value will be "UNDECIDED".
with error type UnknownError, if any other error occurs.
Methods
saveAbilities
Saves the current state of playback abilities to the database.
void saveAbilities();
Since: 5.5
Remark: Using this function is required to save changes of playback abilities into database, otherwise changes will have no effect on the device and clients will not be notified about an update.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
with error type UnknownError, if any other error occurs.
unsubscribe
Removes a subscription for monitoring status of all abilities of server represented by this object.
void unsubscribe();
Since: 5.5
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
/\* Code example uses two applications: */
/\* XX8qUW5iDD.FirstMCServer - both server and client app */
/\* GC8qUW5iQf.SecondMCServer - only server app */
/\* APP XX8qUW5iDD.FirstMCServer */
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackState("PLAY");
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
var listener =
{
onsimpleabilitychanged: function(server, type, ability)
{
console.log(type + " ability changed, server name: " + server.name + ", ability: " + ability);
}
};
var watchId = mcClient.addAbilityChangeListener(listener);
console.log("#### All events would be handled by listener ####");
mcServer.abilities.shuffle = "YES"; /* triggers listener */
/\* APP GC8qUW5iQf.SecondMCServer */
var server2 = tizen.mediacontroller.createServer();
server2.abilities.repeat = "NO"; /* triggers listener */
/\* APP XX8qUW5iDD.FirstMCServer */
console.log("#### Subscribe only changes from XX8qUW5iDD.FirstMCServer ####");
mcServerInfo.abilities.subscribe();
mcServer.abilities.shuffle = "NO"; /* triggers listener */
/\* APP GC8qUW5iQf.SecondMCServer */
server2.abilities.repeat = "YES"; /* does NOT trigger listener */
/\* APP XX8qUW5iDD.FirstMCServer */
console.log("#### Handle all events again ####");
mcServerInfo.abilities.unsubscribe();
mcServer.abilities.shuffle = "YES"; /* triggers listener */
/\* APP GC8qUW5iQf.SecondMCServer */
server2.abilities.repeat = "NO"; /* triggers listener */
Output example:
#### All events would be handled by listener ####
SHUFFLE ability changed, server name: XX8qUW5iDD.FirstMCServer, ability: "YES"
REPEAT ability changed, server name: GC8qUW5iQf.SecondMCServer, ability: "NO"
#### Subscribe only changes from XX8qUW5iDD.FirstMCServer ####
SHUFFLE ability changed, server name: XX8qUW5iDD.FirstMCServer, ability: "NO"
#### Handle all events again ####
SHUFFLE ability changed, server name: XX8qUW5iDD.FirstMCServer, ability: "YES"
REPEAT ability changed, server name: GC8qUW5iQf.SecondMCServer, ability: "NO"
2.12. MediaControllerPlaybackAbilitiesInfo
Client-side object representing playback abilities of the media controller server.
State of subtitles mode on the server. Default value for a newly created server is false.
Since: 5.5
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Methods
addChangeRequestListener
Adds the listener for change requests of a media controller subtitles mode.
long addChangeRequestListener([MediaControllerEnabledChangeRequestCallback](#MediaControllerEnabledChangeRequestCallback) listener);
Since: 5.5
Remark: Remember to set corresponding server's MediaControllerAbilities.subtitles ability to "YES" to let clients send change requests to the server.
Parameters:
listener: Change request listener to add.
Return value:
long: The identifier used to remove the listener.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, enabled)
{
console.log("Subtitles mode change requested to: " + enabled + " by " + clientName);
var result = false;
/\* do some action here and return according to the result */
if (!result)
{
return new tizen.mediacontroller.RequestReply(
new tizen.Bundle({"message": "Error - Not allowed"}), 13);
}
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to subtitles mode change requests from client. */
watcherId = mcServer.subtitles.addChangeRequestListener(changeListener);
removeChangeRequestListener
Removes the listener and stops receiving change requests of media controller subtitles mode.
void removeChangeRequestListener(long watchId);
Since: 5.5
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Watcher identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, enabled)
{
console.log("Subtitles mode change requested to: " + enabled + " by " + clientName);
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to receive subtitles mode change requests from clients. */
watcherId = mcServer.subtitles.addChangeRequestListener(changeListener);
/* Cancels the watch operation. */
mcServer.subtitles.removeChangeRequestListener(watcherId);
2.16. MediaControllerSubtitlesInfo
Client-side object representing subtitles mode of a media controller server.
State of spherical (360°) mode on the server. Default value for a newly created server is false.
Since: 5.5
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Methods
addChangeRequestListener
Adds the listener for change requests of a media controller spherical (360°) mode.
long addChangeRequestListener(MediaControllerEnabledChangeRequestCallback listener);
Since: 5.5
Remark: Remember to set corresponding server's MediaControllerAbilities.mode360 ability to "YES" to let clients send change requests to the server.
Parameters:
listener: Change request listener to add.
Return value:
long: The identifier used to remove the listener.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, enabled)
{
console.log("Spherical mode change requested to: " + enabled + " by " + clientName);
var result = false;
/\* do some action here and return according to the result */
if (!result)
{
return new tizen.mediacontroller.RequestReply(
new tizen.Bundle({"message": "Error - Not allowed"}), 13);
}
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to receive spherical mode change requests from clients. */
watcherId = mcServer.mode360.addChangeRequestListener(changeListener);
removeChangeRequestListener
Removes the listener and stops receiving change requests of media controller spherical (360°) mode.
void removeChangeRequestListener(long watchId);
Since: 5.5
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Watcher identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, enabled)
{
console.log("Spherical mode change requested to: " + enabled + " by " + clientName);
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to receive spherical mode change requests from clients. */
watcherId = mcServer.mode360.addChangeRequestListener(changeListener);
/* Cancels the watch operation. */
mcServer.mode360.removeChangeRequestListener(watcherId);
2.18. MediaControllerMode360Info
Client-side object representing spherical (360°) mode of a media controller server.
enabled: State which is requested by a media controller client.
replyCallback: The method to invoke when server responded to change request.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type NotSupportedError, if related ability is not supported by the media controller server.
with error type UnknownError, if any other error occurs.
Code example:
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
var enabled = true;
mcServerInfo.mode360.sendRequest(enabled, function(data, code)
{
console.log("Server replied with return data: " + JSON.stringify(data) + " and code: " + code);
});
addModeChangeListener
Adds the listener for changes of a media controller spherical (360°) mode of a media controller server.
long addModeChangeListener(MediaControllerEnabledChangeCallback listener);
Since: 5.5
Parameters:
listener: Spherical (360°) mode change listener to add.
Return value:
long: The identifier used to clear the watch subscription.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
/\* Registers to be notified when spherical mode changes. */
watcherId = mcServerInfo.mode360.addModeChangeListener(function(enabled)
{
console.log(mcServerInfo.name + " server spherical mode changed to " + enabled);
});
removeModeChangeListener
Removes the listener, so stop receiving notifications about media controller server spherical (360°) mode changes.
void removeModeChangeListener(long watchId);
Since: 5.5
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Watcher identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcClient = tizen.mediacontroller.getClient();
var mcServerInfo = mcClient.getLatestServerInfo();
/* Registers to be notified when spherical mode changes. */
watcherId = mcServerInfo.mode360.addModeChangeListener(function(enabled)
{
console.log(mcServerInfo.name + " server spherical mode changed to " + enabled);
});
/* Cancels the watch operation. */
mcServerInfo.mode360.removeModeChangeListener(watcherId);
2.19. MediaControllerDisplayMode
Server-side object representing display mode of a media controller server.
[NoInterfaceObject] interface MediaControllerDisplayMode {
attribute MediaControllerDisplayModeType type raises(WebAPIException);
long addChangeRequestListener(MediaControllerDisplayModeChangeRequestCallback listener) raises(WebAPIException);
void removeChangeRequestListener(long watchId) raises(WebAPIException);
};
Since: 5.5
Attributes
MediaControllerDisplayModeType type
Type of display mode on the server. Default value for a newly created server is "FULL_SCREEN".
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if an input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Methods
addChangeRequestListener
Adds the listener for change requests of the media controller display mode.
long addChangeRequestListener(MediaControllerDisplayModeChangeRequestCallback listener);
Since: 5.5
Remark: Remember to set corresponding server's display mode ability to "YES" to let clients send change requests to the server.
Parameters:
listener: Change request listener to add.
Return value:
long: The identifier used to remove the listener.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, type)
{
console.log("Display mode change requested to: " + type + " by " + clientName);
var result = false;
/\* do some action here and return according to the result */
if (!result)
{
return new tizen.mediacontroller.RequestReply(
new tizen.Bundle({"message": "Error - Not allowed"}), 13);
}
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to receive display mode change requests from clients. */
watcherId = mcServer.displayMode.addChangeRequestListener(changeListener);
removeChangeRequestListener
Removes the listener and stops receiving change requests of media controller display mode.
void removeChangeRequestListener(long watchId);
Since: 5.5
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Watcher identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, type)
{
console.log("Display mode change requested to: " + type + " by " + clientName);
};
/* Registers to receive display mode change requests from clients. */
watcherId = mcServer.displayMode.addChangeRequestListener(changeListener);
/* Cancels the watch operation. */
mcServer.displayMode.removeChangeRequestListener(watcherId);
2.20. MediaControllerDisplayModeInfo
Client-side object representing display mode of a media controller server.
State of display rotation on the server. Default value for a newly created server is "ROTATION_NONE".
Since: 5.5
Exceptions:
WebAPIException
with error type TypeMismatchError, if an input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Methods
addChangeRequestListener
Adds the listener for change requests of a media controller display rotation.
long addChangeRequestListener(MediaControllerDisplayRotationChangeRequestCallback listener);
Since: 5.5
Remark: Remember to set corresponding server's display rotation ability to "YES" to let clients send change requests to the server.
Parameters:
listener: Change request listener to add.
Return value:
long: The identifier used to remove the listener.
Exceptions:
WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if any other error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, rotation)
{
console.log("Display rotation change requested to: " + rotation + " by " + clientName);
var result = false;
/\* do some action here and return according to the result */
if (!result)
{
return new tizen.mediacontroller.RequestReply(
new tizen.Bundle({"message": "Error - Not allowed"}), 13);
}
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to receive display rotation change requests from clients. */
watcherId = mcServer.displayRotation.addChangeRequestListener(changeListener);
removeChangeRequestListener
Removes the listener and stops receiving change requests of media controller display rotation.
void removeChangeRequestListener(long watchId);
Since: 5.5
Calling this function has no effect if there is no listener with given id.
Parameters:
watchId: Watcher identifier.
Exceptions:
WebAPIException
with error type UnknownError, if any error occurs.
Code example:
var watcherId = 0; /* Watcher identifier. */
var mcServer = tizen.mediacontroller.createServer();
var changeListener = function(clientName, rotation)
{
console.log("Display rotation change requested to: " + rotation + " by " + clientName);
return new tizen.mediacontroller.RequestReply(new tizen.Bundle({"message": "Success"}), 0);
};
/* Registers to receive display rotation change requests from clients. */
watcherId = mcServer.displayRotation.addChangeRequestListener(changeListener);
/* Cancels the watch operation. */
mcServer.displayRotation.removeChangeRequestListener(watcherId);
2.22. MediaControllerClientInfo
This interface provides communication methods from the server to the client.
with error type TypeMismatchError, if any argument has invalid type.
with error type UnknownError, if any other error occurs.
Code example:
/\* CLIENT APPLICATION */
var mcClient = tizen.mediacontroller.getClient();
mcClient.setCustomEventListener(function(serverName, eventName, data)
{
console.log("Media controller client received an event from the server:");
console.log(" name: " + eventName);
console.log(" data: " + JSON.stringify(data));
mcClient.unsetCustomEventListener();
return new tizen.mediacontroller.RequestReply({response: "response data"}, 123);
});
/\* SERVER APPLICATION */
var mcServer = tizen.mediacontroller.createServer();
mcServer.updatePlaybackState("PLAY");
var mcClientsInfoAll = mcServer.getAllClientsInfo();
if (mcClientsInfoAll.length < 1)
{
console.log("Server has no active clients.");
}
else
{
mcClientsInfoAll\[0\].sendEvent(
"test", new tizen.Bundle({param1: "value1", param2: "value2"}), function(response)
{
console.log("Media controller server received a reply to the event:");
console.log(" response: " + JSON.stringify(response));
});
}
Output example:
Media controller client received an event from the server:
name: test
data: '{param1: "value1", param2: "value2"}'
Media controller server received a reply to the event:
response: '{data: {response: "response data"}, code: 123}'
2.23. MediaControllerDisplayRotationInfo
Client-side object representing display rotation of a media controller server.
data: Response object. This object is compatible with Bundle.
Return value:
RequestReply [nullable]: RequestReply object which will be returned to the author of the request.
2.35. MediaControllerEnabledChangeRequestCallback
The MediaControllerEnabledChangeRequestCallback interface that defines the listener for change requests for spherical mode in MediaControllerMode360.addChangeRequestListener() and subtitles mode in MediaControllerSubtitles.addChangeRequestListener().
The MediaControllerDisplayModeChangeRequestCallback interface that defines the listener for change requests for display mode in MediaControllerDisplayMode.addChangeRequestListener().
Remark: You can return data object from callback which will be sent in reply to the client. See addChangeRequestListener() method to check how to handle and respond to commands.
Parameters:
clientName: An id of a client application which sent the request.
mode: The value requested by a client application.
Return value:
RequestReply [nullable]: RequestReply object which is sent with the reply to the client.
2.38. MediaControllerDisplayModeChangeCallback
The MediaControllerDisplayModeChangeCallback interface that defines the listener for display mode changes of the media controller server.
The MediaControllerDisplayRotationChangeRequestCallback interface that defines the listener for change requests for display rotation in MediaControllerDisplayRotation.addChangeRequestListener().
Remark: You can return data object from callback which will be sent in reply to the client. See displayRotation.addChangeRequestListener() method to check how to handle and respond to commands.
Parameters:
clientName: An id of a client application which sent the request.
displayRotation: The value requested by a client application.
Return value:
RequestReply [nullable]: RequestReply object which is sent with the reply to the client.
The MediaControllerPlaybackInfoChangeCallback interface that defines the listeners object for receiving media controller playback info changes from server.
The MediaControllerChangeRequestPlaybackInfoCallback interface that defines the listeners object for receiving playback info change requests from client.
We use cookies to improve your experience on our website and to show you relevant
advertising. Manage you settings for our cookies below.
Essential Cookies
These cookies are essential as they enable you to move around the website. This
category cannot be disabled.
Company
Domain
Samsung Electronics
.samsungdeveloperconference.com
Analytical/Performance Cookies
These cookies collect information about how you use our website. for example which
pages you visit most often. All information these cookies collect is used to improve
how the website works.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Functionality Cookies
These cookies allow our website to remember choices you make (such as your user name, language or the region your are in) and
tailor the website to provide enhanced features and content for you.
Company
Domain
LinkedIn
.ads.linkedin.com, .linkedin.com
Advertising Cookies
These cookies gather information about your browser habits. They remember that
you've visited our website and share this information with other organizations such
as advertisers.
Company
Domain
LinkedIn
.linkedin.com
Meta (formerly Facebook)
.samsungdeveloperconference.com
Google Inc.
.samsungdeveloperconference.com
Preferences Submitted
You have successfully updated your cookie preferences.