[TCSACR-82][Multimedia] Add guide for MediaController 72/152272/3
authorcoderhyme <jhyo.kim@samsung.com>
Mon, 25 Sep 2017 11:33:26 +0000 (20:33 +0900)
committerEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Tue, 26 Sep 2017 08:11:14 +0000 (11:11 +0300)
PS2: Reviewed
PS3: Fixed typo

Change-Id: Ibf000962e75202c0ba67bcbbf0b5ed82b872af80
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
org.tizen.guides/html/dotnet/media/media_controller.htm [new file with mode: 0644]

diff --git a/org.tizen.guides/html/dotnet/media/media_controller.htm b/org.tizen.guides/html/dotnet/media/media_controller.htm
new file mode 100644 (file)
index 0000000..cea8cf2
--- /dev/null
@@ -0,0 +1,231 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+       <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+       <meta http-equiv="X-UA-Compatible" content="IE=9" />
+       <link rel="stylesheet" type="text/css" href="../../css/styles.css" />
+       <link rel="stylesheet" type="text/css" href="../../css/snippet.css" />
+       <script type="text/javascript" src="../../scripts/snippet.js"></script>
+       <script type="text/javascript" src="../../scripts/jquery.util.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../../scripts/common.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../../scripts/core.js" charset="utf-8"></script>
+       <script type="text/javascript" src="../../scripts/search.js" charset="utf-8"></script>
+
+       <title>Media Controller</title>
+
+</head>
+
+<body onload="prettyPrint()" style="overflow: auto;">
+
+<div id="toc-navigation">
+
+       <div id="toc_border"><div id="toc">
+               <p class="toc-title">Dependencies</p>
+               <ul class="toc">
+                       <li>Tizen 4.0 and Higher</li>
+               </ul>
+
+               <p class="toc-title">Content</p>
+                       <ul class="toc">
+            <li><a href="#prerequisites">Prerequisites</a></li>
+            <li><a href="#get_media">Updating and Retrieving Information</a></li>
+            <li><a href="#send_media">Sending and Processing Commands</a></li>
+                       <li><a href="#servermetadata">Media Control Metadata Properties</a></li>
+                       </ul>
+
+               <p class="toc-title">Related Info</p>
+               <ul class="toc">
+                       <li><a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaController.html" target="_blank">Tizen.Multimedia.Remoting.MediaController Class</a></li>
+                       <li><a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControllerManager.html" target="_blank">Tizen.Multimedia.Remoting.MediaControllerManager Class</a></li>
+                       <li><a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControlServer.html" target="_blank">Tizen.Multimedia.Remoting.MediaControlServer Class</a></li>
+               </ul>
+       </div></div>
+</div>
+
+<div id="container"><div id="contents"><div class="content">
+
+<h1>Media Controller</h1>
+<p>You can establish communication between a media control server and a media control client. You can send commands from the client to the server, and the client can request updated metadata and playback information from the server.</p>
+
+<p>The main media controller features include:</p>
+<ul>
+    <li>Updating and retrieving information
+        <p>You can <a href="#get_media">update the metadata and playback information</a> on the server side, and then retrieve that information on the client side.</p>
+               <p>The media control server provides current information about the registered application that you can send to the client.</p>
+               <p>When the client requests the information, the media control server updates the state information of an active application before transferring the data. If the application is not running when the client request arrives, the media control server transfers the latest information.</p>
+       </li>
+    <li>Sending and processing commands
+        <p>You can <a href="#send_media">send a command</a> to the server from the client side, and then process the command on the server side.</p>
+               <p>The client can request server state or <a href="#servermetadata">metadata</a> information from the server, and receive it through an event handler.</p>
+       </li>
+</ul>
+
+<h2 id="prerequisites">Prerequisites</h2>
+
+<p>To use the media controller functionality in your application:</p>
+<ol>
+       <li>To use the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControlServer.html" target="_blank">Tizen.Multimedia.Remoting.MediaControlServer</a> class, the application has to request permission by adding the following privilege to the <code>tizen-manifest.xml</code> file:
+<pre class="prettyprint">
+&lt;privileges&gt;
+   &lt;privilege&gt;http://tizen.org/privilege/mediacontroller.server&lt;/privilege&gt;
+&lt;/privileges&gt;
+</pre>
+       </li>
+       <li>To use the methods and properties of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaController.html" target="_blank">Tizen.Multimedia.Remoting.MediaController</a>, <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControllerManager.html" target="_blank">Tizen.Multimedia.Remoting.MediaControllerManager</a>, and <code>Tizen.Multimedia.Remoting.MediaControlServer</code> classes, include the <a href="https://developer.tizen.org/dev-guide/csapi/namespaceTizen_1_1Multimedia_1_1Remoting.html" target="_blank">Tizen.Multimedia.Remoting</a> namespace in your application:
+<pre class="prettyprint">
+using Tizen.Multimedia.Remoting;
+</pre>
+       </li>
+</ol>
+
+<h2 id="get_media">Updating and Retrieving Information</h2>
+
+<p>To update the metadata and playback information on the server side, and to retrieve it on the client side:</p>
+
+<ul>
+       <li>To update the metadata and playback information on the server side:
+               <ol>
+                       <li>Start the media control server using the <code>Start()</code> method of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControlServer.html" target="_blank">Tizen.Multimedia.Remoting.MediaControlServer</a> class:
+<pre class="prettyprint">
+MediaControlServer.Start();
+</pre>
+                       </li>
+                       <li>Update the metadata or playback information using the <code>SetMetadata()</code> or <code>SetPlaybackState()</code> methods:
+<pre class="prettyprint">
+MediaControlServer.SetPlaybackState(MediaControlPlaybackState.Playing, currentPosition);
+</pre>
+                       </li>
+                       <li>When no longer needed, stop the media control server using the <code>Stop()</code> method:
+<pre class="prettyprint">
+MediaControlServer.Stop();
+</pre>
+                       </li>
+               </ol>
+       </li>
+       <li>To retrieve the metadata and playback information on the client side:
+               <ol>
+                       <li>Create a new instance of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControllerManager.html" target="_blank">Tizen.Multimedia.Remoting.MediaControllerManager</a> class:
+<pre class="prettyprint">
+var mediaControllerManager = new MediaControllerManager();
+</pre>
+                       </li>
+                       <li>Retrieve the currently-active controllers and select one:
+<pre class="prettyprint">
+var controller = MediaControllerManager.GetActiveControllers().First();
+</pre>
+                       </li>
+                       <li>Retrieve the metadata or playback information from the server using the <code>GetMetadata()</code>, <code>GetPlaybackState()</code>, or <code>GetPlaybackPosition()</code> methods.
+                       <p>For example, to retrieve the playback state from the server:</p>
+<pre class="prettyprint">
+Tizen.Log.info(LogTag, $"Playback state is {controller.GetPlaybackState()}");
+</pre>
+                       </li>
+               </ol>
+       </li>
+</ul>
+
+<h2 id="send_media">Sending and Processing Commands</h2>
+
+<p>To send a command from the client and to process it on the server side:</p>
+
+<ol>
+       <li>To send a command on the client side, use the <code>SendPlaybackCommand()</code> method of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaController.html" target="_blank">Tizen.Multimedia.Remoting.MediaController</a> class:
+<pre class="prettyprint">
+controller.SendPlaybackCommand(MediaControlPlaybackCommand.Pause);
+</pre>
+       </li>
+       <li>To process the received command on the server side, add an event handler to the <code>PlaybackCommandReceived</code> event of the <a href="https://developer.tizen.org/dev-guide/csapi/classTizen_1_1Multimedia_1_1Remoting_1_1MediaControlServer.html" target="_blank">Tizen.Multimedia.Remoting.MediaControlServer</a> class:
+<pre class="prettyprint">
+MediaControlServer.PlaybackCommandReceived += OnPlaybackCommandReceived;
+
+void OnPlaybackCommandReceived(object sender, PlaybackCommandReceivedEventArgs e)
+{
+    Tizen.Log.Info(LogTag, $"Received command is {e.Command} from {e.ClientAppId}");
+}
+</pre>
+       </li>
+</ol>
+
+
+<h2 id="servermetadata">Media Control Metadata Properties</h2>
+
+<p>The following table lists all the media control metadata properties the client can request from the server.</p>
+
+    <p align="center" class="Table"><strong>Table: Media control metadata properties</strong></p>
+<table>
+   <tbody>
+    <tr>
+     <th>Property</th>
+     <th>Description</th>
+    </tr>
+     <tr>
+     <td><code>Title</code></td>
+     <td>Title of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Artist</code></td>
+     <td>Artist of the latest content in the media control server</td>
+    </tr>
+     <tr>
+     <td><code>Album</code></td>
+     <td>Album name of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Author</code></td>
+     <td>Author of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Genre</code></td>
+     <td>Genre of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Duration</code></td>
+     <td>Duration of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Date</code></td>
+     <td>Date of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Copyright</code></td>
+     <td>Copyright of the latest content in the media control server</td>
+    </tr>
+    <tr>
+     <td><code>Description</code></td>
+     <td>Description of the latest content in the media control server</td>
+    </tr>
+     <tr>
+     <td><code>TrackNumber</code></td>
+     <td>Track number of the latest content in the media control server</td>
+    </tr>
+     <tr>
+     <td><code>AlbumArtPath</code></td>
+     <td>Album art of the latest content in the media control server</td>
+    </tr>
+   </tbody>
+  </table>
+
+<script type="text/javascript" src="../../scripts/jquery.zclip.min.js"></script>
+<script type="text/javascript" src="../../scripts/showhide.js"></script>
+</div></div></div>
+
+
+<a class="top sms" href="#"><img src="../../images/btn_top.gif" alt="Go to top"/></a>
+
+<div id="footer">
+<p class="footer">Except as noted, this content - excluding the Code Examples - is licensed under <a href="http://creativecommons.org/licenses/by/3.0/legalcode" target="_blank">Creative Commons Attribution 3.0</a> and all of the Code Examples contained herein are licensed under <a href="https://www.tizen.org/bsd-3-clause-license" target="_blank">BSD-3-Clause</a>.<br/>For details, see the <a href="https://www.tizen.org/content-license" target="_blank">Content License</a>.</p>
+</div>
+
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-25976949-1']);
+_gaq.push(['_trackPageview']);
+(function() {
+var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+})();
+</script>
+
+</body>
+</html>