<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Fred LE COQUIL's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/flecoqui/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/flecoqui/feed.xml</link>
    <description>Sharing information about Windows Phone, Windows Store applications...</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:21:52 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Building Audio/Video Applications based on Player Framework v2.0 for Windows Phone 8, Windows 8.1 and Windows Phone 8.1</title>
      <link>https://docs.microsoft.com/archive/blogs/flecoqui/building-audiovideo-applications-based-on-player-framework-v2-0-for-windows-phone-8-windows-8-1-and-windows-phone-8-1</link>
      <pubDate>Wed, 28 May 2014 10:21:44 GMT</pubDate>
      <dc:creator><![CDATA[FRED LE COQUIL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/flecoqui/2014/05/28/building-audiovideo-applications-based-on-player-framework-v2-0-for-windows-phone-8-windows-8-1-and-windows-phone-8-1/</guid>
      <description><![CDATA[INTRODUCTION  This article describes the different steps&#160; to create Windows Phone 8, Windows...]]></description>
      <content:encoded><![CDATA[<p><b>INTRODUCTION</b></p>  <p>This article describes the different steps&#160; to create Windows Phone 8, Windows 8.1 and Windows Phone 8.1 applications playing video supporting the following formats:&#160;&#160; <br />- Step 1: WMV, MP4, MPEG2-TS (only for Windows 8.1)&#160;&#160;&#160;&#160; <br />- Step 2: WMV, MP4, MPEG2-TS (only for Windows 8.1) and Smooth Streaming&#160;&#160;&#160;&#160;&#160; <br />- Step 3: WMV, MP4, MPEG2-TS (only for Windows 8.1), Smooth Streaming and MPEG DASH&#160;&#160;&#160;&#160; <br />- Step 4: WMV, MP4, MPEG2-TS (only for Windows 8.1), Smooth Streaming and MPEG DASH protected with PlayReady&#160;&#160;&#160;&#160; <br />The sample applications delivered with this article allow the user to define:&#160;&#160;&#160;&#160; <br />- the video Uri,&#160;&#160;&#160;&#160; <br />- the PlayReady license acquisition Uri,&#160;&#160;&#160;&#160; <br />- the « Challenge Custom Data » for the PlayReady license acquisition.     <br />If the PlayReady license acquisition Uri is not defined, the application will use the Uri defined in protection header of the manifest.     <br />By default the applications use a list of videos supporting the different formats.     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7827.image_thumb4_631C59ED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7827.image_5F00_thumb4_5F00_631C59ED.png"><img title="image_thumb4" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb4" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2234.image_thumb4_thumb_1E038CB7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2234.image_5F00_thumb4_5F00_thumb_5F00_1E038CB7.png" width="162" height="294" /></a>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0028.image_thumb5_34C564F1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0028.image_5F00_thumb5_5F00_34C564F1.png"><img title="image_thumb5" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb5" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4276.image_thumb5_thumb_7255536B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4276.image_5F00_thumb5_5F00_thumb_5F00_7255536B.png" width="164" height="297" /></a>     <br /><b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows Phone 8</b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <b>Windows Phone 8.1</b></p>  <p><b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4213.image_thumb3_0602=.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4213.image_5F00_thumb3_5F00_06023D00.png"><img title="image_thumb3" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb3" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3022.image_thumb3_thumb_5F36B770.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3022.image_5F00_thumb3_5F00_thumb_5F00_5F36B770.png" width="445" height="247" /></a></b>     <br /><b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows 8.1      <br />      <br /></b><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0654.image_thumb35_19B447F6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0654.image_5F00_thumb35_5F00_19B447F6.png"><img title="image_thumb35" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb35" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8524.image_thumb35_thumb_1B186AC8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8524.image_5F00_thumb35_5F00_thumb_5F00_1B186AC8.png" width="602" height="301" /></a></p>  <p><b>STEP 1: AUDIO/VIDEO PLAYER (WMV, MP4, MPEG2-TS)</b></p>  <p>The Windows Phone 8, Windows 8.1 and Windows Phone 8.1 Applications for Step 1 support the following formats:    <br />- Windows: WMV, MP4, MPEG2-TS     <br />- Windows Phone : WMV, MP4</p>  <p>Those formats are natively supported, no supplementary SDKs are required.    <br />    <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6813.image_thumb9_7857330A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6813.image_5F00_thumb9_5F00_7857330A.png"><img title="image_thumb9" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb9" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1651.image_thumb9_thumb_63D4743D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1651.image_5F00_thumb9_5F00_thumb_5F00_63D4743D.png" width="608" height="303" /></a></p>  <p><b>Windows 8.1, Windows Phone 8.1 and Windows Phone 8.0 Applications:</b></p>  <p>On the XAML MainPage insert the MediaElement and call it « Player »&#160;&#160;&#160; </p>  <div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 81.62%; height: 55px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">   <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MediaElement</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span><br /><span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>

  <br /></div>

<p>In the method associated with Click event on button “Play”, initialize Player Source with the Uri of the video you want to play&#160;&#160; <br /></p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 81.16%; height: 35px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 120.21%; height: 16px; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);</pre>

  <br /></div>

<p>Sample Uris compliant with WMV, MP4 and MPEG2-TS format are available on Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 80.79%; height: 99px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 99.54%; height: 64px; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://livestreamingvm.cloudapp.net/vod/wmv/test1.wmv<br />http://livestreamingvm.cloudapp.net/vod/mp4/test1.mp4<br />http://livestreamingvm.cloudapp.net/vod/ts/test1.ts</pre>

  <br /></div>

<p><b>
    <br /></b><b><b>STEP 2: AUDIO/VIDEO PLAYER </b> (WMV, MP4, MPEG2-TS, SMOOTH STREAMING)</b></p>
The Windows Phone 8, Windows 8.1 and Windows Phone 8.1 Applications for Step 2 support the following formats: 

<br />- Windows: WMV, MP4, MPEG2-TS and Smooth Streaming&#160; <br />- Windows Phone : WMV, MP4 and Smooth Streaming 

<p>
  <br />Supplementary SDKs are required to build the applications :</p>

<ul>
  <li>Windows 8.0 (not required for this application) 
    <br />Smooth Streaming Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a></li>

  <li>Windows 8.1 
    <br />Smooth Streaming Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Windows Phone 8.0 
    <br />Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 

    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Windows Phone 8.1 
    <br />Smooth Streaming Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a> 

    <br /></li>
</ul>

<p>&#160;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8831.image_thumb37_5E858D8C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8831.image_5F00_thumb37_5F00_5E858D8C.png"><img title="image_thumb37" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb37" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8867.image_thumb37_thumb_74DB32D1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8867.image_5F00_thumb37_5F00_thumb_5F00_74DB32D1.png" width="679" height="339" /></a> 

  <br /></p>

<p><b>Windows 8.1 and Windows Phone 8.1 Applications:</b></p>

<p>Add a reference to « Microsoft Smooth Streaming Client SDK for Windows 8.1 » for Windows 8.1 application. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2626.image_thumb13_391E2ACF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2626.image_5F00_thumb13_5F00_391E2ACF.png"><img title="image_thumb13" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb13" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3542.image_thumb13_thumb_74055D98.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3542.image_5F00_thumb13_5F00_thumb_5F00_74055D98.png" width="244" height="76" /></a></p>

<p>Add a reference to « Microsoft Smooth Streaming Client SDK for Windows Phone 8.1 » for Windows Phone 8.1 application. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6253.image_thumb14_64F43798.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6253.image_5F00_thumb14_5F00_64F43798.png"><img title="image_thumb14" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb14" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5516.image_thumb14_thumb_62BA3F8D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5516.image_5F00_thumb14_5F00_thumb_5F00_62BA3F8D.png" width="244" height="68" /></a></p>

<p>On the XAML MainPage insert the MediaElement and call it&#160; « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 70.16%; height: 102px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MediaElement</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span><br /><span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span> <br /><span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>

  <br /></div>

<p>Create a method RegisterPlugins which associates the Smooth Streaming library with the Smooth Streaming Uri opened by the MediaElement. This method is called in the method OnNavigatedTo. 
  <br /></p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> Windows.Media.MediaExtensionManager MediaManager;<br /><span style="color: rgb(0, 0, 255);">public</span> IAdaptiveSourceManager AdaptiveSrcManager { get; <span style="color: rgb(0, 0, 255);">private</span> set; }<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />     LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br />     <span style="color: rgb(0, 0, 255);">if</span> (MediaManager == <span style="color: rgb(0, 0, 255);">null</span>)<br />                MediaManager = <span style="color: rgb(0, 0, 255);">new</span> Windows.Media.MediaExtensionManager();<br />     <span style="color: rgb(0, 0, 255);">if</span> (AdaptiveSrcManager == <span style="color: rgb(0, 0, 255);">null</span>)<br />                AdaptiveSrcManager = AdaptiveSourceManager.GetDefault();<br />     PropertySet ssps = <span style="color: rgb(0, 0, 255);">new</span> PropertySet();<br />     ssps[<span style="color: rgb(0, 96, 128);">&quot;{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}&quot;</span>] = AdaptiveSrcManager;<br /><br /><br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.ism&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;text/xml&quot;</span>, ssps);<br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.ism&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;application/vnd.ms-sstr+xml&quot;</span>, ssps);<br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.isml&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;text/xml&quot;</span>, ssps);<br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.isml&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;application/vnd.ms-sstr+xml&quot;</span>, ssps);<br />     MediaManager.RegisterSchemeHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;ms-sstr:&quot;</span>, ssps);<br />} <br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    Application.Current.Suspending += App_Suspending;<br />    Application.Current.Resuming += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br /><span style="color: rgb(204, 102, 51);">#if</span> WINDOOWS_PHONE_APP<br />    DisplayInformation.GetForCurrentView().OrientationChanged += OnOrientationChanged;<br /><span style="color: rgb(204, 102, 51);">#endif</span><br />    RegisterPlugins();<br />}<br /></pre>

  <br /></div>

<p>In the method associated with Click event on button “Play”, initialize Player Source with the Uri of the video you want to play</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);</pre>

  <br /></div>

<p>Sample Uris compliant with Smooth Streaming format are available on Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://livestreamingvm.cloudapp.net/vod/test1/test1.ism/manifest</pre>

  <br /></div>

<p><b>Applications Windows Phone 8.0:</b></p>

<p>Add a reference to « Microsoft.Web.Media.SmoothStreaming » for Windows Phone 8.0 application. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0160.image_thumb15_1DA17257.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0160.image_5F00_thumb15_5F00_1DA17257.png"><img title="image_thumb15" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb15" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0172.image_thumb15_thumb_665AEB1B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0172.image_5F00_thumb15_5F00_thumb_5F00_665AEB1B.png" width="244" height="72" /></a></p>

<p>On the XAML MainPage : 
  <br />- insert the MediaElement used to play WMV, MP4 content and call it « Player » 

  <br />- insert the SmoothStreamingMediaElement used to play Smooth Streaming content and call it « PlayerSSME »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.25%; height: 130px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 98.41%; height: 128px; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MediaElement</span> <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Visible&quot;</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <br /><span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ssme:SmoothStreamingMediaElement</span> <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Collapsed&quot;</span> <br /><span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;PlayerSSME&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <br /><span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>

  <br /></div>

<p>In the method associated with Click event on button “Play”, initialize PlayerSSME SmoothStreamingSource with the Uri of the smooth streaming video you want to play, if you want to play MP4 or WMV video, initialize Player Source with the Uri of the WMV or MP4 video.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 61.23%; height: 78px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">if</span> (MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;/manifest&quot;</span>, StringComparison.CurrentCultureIgnoreCase))<br />    PlayerSSME.SmoothStreamingSource = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><span style="color: rgb(0, 0, 255);">else</span> <br />    Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /></pre>

  <br /></div>

<p>Sample Uris compliant with Smooth Streaming format are available on Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 61.61%; height: 74px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://livestreamingvm.cloudapp.net/vod/test1/test1.ism/manifest</pre>

  <br /></div>

<p><b><b>STEP 3: AUDIO/VIDEO PLAYER </b> (WMV, MP4, MPEG2-TS, SMOOTH STREAMING, MPEG DASH)</b></p>
The Windows Phone 8, Windows 8.1 and Windows Phone 8.1 Applications for Step 3 support the following formats: 

<br />- Windows: WMV, MP4, MPEG2-TS, Smooth Streaming&#160; and MPEG DASH&#160; <br />- Windows Phone : WMV, MP4, Smooth Streaming&#160; and MPEG DASH 

<p>
  <br />Supplementary SDKs are required to build the applications :</p>

<ul>
  <li>Windows 8.0 (not required for this application) 
    <br />Smooth Streaming Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a></li>

  <li>Windows 8.1 
    <br />Smooth Streaming Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Windows Phone 8.0 
    <br />Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 

    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Windows Phone 8.1 
    <br />Smooth Streaming Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a></li>

  <li>Windows Phone 8.0, Windows Phone 8.1 et Windows 8.1 
    <br />Player Framework for Windows and Windows Phone V2.0: 

    <br /><a href="http://playerframework.codeplex.com/releases/view/121773">http://playerframework.codeplex.com/releases/view/121773</a> 

    <br /></li>
</ul>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8551.image_thumb17_7D1CC355.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8551.image_5F00_thumb17_5F00_7D1CC355.png"><img title="image_thumb17" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb17" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1134.image_thumb17_thumb_415FBB53.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1134.image_5F00_thumb17_5F00_thumb_5F00_415FBB53.png" width="645" height="322" /></a></p>

<p><b>Windows 8.1 and Windows Phone 8.1 Applications:</b></p>

<p>Add a reference to: 
  <br />« Microsoft Smooth Streaming Client SDK for Windows 8.1 », 

  <br />« Microsoft Player Framework »,&#160; <br />« Microsoft Player Framework Adaptive Streaming Plugin»,&#160; <br />« Microsoft Player Framework Dash Plugin» for Windows 8.1 application. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6765.image_thumb18_29C80DE0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6765.image_5F00_thumb18_5F00_29C80DE0.png"><img title="image_thumb18" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb18" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5810.image_thumb18_thumb_129C9362.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5810.image_5F00_thumb18_5F00_thumb_5F00_129C9362.png" width="244" height="110" /></a></p>

<p>Add a reference to: 
  <br />« Microsoft Smooth Streaming Client SDK for Windows Phone 8.1 », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin» for Windows Phone 8.1 application. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4263.image_thumb19_4D83C62B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4263.image_5F00_thumb19_5F00_4D83C62B.png"><img title="image_thumb19" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb19" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0804.image_thumb19_thumb_36584BAD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0804.image_5F00_thumb19_5F00_thumb_5F00_36584BAD.png" width="244" height="104" /></a></p>

<p>On the XAML MainPage insert the « PlayerFramework:MediaPlayer » and call it « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; height: 127px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span>         <br />            <span style="color: rgb(255, 0, 0);">IsTimelineVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeElapsedVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsDurationVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeRemainingVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false« <br />            IsInfoVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&quot;  IsMoreVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span>«  <span style="color: rgb(255, 0, 0);">IsFastForwardVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsRewindVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span><br />            <span style="color: rgb(255, 0, 0);">IsSkipBackVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsSkipAheadVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <span style="color: rgb(255, 0, 0);">IsSkipPreviousVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>   <span style="color: rgb(255, 0, 0);">IsReplayVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;True&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span>  <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>

  <br /></div>

<p>Create a method RegisterPlugins which associates the Adaptive plugin with the Smooth Streaming Uri opened by the Player. This method is called in the method OnNavigatedTo.&#160; Create a method RegisterDashPlugins which associates the DashDownloaderPlugin plugin with the Adaptive plugin used by the Player. This method is called before playing any MPEG DASH content.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; height: 794px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br /><span style="color: rgb(0, 0, 255);">void</span> RegisterDashPlugin(<span style="color: rgb(0, 0, 255);">bool</span> bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().First();<br />    <span style="color: rgb(0, 0, 255);">if</span> (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register DASH plugin&quot;</span>);<br />            <span style="color: rgb(0, 0, 255);">if</span> (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Unregister DASH plugin&quot;</span>);<br />            plugin.DownloaderPlugin = <span style="color: rgb(0, 0, 255);">null</span>;<br />        }<br />    }<br />}<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br /><br />    <span style="color: rgb(0, 0, 255);">if</span> (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br /><br />    Player.Plugins.Add(adaptivePlugin);<br />}<br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    Application.Current.Suspending += App_Suspending;<br />    Application.Current.Resuming += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br /><span style="color: rgb(204, 102, 51);">#if</span> WINDOWS_PHONE_APP<br />    DisplayInformation.GetForCurrentView().OrientationChanged += OnOrientationChanged;<br /><span style="color: rgb(204, 102, 51);">#endif</span><br />    RegisterPlugins();<br />}<br /><br /></pre>

  <br /></div>

<p>In the method associated with Click event on button “Play”, call the method RegisterDashPlugin to register the DashDownloaderPlugin (if it’s a MPEG DASH uri), and then initialize Player Source with the Uri of the video you want to play. </p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /></pre>

  <br /></div>

<p>Sample Uris compliant with MPEG DASH format are available on Microsoft Azure.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">http://wams.edgesuite.net/media/SintelTrailer_Smooth_SeekDemo/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p><b>Applications Windows Phone 8.0:</b></p>

<p>Add a reference to: 
  <br />« Microsoft.Web.Media.SmoothStreaming », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin» for the Windows Phone 8.0 application&lt; 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8838.image_thumb20_341E53A2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8838.image_5F00_thumb20_5F00_341E53A2.png"><img title="image_thumb20" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb20" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5226.image_thumb20_thumb_03F708DF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5226.image_5F00_thumb20_5F00_thumb_5F00_03F708DF.png" width="244" height="94" /></a></p>

<p>On the XAML MainPage insert the « PlayerFramework:MediaPlayer » and call it « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span>  <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Visible&quot;</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span>  <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <br /><span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>     <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>

  <br /></div>

<p>Create a method RegisterPlugins which associates the Adaptive plugin with the Smooth Streaming Uri opened by the Player. This method is called in the method OnNavigatedTo.&#160; Create a method RegisterDashPlugins which associates the DashDownloaderPlugin plugin with the Adaptive plugin used by the Player. This method is called before playing any MPEG DASH content.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br />void RegisterDashPlugin(bool bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().<span style="color: rgb(0, 0, 255);">First</span>();<br />    if (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        if (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(&quot;Register DASH plugin&quot;);<br />            if (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = new Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />    }<br />}<br />void RegisterPlugins()<br />{<br />    LogMessage(&quot;Register plugins&quot;);<br />    if (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = new Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br />    Player.Plugins.<span style="color: rgb(0, 0, 255);">Add</span>(adaptivePlugin);<br />}<br /><br />protected override void OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(&quot;OnNavigatedTo&quot;);<br />    base.OnNavigatedTo(e);<br />    PhoneApplicationService.<span style="color: rgb(0, 0, 255);">Current</span>.Deactivated += App_Suspending;<br />    PhoneApplicationService.<span style="color: rgb(0, 0, 255);">Current</span>.Activated += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br />    RegisterPlugins();<br />}<br /><br /></pre>

  <br /></div>

<p>In the method associated with Click event on button “Play”, first initialize the Player Source with null and close the player. Then call the method RegisterDashPlugin to register the DashDownloaderPlugin (if it’s a MPEG DASH Uri), and then initialize Player Source with the Uri of the video you want to play.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />Player.Source = <span style="color: rgb(0, 0, 255);">null</span>;<br />Player.Close();<br /><br />RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><br /></pre>

  <br /></div>

<p>Sample Uris compliant with MPEG DASH format are available on Microsoft Azure.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">http://wams.edgesuite.net/media/SintelTrailer_Smooth_SeekDemo/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p><b><b>STEP 4: AUDIO/VIDEO PLAYER </b> (WMV, MP4, MPEG2-TS, SMOOTH STREAMING, MPEG DASH, PLAYREADY)</b></p>
The Windows Phone 8, Windows 8.1 and Windows Phone 8.1 Applications for Step 4 support the following formats: 

<br />- Windows: WMV, MP4, MPEG2-TS, Smooth Streaming and MPEG DASH protected or not with PlayReady&#160; DRM 

<br />- Windows Phone : WMV, MP4, Smooth Streaming and MPEG DASH protected or not with PlayReady DRM 

<br />

<p>Supplementary SDKs are required to build the applications :</p>

<ul>
  <li>Windows 8.0 (not required for this application) 
    <br />Smooth Streaming Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a></li>

  <li>Windows 8.1 
    <br />Smooth Streaming Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Windows Phone 8.0 
    <br />Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 

    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Windows Phone 8.1 
    <br />Smooth Streaming Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a></li>

  <li>Windows Phone 8.0, Windows Phone 8.1 et Windows 8.1 
    <br />Player Framework for Windows and Windows Phone V2.0: 

    <br /><a href="http://playerframework.codeplex.com/releases/view/121773">http://playerframework.codeplex.com/releases/view/121773</a>&#160;&#160;&#160;&#160; </li>

  <li>Windows 8.0 (not required for this application) 
    <br />PlayReady Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483</a></li>

  <li>Windows 8.1 
    <br />PlayReady Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b">http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b</a></li>

  <li>Windows Phone 8.1 
    <br />PlayReady Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f</a> 

    <br /></li>
</ul>

<p>
  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2055.image_thumb22_3EDE3BA8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2055.image_5F00_thumb22_5F00_3EDE3BA8.png"><img title="image_thumb22" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb22" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4466.image_thumb22_thumb_42EB1A2B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4466.image_5F00_thumb22_5F00_thumb_5F00_42EB1A2B.png" width="746" height="372" /></a></p>

<p><b><strong>Steps to acquire a PlayReady license for </strong>Universal Apps (Windows 8.1 et Windows Phone 8.1) :</b></p>

<p>Before describing how the PlayReady client acquires the PlayReady license, some words about the Individualization. Every PlayReady client has a unique digital certificate and key, the installation of the certificate and the key is called Individualization. 
  <br />Moreover, before the PlayReady client requests the license to decrypt the content, it must first determine whether the user’s computer has the appropriate PlayReady software installed. This software is called the Individualized Black boX (IBX) and is the client component of PlayReady that is required before any protected content can be played. The individualization component software enables the client computer to request and use a PlayReady license. 

  <br />The PlayReady client for Windows Store applications supports dynamic individualization: the IBX is downloaded from the Individualization Server. In your application you can implement a Pro-Active Individualization Request or a Reactive Individualization Request.</p>

<ul>
  <li>A <strong>Pro-Active Individualization Request </strong>can be transmitted just after the installation of the application or when the user launches the application for the first time. </li>

  <li>A <strong>Reactive Individualization Request</strong> is automatically prepared by the PlayReady client when the application is about to play an asset protected with PlayReady and if the IBX is not installed on the computer.</li>
</ul>

<p>The schema below describes the acquisition of a PlayReady license to play an asset protected with PlayReady with a Reactive Individualization Request:&#160; </p>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6076.image_thumb24_74E54B66.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6076.image_5F00_thumb24_5F00_74E54B66.png"><img title="image_thumb24" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb24" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0167.image_thumb24_thumb_58D71D2C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0167.image_5F00_thumb24_5F00_thumb_5F00_58D71D2C.png" width="671" height="293" /></a>&#160;&#160; <br /></p>

<p>The schema below describes the acquisition of a PlayReady license to play an asset protected with PlayReady without any Individualization Request as the Individualized Black Box (IBX) is already installed:&#160; </p>

<p>
  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4718.image_thumb26_5CE3FBAF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4718.image_5F00_thumb26_5F00_5CE3FBAF.png"><img title="image_thumb26" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb26" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8468.image_thumb26_thumb_5E481E81.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8468.image_5F00_thumb26_5F00_thumb_5F00_5E481E81.png" width="679" height="240" /></a></p>

<p>The schema below describes the exchanges between the client and the server when the application plays an asset protected with PlayReady when the Individualized Black Box (IBX) is already installed and the PlayReady license has already been acquired and the license is persistent:&#160; </p>

<p>
  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1376.image_thumb28_50786937.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1376.image_5F00_thumb28_5F00_50786937.png"><img title="image_thumb28" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb28" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2313.image_thumb28_thumb_66CE0E7C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2313.image_5F00_thumb28_5F00_thumb_5F00_66CE0E7C.png" width="686" height="265" /></a></p>

<p><b>Windows 8.1 and Windows Phone 8.1 applications: 
    <br /></b>Add a reference to: 

  <br />« Microsoft Smooth Streaming Client SDK for Windows 8.1 »,&#160; <br />« Microsoft Player Framework »,&#160; <br />« Microsoft Player Framework Adaptive Streaming Plugin»,&#160; <br />« Microsoft Player Framework Dash Plugin»,&#160; <br />« Microsoft PlayReady Client SDK» for Windows 8.1 application. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5460.image_thumb29_7D23B3C1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5460.image_5F00_thumb29_5F00_7D23B3C1.png"><img title="image_thumb29" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb29" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2474.image_thumb29_thumb_019CC53A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2474.image_5F00_thumb29_5F00_thumb_5F00_019CC53A.png" width="244" height="123" /></a></p>

<p>Add a reference to: 
  <br />« Microsoft Smooth Streaming Client SDK for Windows Phone 8.1 »,&#160; <br />« Microsoft Player Framework »,&#160; <br />« Microsoft Player Framework Adaptive Streaming Plugin»,&#160; <br />« Microsoft Player Framework Dash Plugin»,&#160; <br />« Microsoft PlayReady Client SDK» for Windows Phone 8.1 application. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2804.image_thumb30_43370186.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2804.image_5F00_thumb30_5F00_43370186.png"><img title="image_thumb30" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb30" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7534.image_thumb30_thumb_7E1E344F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7534.image_5F00_thumb30_5F00_thumb_5F00_7E1E344F.png" width="244" height="113" /></a></p>

<p>On the XAML MainPage insert the « PlayerFramework:MediaPlayer » and call it « Player ».</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; height: 132px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span>         <br />            <span style="color: rgb(255, 0, 0);">IsTimelineVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeElapsedVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsDurationVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeRemainingVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false« <br />            IsInfoVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&quot;  IsMoreVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span>«  <span style="color: rgb(255, 0, 0);">IsFastForwardVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsRewindVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span><br />            <span style="color: rgb(255, 0, 0);">IsSkipBackVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsSkipAheadVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <span style="color: rgb(255, 0, 0);">IsSkipPreviousVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>   <span style="color: rgb(255, 0, 0);">IsReplayVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;True&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span>  <span style="color: rgb(0, 0, 255);">/&gt;</span><br /><br /></pre>

  <br /></div>

<p>Create a method RegisterPlugins which associates the Adaptive plugin with the Smooth Streaming Uri opened by the Player, which creates a MediaProtectionManager associated with the Player and which registers the PlayReady events&#160; « ServiceRequested » and « ComponentLoadFailed » 
  <br />This method is called in the method OnNavigatedTo.&#160; <br />Create a method RegisterDashPlugins which associates the DashDownloaderPlugin plugin with the Adaptive plugin used by the Player. This method is called before playing any MPEG DASH content.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br /><span style="color: rgb(0, 0, 255);">void</span> RegisterDashPlugin(<span style="color: rgb(0, 0, 255);">bool</span> bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().First();<br />    <span style="color: rgb(0, 0, 255);">if</span> (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register DASH plugin&quot;</span>);<br />            <span style="color: rgb(0, 0, 255);">if</span> (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Unregister DASH plugin&quot;</span>);<br />            plugin.DownloaderPlugin = <span style="color: rgb(0, 0, 255);">null</span>;<br />        }<br />    }<br />}<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br /><br />    <span style="color: rgb(0, 0, 255);">if</span> (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br /><br />    Player.Plugins.Add(adaptivePlugin);<br /><br />    <span style="color: rgb(0, 128, 0);">// PlayReady</span><br />    <span style="color: rgb(0, 128, 0);">// Init PlayReady Protection Manager</span><br />    var protectionManager = <span style="color: rgb(0, 0, 255);">new</span> MediaProtectionManager();<br />    Windows.Foundation.Collections.PropertySet cpSystems = <span style="color: rgb(0, 0, 255);">new</span> Windows.Foundation.Collections.PropertySet();<br />    cpSystems.Add(<span style="color: rgb(0, 96, 128);">&quot;{F4637010-03C3-42CD-B932-B48ADF3A6A54}&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput&quot;</span>); <span style="color: rgb(0, 128, 0);">//Playready</span><br />    protectionManager.Properties.Add(<span style="color: rgb(0, 96, 128);">&quot;Windows.Media.Protection.MediaProtectionSystemIdMapping&quot;</span>, cpSystems);<br />    protectionManager.Properties.Add(<span style="color: rgb(0, 96, 128);">&quot;Windows.Media.Protection.MediaProtectionSystemId&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;{F4637010-03C3-42CD-B932-B48ADF3A6A54}&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">this</span>.Player.ProtectionManager = protectionManager;<br />    <br />    <span style="color: rgb(0, 128, 0);">// PlayReady Events registration</span><br />    Player.ProtectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed;<br />    Player.ProtectionManager.ServiceRequested += ProtectionManager_ServiceRequested;<br />}<br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    Application.Current.Suspending += App_Suspending;<br />    Application.Current.Resuming += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br /><span style="color: rgb(204, 102, 51);">#if</span> WINDOWS_PHONE_APP<br />    DisplayInformation.GetForCurrentView().OrientationChanged += OnOrientationChanged;<br /><span style="color: rgb(204, 102, 51);">#endif</span><br />    RegisterPlugins();<br />}<br /><br /></pre>

  <br /></div>

<p>To support PlayReady the application must call the license server to acquire the PlayReady license associated with the content protected with PlayReady. You need to include in the project the file&#160; <b><i>CommonLicenseRequest.cs</i></b>. This file implements the common class based on HttpClient to acquire the PlayReady license.</p>

<p>The method ProtectionManager_ServiceRequested is called each time the application requests a PlayReady license or an individualization. If it’s a individualization request, the method ReactiveIndivRequest is called. If it’s a license request, the methode LicenseAcquisitionRequest is called.&#160;&#160;&#160;&#160; </p>

<p>If the URL used to acquire the PlayReady License is not forced and is the one defined in the PlayReady protection header, the method LicenseAcquisitionRequest calls licenseRequest.BeginServiceRequest. If the URL to acquire the PlayReady License is forced by the application, the method LicenseAcquisitionRequest creates a PlayReady challenge using the ChallengeCustomData and then call licenseAcquisition.AcquireLicense using the URL defined by the user.&#160; </p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">const</span> <span style="color: rgb(0, 0, 255);">int</span> MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED = -2147174251;<br /><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">string</span> PlayReadyLicenseUrl;<br /><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">string</span> PlayReadyChallengeCustomData;<br /><br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked when the Protection Manager can't load some components</span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br /><span style="color: rgb(0, 0, 255);">void</span> ProtectionManager_ComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager ComponentLoadFailed&quot;</span>);<br />    e.Completion.Complete(<span style="color: rgb(0, 0, 255);">false</span>);<br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked to acquire the PlayReady License</span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async <span style="color: rgb(0, 0, 255);">void</span> LicenseAcquisitionRequest(PlayReadyLicenseAcquisitionServiceRequest licenseRequest, MediaProtectionServiceCompletion CompletionNotifier, <span style="color: rgb(0, 0, 255);">string</span> Url, <span style="color: rgb(0, 0, 255);">string</span> ChallengeCustomData)<br />{<br />    <span style="color: rgb(0, 0, 255);">bool</span> bResult = <span style="color: rgb(0, 0, 255);">false</span>;<br />    <span style="color: rgb(0, 0, 255);">string</span> ExceptionMessage = <span style="color: rgb(0, 0, 255);">string</span>.Empty;<br /><br />    <span style="color: rgb(0, 0, 255);">try</span><br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(Url))<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Manual License Acquisition Service Request in progress - URL: &quot;</span> + Url);<br /><br />            <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(ChallengeCustomData))<br />            {<br />                System.Text.UTF8Encoding encoding = <span style="color: rgb(0, 0, 255);">new</span> System.Text.UTF8Encoding();<br />                <span style="color: rgb(0, 0, 255);">byte</span>[] b = encoding.GetBytes(ChallengeCustomData);<br />                licenseRequest.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);<br />            }<br /><br />            PlayReadySoapMessage soapMessage = licenseRequest.GenerateManualEnablingChallenge();<br /><br />            <span style="color: rgb(0, 0, 255);">byte</span>[] messageBytes = soapMessage.GetMessageBody();<br />            HttpContent httpContent = <span style="color: rgb(0, 0, 255);">new</span> ByteArrayContent(messageBytes);<br /><br />            IPropertySet propertySetHeaders = soapMessage.MessageHeaders;<br />            <span style="color: rgb(0, 0, 255);">foreach</span> (<span style="color: rgb(0, 0, 255);">string</span> strHeaderName <span style="color: rgb(0, 0, 255);">in</span> propertySetHeaders.Keys)<br />            {<br />                <span style="color: rgb(0, 0, 255);">string</span> strHeaderValue = propertySetHeaders[strHeaderName].ToString();<br /><br />                <span style="color: rgb(0, 128, 0);">// The Add method throws an ArgumentException try to set protected headers like &quot;Content-Type&quot;</span><br />                <span style="color: rgb(0, 128, 0);">// so set it via &quot;ContentType&quot; property</span><br />                <span style="color: rgb(0, 0, 255);">if</span> (strHeaderName.Equals(<span style="color: rgb(0, 96, 128);">&quot;Content-Type&quot;</span>, StringComparison.OrdinalIgnoreCase))<br />                    httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse(strHeaderValue);<br />                <span style="color: rgb(0, 0, 255);">else</span><br />                    httpContent.Headers.Add(strHeaderName.ToString(), strHeaderValue);<br />            }<br />            CommonLicenseRequest licenseAcquision = <span style="color: rgb(0, 0, 255);">new</span> CommonLicenseRequest();<br />            HttpContent responseHttpContent = await licenseAcquision.AcquireLicense(<span style="color: rgb(0, 0, 255);">new</span> Uri(Url), httpContent);<br />            <span style="color: rgb(0, 0, 255);">if</span> (responseHttpContent != <span style="color: rgb(0, 0, 255);">null</span>)<br />            {<br />                Exception exResult = licenseRequest.ProcessManualEnablingResponse(await responseHttpContent.ReadAsByteArrayAsync());<br />                <span style="color: rgb(0, 0, 255);">if</span> (exResult != <span style="color: rgb(0, 0, 255);">null</span>)<br />                {<br />                    <span style="color: rgb(0, 0, 255);">throw</span> exResult;<br />                }<br />                bResult = <span style="color: rgb(0, 0, 255);">true</span>;<br />            }<br />            <span style="color: rgb(0, 0, 255);">else</span><br />                ExceptionMessage = licenseAcquision.GetLastErrorMessage();<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady License Acquisition Service Request in progress - URL: &quot;</span> + licenseRequest.Uri.ToString());<br />            await licenseRequest.BeginServiceRequest();<br />            bResult = <span style="color: rgb(0, 0, 255);">true</span>;<br />        }<br />    }<br />    <span style="color: rgb(0, 0, 255);">catch</span> (Exception e)<br />    {<br />        ExceptionMessage = e.Message;<br />    }<br /><br />    <span style="color: rgb(0, 0, 255);">if</span> (bResult == <span style="color: rgb(0, 0, 255);">true</span>)<br />        LogMessage(!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(Url) ? <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager Manual PlayReady License Acquisition Service Request successful&quot;</span> :<br />            <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady License Acquisition Service Request successful&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">else</span><br />        LogMessage(!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(Url) ? <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager Manual PlayReady License Acquisition Service Request failed: &quot;</span> + ExceptionMessage :<br />            <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady License Acquisition Service Request failed: &quot;</span> + ExceptionMessage);<br />    CompletionNotifier.Complete(bResult);<br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Proactive Individualization Request </span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async <span style="color: rgb(0, 0, 255);">void</span> ProActiveIndivRequest()<br />{<br />    PlayReadyIndividualizationServiceRequest indivRequest = <span style="color: rgb(0, 0, 255);">new</span> PlayReadyIndividualizationServiceRequest();<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady ProActive Individualization Service Request in progress...&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">bool</span> bResultIndiv = await ReactiveIndivRequest(indivRequest, <span style="color: rgb(0, 0, 255);">null</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (bResultIndiv == <span style="color: rgb(0, 0, 255);">true</span>)<br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady ProActive Individualization Service Request successful&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">else</span><br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady ProActive Individualization Service Request failed&quot;</span>);<br /><br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked to send the Individualization Request </span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async Task&lt;<span style="color: rgb(0, 0, 255);">bool</span>&gt; ReactiveIndivRequest(PlayReadyIndividualizationServiceRequest IndivRequest, MediaProtectionServiceCompletion CompletionNotifier)<br />{<br />    <span style="color: rgb(0, 0, 255);">bool</span> bResult = <span style="color: rgb(0, 0, 255);">false</span>;<br />    Exception exception = <span style="color: rgb(0, 0, 255);">null</span>;<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Individualization Service Request in progress...&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">try</span><br />    {<br />        await IndivRequest.BeginServiceRequest();<br />    }<br />    <span style="color: rgb(0, 0, 255);">catch</span> (Exception ex)<br />    {<br />        exception = ex;<br />    }<br />    <span style="color: rgb(0, 0, 255);">finally</span><br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (exception == <span style="color: rgb(0, 0, 255);">null</span>)<br />        {<br />            bResult = <span style="color: rgb(0, 0, 255);">true</span>;<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            COMException comException = exception <span style="color: rgb(0, 0, 255);">as</span> COMException;<br />            <span style="color: rgb(0, 0, 255);">if</span> (comException != <span style="color: rgb(0, 0, 255);">null</span> &amp;&amp; comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED)<br />            {<br />                IndivRequest.NextServiceRequest();<br />            }<br />        }<br />    }<br />    <span style="color: rgb(0, 0, 255);">if</span> (bResult == <span style="color: rgb(0, 0, 255);">true</span>)<br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Individualization Service Request successful&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">else</span><br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Individualization Service Request failed&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (CompletionNotifier != <span style="color: rgb(0, 0, 255);">null</span>) CompletionNotifier.Complete(bResult);<br />    <span style="color: rgb(0, 0, 255);">return</span> bResult;<br /><br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked to send a PlayReady request (Individualization or License request)</span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async <span style="color: rgb(0, 0, 255);">void</span> ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager ServiceRequested&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (srEvent.Request <span style="color: rgb(0, 0, 255);">is</span> PlayReadyIndividualizationServiceRequest)<br />    {<br />        PlayReadyIndividualizationServiceRequest IndivRequest = srEvent.Request <span style="color: rgb(0, 0, 255);">as</span> PlayReadyIndividualizationServiceRequest;<br />        <span style="color: rgb(0, 0, 255);">bool</span> bResultIndiv = await ReactiveIndivRequest(IndivRequest, srEvent.Completion);<br />    }<br />    <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 255);">if</span> (srEvent.Request <span style="color: rgb(0, 0, 255);">is</span> PlayReadyLicenseAcquisitionServiceRequest)<br />    {<br />        PlayReadyLicenseAcquisitionServiceRequest licenseRequest = srEvent.Request <span style="color: rgb(0, 0, 255);">as</span> PlayReadyLicenseAcquisitionServiceRequest;<br />        LicenseAcquisitionRequest(licenseRequest, srEvent.Completion, PlayReadyLicenseUrl, PlayReadyChallengeCustomData);<br />    }<br />}<br /></pre>

  <br /></div>

<p>In the method associated with Click event on button “Play”, first initialize PlayReadyLicenseUrl with the Uri of the PlayReady Server (if defined), initialize PlayReadyChallengeCustomData with the data required to generate the PlayReady challenge (if defined). Then call the method RegisterDashPlugin to register the DashDownloaderPlugin (if it’s MPEG DASH Uri), and then initialize Player Source with the Uri of the video you want to play.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">PlayReadyLicenseUrl = PlayReadyUri.Text;<br />PlayReadyChallengeCustomData = CustomData.Text;<br />RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><br /></pre>

  <br /></div>

<p>Sample Uris compliant with MPEG DASH and Smooth Streaming protected with PlayReady format are available with the sample application.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest<br />http://wams.edgesuite.net/media/SintelTrailer_Smooth_from_WAME_CENC/NoSubSampleAdjustment/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)<br />http://wams.edgesuite.net/media/Tears_of_Steel_Smooth_1080p_Protected2/tears_of_steel_1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p>By default the applications will try to play the following Smooth Streaming asset: 
  <br /><a href="http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest">http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest</a> 

  <br />using the following URL for the license acquisition: 

  <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1">http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1</a> 

  <br />This URL will return a non-persistent license. Each time the application will try to play the smooth streaming asset, a request to the PlayReady server will be transmitted. 

  <br />By default, the challenge custom data is empty, you can change this field if the PlayReady server expect a specific challenge custom data. 

  <br />If you use the following URL, the license returned will be persistent: 

  <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx">http://playready.directtaps.net/pr/svc/rightsmanager.asmx</a></p>

<p><b>Applications Windows Phone 8.0:</b></p>

<p>Add a reference to: 
  <br />« Microsoft.Web.Media.SmoothStreaming »,&#160; <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin» for Windows Phone 8.0 application. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7446.image_thumb31_7BE43C44.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7446.image_5F00_thumb31_5F00_7BE43C44.png"><img title="image_thumb31" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb31" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0647.image_thumb31_thumb_4FC73F53.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0647.image_5F00_thumb31_5F00_thumb_5F00_4FC73F53.png" width="244" height="113" /></a>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0167.image_thumb33_14766A46.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0167.image_5F00_thumb33_5F00_14766A46.png"><img title="image_thumb33" style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" border="0" alt="image_thumb33" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5707.image_thumb33_thumb_7D4AEFC7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5707.image_5F00_thumb33_5F00_thumb_5F00_7D4AEFC7.png" width="296" height="49" /></a></p>

<p><b><i>Http Client Library:</i></b><b>&#160;&#160;&#160;&#160; <br /></b>These PlayReady sample applications are based on Player Framework V2.0 and the PlayReady license acquisition is based on HttpClient class for both platforms Windows and Windows Phone.&#160;&#160; <br />HttpClient is a part of .NET Framework 4.5 and Windows Store applications that provides developers an extremely easy way to connect with services across the Internet including REST-based services. HttpClient is available for Windows Phone developers provided you install the Microsoft HttpClient Libraries Nuget package. </p>

<p>On the XAML MainPage insert the « PlayerFramework:MediaPlayer » and call it « Player ».</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span>  <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Visible&quot;</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span>  <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <br /><span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>     <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>

  <br /></div>
Create a method RegisterPlugins which associates the Adaptive plugin with the Smooth Streaming Uri opened by the Player, which initialize the property “LicenseAcquirer” of Player MediaElement. 

<br />This method is called in the method OnNavigatedTo.&#160; <br />Create a method RegisterDashPlugins which associates the DashDownloaderPlugin plugin with the Adaptive plugin used by the Player. This method is called before playing any MPEG DASH content. 

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br /><span style="color: rgb(0, 0, 255);">void</span> RegisterDashPlugin(<span style="color: rgb(0, 0, 255);">bool</span> bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().First();<br />    <span style="color: rgb(0, 0, 255);">if</span> (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register DASH plugin&quot;</span>);<br />            <span style="color: rgb(0, 0, 255);">if</span> (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />    }<br />}<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br />    Player.Plugins.Add(adaptivePlugin);<br /><br />    <span style="color: rgb(0, 128, 0);">// PlayReady</span><br />    <span style="color: rgb(0, 128, 0);">// Init PlayReady </span><br />    adaptivePlugin.MediaElement.LicenseAcquirer = <span style="color: rgb(0, 0, 255);">new</span> WindowsPhoneLicenseAcquisition(<span style="color: rgb(0, 0, 255);">null</span>);<br />}<br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    PhoneApplicationService.Current.Deactivated += App_Suspending;<br />    PhoneApplicationService.Current.Activated += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br />    RegisterPlugins();<br />}<br /></pre>

  <br /></div>

<p>To support PlayReady, the application must call the license server to acquire the PlayReady license associated with the content. You need to include in the project the files&#160; <strong><em>CommonLicenseRequest.cs </em></strong>and <strong><em>WindowsPhoneLicenseAcquisition.cs </em></strong>. The file <strong><em>CommonLicenseRequest.cs </em></strong>implements the common class based on HttpClient to acquire the PlayReady license. The file <b><i>WindowsPhoneLicenseAcquisition.cs</i></b> implements the class WindowsPhoneLicenseAcquisition derived from the PlayReady class LicenseAcquirer used to acquire the PlayReady license.</p>

<p>In the method associated with the Click event on the « Play » button, 
  <br />- initialize PlayReadyLicenseUrl with the PlayReady server Uri (if defined), 

  <br />- initialize PlayReadyChallengeCustomData with the data required to generate the PlayReady challenge (if defined), 

  <br />- initialize Player Source to null and 

  <br />- call the Player method « Close » du Player 

  <br />- if PlayReadyChallengeCustomData is defined, initialize LicenseAcquirer.ChallengeCustomData of Player Media Element. 

  <br />- if PlayReadyLicenseUrl is defined, initialize LicenseAcquirer.LicenseServerUriOverride of Player Media Element . 

  <br />- call the method RegisterDashPlugin 

  <br />- then initialize the Player Source with the content Uri . </p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">PlayReadyLicenseUrl = PlayReadyUri.Text;<br />     PlayReadyChallengeCustomData = CustomData.Text;<br /><br />     <span style="color: rgb(0, 128, 0);">// Reset the source and close the player</span><br />     Player.Source = <span style="color: rgb(0, 0, 255);">null</span>;<br />     Player.Close();<br /><br />     Microsoft.PlayerFramework.Adaptive.AdaptivePlugin ap = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().FirstOrDefault();<br />     <span style="color: rgb(0, 0, 255);">if</span> (ap != <span style="color: rgb(0, 0, 255);">null</span>)<br />     {<br />         <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(PlayReadyChallengeCustomData))<br />         {<br />             System.Text.UTF8Encoding encoding = <span style="color: rgb(0, 0, 255);">new</span> System.Text.UTF8Encoding();<br />             <span style="color: rgb(0, 0, 255);">byte</span>[] b = encoding.GetBytes(PlayReadyChallengeCustomData);<br />             ap.MediaElement.LicenseAcquirer.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);<br />         }<br />         <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(PlayReadyLicenseUrl))<br />             ap.MediaElement.LicenseAcquirer.LicenseServerUriOverride = <span style="color: rgb(0, 0, 255);">new</span> Uri(PlayReadyLicenseUrl, UriKind.Absolute);<br />         <span style="color: rgb(0, 0, 255);">else</span><br />             ap.MediaElement.LicenseAcquirer.LicenseServerUriOverride = <span style="color: rgb(0, 0, 255);">null</span>;<br />     }<br /> <br />       Player.Visibility = System.Windows.Visibility.Visible;<br />       PlayerSSME.Visibility = System.Windows.Visibility.Collapsed;<br /><br />     <span style="color: rgb(0, 128, 0);">/// if MPEG DASH Uri Register Dash Plugin </span><br />     RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br /><br />     Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br />Player.Source = <span style="color: rgb(0, 0, 255);">null</span>;<br />Player.Close();<br /><br />RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><br /></pre>

  <br /></div>

<p>Sample Uris compliant with MPEG DASH and Smooth Streaming protected with PlayReady format are available with the sample application.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest<br />http://wams.edgesuite.net/media/SintelTrailer_Smooth_from_WAME_CENC/NoSubSampleAdjustment/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)<br />http://wams.edgesuite.net/media/Tears_of_Steel_Smooth_1080p_Protected2/tears_of_steel_1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p><b>BUILDING THE APPLICATIONS</b></p>

<p>In order to build the MediaPlayer sample applications for Windows Phone 8.0, Windows Phone 8.1 and Windows 8.1, make sure you have the basics installed: a computer running Windows 8.1, Visual Studio 2013 Update 2 with Windows Phone 8.1 SDK and the supplementary SDKs: </p>

<ul>
  <li>Smooth Streaming Client SDK for Windows 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 
    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Smooth Streaming Client SDK for Windows Phone 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a></li>

  <li>Player Framework for Windows and Windows Phone V2.0: 
    <br /><a href="http://playerframework.codeplex.com/releases/view/121773">http://playerframework.codeplex.com/releases/view/121773</a></li>

  <li>PlayReady Client SDK for Windows 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b">http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b</a></li>

  <li>PlayReady Client SDK for Windows Phone 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f</a> 

    <br /></li>
</ul>

<p><b>DOWNLOADING THE PROJECTS</b></p>

<p>Download:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/0218.MediaPlayer.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39/0218.MediaPlayer.zip">C# (15.7 MB)</a>&#160;&#160; <br />Requires:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows Phone 8, Windows 8.1, Windows Phone 8.1, Visual Studio 2013 Update 2&#160;&#160; <br />Last updated:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 5/28/2014 

  <br />License:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/7824.license.rtf" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/7824.license.rtf">MS-LPL</a> 

  <br />Technologies:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PlayReady, WMV, MP4, MPEG2-TS, Smooth Streaming, MPEG DASH,&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Player Framework, C#, XAML&#160;&#160; <br />Topics:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PlayReady Smooth Streaming MPEG DASH Player for Windows Phone and Windows Store </p>]]></content:encoded>
    </item>
    <item>
      <title>Créer une application de lecture Audio/Vidéo pour Windows Phone 8, Windows 8.1 et Windows Phone 8.1 en utilisant le Player Framework v2.0</title>
      <link>https://docs.microsoft.com/archive/blogs/flecoqui/crer-une-application-de-lecture-audiovido-pour-windows-phone-8-windows-8-1-et-windows-phone-8-1-en-utilisant-le-player-framework-v2-0</link>
      <pubDate>Wed, 28 May 2014 08:53:10 GMT</pubDate>
      <dc:creator><![CDATA[FRED LE COQUIL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/flecoqui/2014/05/28/crer-une-application-de-lecture-audiovido-pour-windows-phone-8-windows-8-1-et-windows-phone-8-1-en-utilisant-le-player-framework-v2-0/</guid>
      <description><![CDATA[INTRODUCTION  Cet article décrit les différentes étapes pour créer des applications Windows Phone 8,...]]></description>
      <content:encoded><![CDATA[<p><b>INTRODUCTION</b></p>  <p>Cet article décrit les différentes étapes pour créer des applications Windows Phone 8, Windows 8.1 et Windows Phone 8.1 capables de jouer les formats de vidéos suivants:    <br />- WMV, MP4, MPEG2-TS (Seulement pour Windows 8.1) pour l’étape 1,     <br />- Smooth Streaming pour l’étape 2,     <br />- MPEG DASH pour l’étape 3     <br />- Smooth Streaming et MPEG DASH protégées par PlayReady pour l’étape 4.     <br />Avec les exemples d’application fournis avec cet article l’utilisateur peut définir:     <br />- l’URL de la vidéo,     <br />- l’URL utilisée pour l’acquisition de la licence PlayReady,     <br />- le « Challenge Custom Data » transmis au serveur PlayReady pour acquérir la licence PlayReady.     <br />Si l’URL utilisée pour l’acquisition de licence n’est pas définie, l’application utilisera l’URL inclue dans l’en-tête de protection PlayReady du manifeste de la vidéo.     <br />L’application propose par défaut une liste de vidéos pour tester les différents formats.     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8420.image_5285ACBC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8420.image_5F00_5285ACBC.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7774.image_thumb_4FDF81BC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7774.image_5F00_thumb_5F00_4FDF81BC.png" width="162" height="294" /></a>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7711.image_0AC6B486.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7711.image_5F00_0AC6B486.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6505.image_thumb_4F09AC83.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6505.image_5F00_thumb_5F00_4F09AC83.png" width="164" height="297" /></a>     <br /><b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows Phone 8</b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <b>Windows Phone 8.1</b></p>  <p><b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4061.image_77A8188A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4061.image_5F00_77A8188A.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4331.image_thumb_02D43386.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4331.image_5F00_thumb_5F00_02D43386.png" width="445" height="247" /></a></b>     <br /><b>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows 8.1      <br />      <br /></b><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2063.image_79375D46.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2063.image_5F00_79375D46.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8880.image_thumb_71AE7E8A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8880.image_5F00_thumb_5F00_71AE7E8A.png" width="602" height="301" /></a></p>  <p><b>ETAPE 1: LECTEUR AUDIO/VIDEO (WMV, MP4, MPEG2-TS)</b></p>  <p>Les applications pour Windows Phone 8, Windows 8.1 et Windows Phone 8.1 de l’étape 1 sont capables de lire les formats suivants :    <br />- pour Windows: WMV, MP4, MPEG2-TS     <br />- pour Windows Phone : WMV, MP4,</p>  <p>Aucun SDK supplémentaire n’est nécessaire pour générer ces applications.    <br />    <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2480.image_2B974AE2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2480.image_5F00_2B974AE2.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1351.image_thumb_6927395C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1351.image_5F00_thumb_5F00_6927395C.png" width="608" height="303" /></a></p>  <p><b>Applications Windows 8.1, Windows Phone 8.1 et Windows Phone 8.0 :</b></p>  <p>Sur la MainPage XAML insérer le MediaElement et nommer le « Player »    <br /></p>  <div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 81.62%; height: 55px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">   <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MediaElement</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span><br /><span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>

  <br /></div>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », initialiser la Source du Player avec l’url du fichier à jouer 
  <br /></p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 81.16%; height: 35px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 120.21%; height: 16px; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);</pre>

  <br /></div>

<p>Les urls associées à des fichiers WMV, MP4 et MPEG2-TS disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 80.79%; height: 99px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 99.54%; height: 64px; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://livestreamingvm.cloudapp.net/vod/wmv/test1.wmv<br />http://livestreamingvm.cloudapp.net/vod/mp4/test1.mp4<br />http://livestreamingvm.cloudapp.net/vod/ts/test1.ts</pre>

  <br /></div>

<p><b>
    <br /></b><b>ETAPE 2: LECTEUR AUDIO/VIDEO (WMV, MP4, MPEG2-TS, SMOOTH STREAMING)</b></p>

<p>Les applications pour Windows Phone 8, Windows 8.1 et Windows Phone 8.1 de l’étape 2 sont capables de lire les formats suivants : 
  <br />- pour Windows: WMV, MP4, MPEG2-TS et Smooth Streaming 

  <br />- pour Windows Phone : WMV, MP4 et Smooth Streaming</p>

<p>Les SDK supplémentaires suivants sont nécessaires pour générer ces applications :</p>

<ul>
  <li>Windows 8.0 (not required for this application) 
    <br />Smooth Streaming Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a></li>

  <li>Windows 8.1 
    <br />Smooth Streaming Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Windows Phone 8.0 
    <br />Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 

    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Windows Phone 8.1 
    <br />Smooth Streaming Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a> 

    <br /></li>
</ul>

<p>&#160;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5125.image_35F17688.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5125.image_5F00_35F17688.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8765.image_thumb_7315320D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8765.image_5F00_thumb_5F00_7315320D.png" width="679" height="339" /></a> 

  <br /></p>

<p><b>Applications Windows 8.1 et Windows Phone 8.1:</b></p>

<p>Ajouter une référence au « Microsoft Smooth Streaming Client SDK for Windows 8.1 » pour l’application Windows 8.1. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1754.image_4119AB9F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1754.image_5F00_4119AB9F.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7043.image_thumb_0E49A52B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7043.image_5F00_thumb_5F00_0E49A52B.png" width="244" height="76" /></a></p>

<p>Ajouter une référence au « Microsoft Smooth Streaming Client SDK for Windows Phone 8.1 » pour l’application Windows Phone 8.1. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6813.image_5E225A67.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6813.image_5F00_5E225A67.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5857.image_thumb_4043D666.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5857.image_5F00_thumb_5F00_4043D666.png" width="244" height="68" /></a></p>

<p>Sur la MainPage XAML insérer le MediaElement et nommer le « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 70.16%; height: 102px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MediaElement</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span><br /><span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span> <br /><span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>

  <br /></div>

<p>Créez une méthode RegisterPlugins qui associe la librairie Smooth Streaming avec l’ouverture d’url Smooth Streaming par le MediaElement. Cette méthode est appelée dans la méthode OnNavigatedTo. 
  <br /></p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> Windows.Media.MediaExtensionManager MediaManager;<br /><span style="color: rgb(0, 0, 255);">public</span> IAdaptiveSourceManager AdaptiveSrcManager { get; <span style="color: rgb(0, 0, 255);">private</span> set; }<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />     LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br />     <span style="color: rgb(0, 0, 255);">if</span> (MediaManager == <span style="color: rgb(0, 0, 255);">null</span>)<br />                MediaManager = <span style="color: rgb(0, 0, 255);">new</span> Windows.Media.MediaExtensionManager();<br />     <span style="color: rgb(0, 0, 255);">if</span> (AdaptiveSrcManager == <span style="color: rgb(0, 0, 255);">null</span>)<br />                AdaptiveSrcManager = AdaptiveSourceManager.GetDefault();<br />     PropertySet ssps = <span style="color: rgb(0, 0, 255);">new</span> PropertySet();<br />     ssps[<span style="color: rgb(0, 96, 128);">&quot;{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}&quot;</span>] = AdaptiveSrcManager;<br /><br /><br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.ism&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;text/xml&quot;</span>, ssps);<br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.ism&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;application/vnd.ms-sstr+xml&quot;</span>, ssps);<br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.isml&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;text/xml&quot;</span>, ssps);<br />     MediaManager.RegisterByteStreamHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;.isml&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;application/vnd.ms-sstr+xml&quot;</span>, ssps);<br />     MediaManager.RegisterSchemeHandler(<span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;ms-sstr:&quot;</span>, ssps);<br />} <br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    Application.Current.Suspending += App_Suspending;<br />    Application.Current.Resuming += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br /><span style="color: rgb(204, 102, 51);">#if</span> WINDOOWS_PHONE_APP<br />    DisplayInformation.GetForCurrentView().OrientationChanged += OnOrientationChanged;<br /><span style="color: rgb(204, 102, 51);">#endif</span><br />    RegisterPlugins();<br />}<br /></pre>

  <br /></div>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », initialiser la Source du Player avec l’url du fichier à jouer</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);</pre>

  <br /></div>

<p>Les urls associées au smooth streaming sont disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://livestreamingvm.cloudapp.net/vod/test1/test1.ism/manifest</pre>

  <br /></div>

<p><b>Applications Windows Phone 8.0:</b></p>

<p>Ajouter une référence au « Microsoft.Web.Media.SmoothStreaming » pour l’application Windows Phone 8.0. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8816.image_7B2B092F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8816.image_5F00_7B2B092F.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0508.image_thumb_1D829EA9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0508.image_5F00_thumb_5F00_1D829EA9.png" width="244" height="72" /></a></p>

<p>Sur la MainPage XAML : 
  <br />- insérer le MediaElement utilisé pour jouer le contenu WMV, MP4 et nommer le « Player » 

  <br />- insérer le SmoothStreamingMediaElement utilisé pour jouer le contenu Smooth Streaming et nommer le « PlayerSSME »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.25%; height: 130px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 98.41%; height: 128px; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">MediaElement</span> <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Visible&quot;</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <br /><span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">ssme:SmoothStreamingMediaElement</span> <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Collapsed&quot;</span> <br /><span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;PlayerSSME&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Stretch</span><span style="color: rgb(0, 0, 255);">=&quot;Uniform&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <br /><span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span></pre>

  <br /></div>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », si l’url est une url Smooth Streaming, initialiser la Source du PlayerSSME avec l’url du fichier à jouer, sinon initialiser la Source du Player avec l’url du fichier à jouer</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 61.23%; height: 78px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">if</span> (MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;/manifest&quot;</span>, StringComparison.CurrentCultureIgnoreCase))<br />    PlayerSSME.SmoothStreamingSource = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><span style="color: rgb(0, 0, 255);">else</span> <br />    Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /></pre>

  <br /></div>

<p>Les urls associées au smooth streaming sont disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 61.61%; height: 74px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://livestreamingvm.cloudapp.net/vod/test1/test1.ism/manifest</pre>

  <br /></div>

<p><b>ETAPE 3: LECTEUR AUDIO/VIDEO (WMV, MP4, MPEG2-TS, SMOOTH STREAMING, MPEG DASH)</b></p>

<p>Les applications pour Windows Phone 8, Windows 8.1 et Windows Phone 8.1 de l’étape 3 sont capables de lire les formats suivants : 
  <br />- pour Windows: WMV, MP4, MPEG2-TS, Smooth Streaming et MPEG DASH 

  <br />- pour Windows Phone : WMV, MP4, Smooth Streaming et MPEG DASH</p>

<p>Les SDK supplémentaires suivants sont nécessaires pour générer ces applications :</p>

<ul><!--StartFragment-->
  <li>Windows 8.0 (not required for this application) 
    <br />Smooth Streaming Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a></li>

  <li>Windows 8.1 
    <br />Smooth Streaming Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Windows Phone 8.0 
    <br />Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 

    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Windows Phone 8.1 
    <br />Smooth Streaming Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a></li>

  <li>Windows Phone 8.0, Windows Phone 8.1 et Windows 8.1 
    <br />Player Framework for Windows and Windows Phone V2.0: 

    <br /><a href="http://playerframework.codeplex.com/releases/view/121773">http://playerframework.codeplex.com/releases/view/121773</a> 

    <br /></li>
</ul>

<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6811.image_5869D172.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6811.image_5F00_5869D172.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4101.image_thumb_03B0F92B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4101.image_5F00_thumb_5F00_03B0F92B.png" width="645" height="322" /></a></p>

<p><b>Applications Windows 8.1 et Windows Phone 8.1:</b></p>

<p>Ajouter une référence au « Microsoft Smooth Streaming Client SDK for Windows 8.1 », au « Microsoft Player Framework », au « Microsoft Player Framework Adaptive Streaming Plugin», au « Microsoft Player Framework Dash Plugin» pour l’application Windows 8.1. 
  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7356.image_6C194BB7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7356.image_5F00_6C194BB7.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5611.image_thumb_7C281A6E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5611.image_5F00_thumb_5F00_7C281A6E.png" width="244" height="110" /></a></p>

<p>Ajouter une référence au: 
  <br />« Microsoft Smooth Streaming Client SDK for Windows Phone 8.1 », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin» pour l’application Windows Phone 8.1. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0317.image_067BCF80.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0317.image_5F00_067BCF80.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5047.image_thumb_689D4B7E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5047.image_5F00_thumb_5F00_689D4B7E.png" width="244" height="104" /></a></p>

<p>Sur la MainPage XAML insérer le « PlayerFramework:MediaPlayer » et nommer le « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; height: 127px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span>         <br />            <span style="color: rgb(255, 0, 0);">IsTimelineVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeElapsedVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsDurationVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeRemainingVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false« <br />            IsInfoVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&quot;  IsMoreVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span>«  <span style="color: rgb(255, 0, 0);">IsFastForwardVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsRewindVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span><br />            <span style="color: rgb(255, 0, 0);">IsSkipBackVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsSkipAheadVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <span style="color: rgb(255, 0, 0);">IsSkipPreviousVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>   <span style="color: rgb(255, 0, 0);">IsReplayVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;True&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span>  <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>

  <br /></div>

<p>Créez une méthode RegisterPlugins qui associe le plugin Adaptive avec le Player. Cette méthode est appelée dans la méthode OnNavigatedTo. 
  <br />Créez une méthode RegisterDashPlugins qui associe le plugin DashDownloaderPlugin avec le plugin Adaptive du Player. Cette méthode est appelée avant de jouer un contenu MPEG DASH.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; height: 794px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br /><span style="color: rgb(0, 0, 255);">void</span> RegisterDashPlugin(<span style="color: rgb(0, 0, 255);">bool</span> bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().First();<br />    <span style="color: rgb(0, 0, 255);">if</span> (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register DASH plugin&quot;</span>);<br />            <span style="color: rgb(0, 0, 255);">if</span> (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Unregister DASH plugin&quot;</span>);<br />            plugin.DownloaderPlugin = <span style="color: rgb(0, 0, 255);">null</span>;<br />        }<br />    }<br />}<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br /><br />    <span style="color: rgb(0, 0, 255);">if</span> (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br /><br />    Player.Plugins.Add(adaptivePlugin);<br />}<br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    Application.Current.Suspending += App_Suspending;<br />    Application.Current.Resuming += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br /><span style="color: rgb(204, 102, 51);">#if</span> WINDOWS_PHONE_APP<br />    DisplayInformation.GetForCurrentView().OrientationChanged += OnOrientationChanged;<br /><span style="color: rgb(204, 102, 51);">#endif</span><br />    RegisterPlugins();<br />}<br /><br /></pre>

  <br /></div>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », initialiser la Source du Player avec l’url du fichier à jouer. S’il s’agit d’un contenu MPEG DASH, appeler la méthode RegisterDashPlugin préalablement.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /></pre>

  <br /></div>

<p>Les urls associées au MPEG DASH sont disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">http://wams.edgesuite.net/media/SintelTrailer_Smooth_SeekDemo/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p><b>Applications Windows Phone 8.0:</b></p>

<p>Ajouter une référence au: 
  <br />« Microsoft.Web.Media.SmoothStreaming », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin» pour l’application Windows Phone 8.0. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3718.image_66635373.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3718.image_5F00_66635373.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7853.image_thumb_2869C2B5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7853.image_5F00_thumb_5F00_2869C2B5.png" width="244" height="94" /></a></p>

<p>Sur la MainPage XAML insérer le « PlayerFramework:MediaPlayer » et nommer le « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span>  <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Visible&quot;</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span>  <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <br /><span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>     <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>

  <br /></div>

<p>Créez une méthode RegisterPlugins qui associe le plugin Adaptive avec le Player. Cette méthode est appelée dans la méthode OnNavigatedTo. 
  <br />Créez une méthode RegisterDashPlugins qui associe le plugin DashDownloaderPlugin avec le plugin Adaptive du Player. Cette méthode est appelée avant de jouer un contenu MPEG DASH.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br />void RegisterDashPlugin(bool bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().<span style="color: rgb(0, 0, 255);">First</span>();<br />    if (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        if (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(&quot;Register DASH plugin&quot;);<br />            if (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = new Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />    }<br />}<br />void RegisterPlugins()<br />{<br />    LogMessage(&quot;Register plugins&quot;);<br />    if (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = new Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br />    Player.Plugins.<span style="color: rgb(0, 0, 255);">Add</span>(adaptivePlugin);<br />}<br /><br />protected override void OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(&quot;OnNavigatedTo&quot;);<br />    base.OnNavigatedTo(e);<br />    PhoneApplicationService.<span style="color: rgb(0, 0, 255);">Current</span>.Deactivated += App_Suspending;<br />    PhoneApplicationService.<span style="color: rgb(0, 0, 255);">Current</span>.Activated += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br />    RegisterPlugins();<br />}<br /><br /></pre>

  <br /></div>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », initialiser la Source du Player à null et appeler la méthode « Close » du Player, puis initialiser la Source du Player avec l’url du fichier à jouer. S’il s’agit d’un contenu MPEG DASH, appeler la méthode RegisterDashPlugin préalablement.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />Player.Source = <span style="color: rgb(0, 0, 255);">null</span>;<br />Player.Close();<br /><br />RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><br /></pre>

  <br /></div>

<p>Les urls associées au MPEG DASH sont disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">http://wams.edgesuite.net/media/SintelTrailer_Smooth_SeekDemo/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p><b>ETAPE 4: LECTEUR AUDIO/VIDEO (WMV, MP4, MPEG2-TS, SMOOTH STREAMING, MPEG DASH, PLAYREADY)</b></p>

<p>Les applications pour Windows Phone 8, Windows 8.1 et Windows Phone 8.1 de l’étape 4 sont capables de lire les formats suivants : 
  <br />- pour Windows: WMV, MP4, MPEG2-TS, Smooth Streaming et MPEG DASH protégés ou non avec le DRM PlayReady 

  <br />- pour Windows Phone : WMV, MP4, Smooth Streaming et MPEG DASH protégés ou non avec le DRM PlayReady</p>

<p>Les SDK supplémentaires suivants sont nécessaires pour générer ces applications :</p>

<ul>
  <li>Windows 8.0 (not required for this application) 
    <br />Smooth Streaming Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a></li>

  <li>Windows 8.1 
    <br />Smooth Streaming Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Windows Phone 8.0 
    <br />Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 

    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Windows Phone 8.1 
    <br />Smooth Streaming Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a></li>

  <li>Windows Phone 8.0, Windows Phone 8.1 et Windows 8.1 
    <br />Player Framework for Windows and Windows Phone V2.0: 

    <br /><a href="http://playerframework.codeplex.com/releases/view/121773">http://playerframework.codeplex.com/releases/view/121773</a></li>

  <li>Windows 8.0 (not required for this application) 
    <br />PlayReady Client SDK for Windows 8.0: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483</a></li>

  <li>Windows 8.1 
    <br />PlayReady Client SDK for Windows 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b">http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b</a></li>

  <li>Windows Phone 8.1 
    <br />PlayReady Client SDK for Windows Phone 8.1: 

    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f</a> 

    <br /></li>
</ul>

<p>
  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6813.image_3563A2C6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6813.image_5F00_3563A2C6.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1565.image_thumb_79A69AC3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1565.image_5F00_thumb_5F00_79A69AC3.png" width="746" height="372" /></a></p>

<p><b>Les étapes pour l’acquisition d’une licence PlayReady pour les applications de type Universal Apps (Windows 8.1 et Windows Phone 8.1) :</b></p>

<p>Avant de décrire comment le client PlayReady acquiert la licence PlayReady, quelques mots sur le mécanisme d’individualisation. Chaque client PlayReady est associé à un unique certificat et à une clé unique, l’installation de ce certificat et de cette clé s’appelle l’individualisation. 
  <br />De plus avant que le client PlayReady demande une licence pour décripter le contenu, il doit d’abord déterminer si le logiciel PlayReady adéquat est installé sur l’ordinateur de l’utilisateur. Ce logiciel est appelé “individualized black box” (appelé aussi IBX) et est le composant PlayReady client nécessaire pour pouvoir jouer des contenus protégés par PlayReady. Ce composant logiciel permet à l’application cliente de demander et d’utiliser une licence PlayReady. 

  <br />Le client PlayReady pour les applications du Windows Store supporte l’individualisation dynamique: le certificat, la clé, l’IBX sont télélchargés depuis le serveur d’individualisation. Dans votre application Windows Store vous pouvez implémenter une demande d’individualisation réactive ou une demande d’individualisation pro-active.</p>

<p>· <b>La demande pro-active d’individualisation </b>peut être transmise après l’installation de l’application ou quand l’utilisateur lance l’application pour la première fois.</p>

<p>· <b>La demande réactive d’individualisation </b>est automatiquement préparée par le client PlayReady quand l’application est sur le point de jouer un contenu protégé par PlayReady et si le certificat, la clé et l’IBX ne sont pas déjà installés sur l’ordinateur.</p>

<p>Le schéma ci-dessous décrit l’acquisition d’une licence PlayReady pour jouer un contenu protégé par PlayReady avec la transmission d’une requête réactive d’individualisation préalable:&#160; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8461.image_76943CCE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8461.image_5F00_76943CCE.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6758.image_thumb_0F929DC5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6758.image_5F00_thumb_5F00_0F929DC5.png" width="671" height="293" /></a> 

  <br /></p>

<p>Le schéma ci-dessous décrit l’acquisition d’une licence PlayReady pour jouer un contenu protégé par PlayReady sans transmission d’une requête d’individualisation comme l’IBX est déjà installé:&#160; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2480.image_65B2298F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2480.image_5F00_65B2298F.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0285.image_thumb_29F5218D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0285.image_5F00_thumb_5F00_29F5218D.png" width="679" height="240" /></a></p>

<p>Le schéma ci-dessous décrit les échanges entre le client et le serveur quand l’application joue un contenu protégé par PlayReady quand l’IBX est déjà installé et la licence PlayReady déjà acquise:&#160; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6507.image_74EB230D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6507.image_5F00_74EB230D.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7534.image_thumb_0B40C853.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7534.image_5F00_thumb_5F00_0B40C853.png" width="686" height="265" /></a></p>

<p><b>Applications Windows 8.1 et Windows Phone 8.1:</b></p>

<p>Ajouter une référence au: 
  <br />« Microsoft Smooth Streaming Client SDK for Windows 8.1 », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin», 

  <br />« Microsoft PlayReady Client SDK» pour l’application Windows 8.1. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0020.image_4F83C050.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0020.image_5F00_4F83C050.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5023.image_thumb_1CB3B9DC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5023.image_5F00_thumb_5F00_1CB3B9DC.png" width="244" height="123" /></a></p>

<p>Ajouter une référence au: 
  <br />« Microsoft Smooth Streaming Client SDK for Windows Phone 8.1 », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin», 

  <br />« Microsoft PlayReady Client SDK» pour l’application Windows Phone 8.1. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5850.image_212CCB54.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5850.image_5F00_212CCB54.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1565.image_thumb_6E5CC4DF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1565.image_5F00_thumb_5F00_6E5CC4DF.png" width="244" height="113" /></a></p>

<p>Sur la MainPage XAML insérer le « PlayerFramework:MediaPlayer » et nommer le « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; height: 132px; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;2&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;4&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span> <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;20,10,20,10&quot;</span>         <br />            <span style="color: rgb(255, 0, 0);">IsTimelineVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeElapsedVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsDurationVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false&quot;</span> <span style="color: rgb(255, 0, 0);">IsTimeRemainingVisible</span><span style="color: rgb(0, 0, 255);">=&quot;false« <br />            IsInfoVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span><span style="color: rgb(0, 0, 255);">&quot;  IsMoreVisible=&quot;</span><span style="color: rgb(255, 0, 0);">false</span>«  <span style="color: rgb(255, 0, 0);">IsFastForwardVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsRewindVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span><br />            <span style="color: rgb(255, 0, 0);">IsSkipBackVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsSkipAheadVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <span style="color: rgb(255, 0, 0);">IsSkipPreviousVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>   <span style="color: rgb(255, 0, 0);">IsReplayVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <br />            <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;True&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span>  <span style="color: rgb(0, 0, 255);">/&gt;</span><br /><br /></pre>

  <br /></div>

<p>Créez une méthode RegisterPlugins qui associe le plugin Adaptive avec le Player, qui créé un MediaProtectionManager associé au Player et qui enregistre les événements PlayReady « ServiceRequested » et « ComponentLoadFailed » 
  <br />Cette méthode est appelée dans la méthode OnNavigatedTo. 

  <br />Créez une méthode RegisterDashPlugins qui associe le plugin DashDownloaderPlugin avec le plugin Adaptive du Player. Cette méthode est appelée avant de jouer un contenu MPEG DASH.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br /><span style="color: rgb(0, 0, 255);">void</span> RegisterDashPlugin(<span style="color: rgb(0, 0, 255);">bool</span> bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().First();<br />    <span style="color: rgb(0, 0, 255);">if</span> (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register DASH plugin&quot;</span>);<br />            <span style="color: rgb(0, 0, 255);">if</span> (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Unregister DASH plugin&quot;</span>);<br />            plugin.DownloaderPlugin = <span style="color: rgb(0, 0, 255);">null</span>;<br />        }<br />    }<br />}<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br /><br />    <span style="color: rgb(0, 0, 255);">if</span> (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br /><br />    Player.Plugins.Add(adaptivePlugin);<br /><br />    <span style="color: rgb(0, 128, 0);">// PlayReady</span><br />    <span style="color: rgb(0, 128, 0);">// Init PlayReady Protection Manager</span><br />    var protectionManager = <span style="color: rgb(0, 0, 255);">new</span> MediaProtectionManager();<br />    Windows.Foundation.Collections.PropertySet cpSystems = <span style="color: rgb(0, 0, 255);">new</span> Windows.Foundation.Collections.PropertySet();<br />    cpSystems.Add(<span style="color: rgb(0, 96, 128);">&quot;{F4637010-03C3-42CD-B932-B48ADF3A6A54}&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput&quot;</span>); <span style="color: rgb(0, 128, 0);">//Playready</span><br />    protectionManager.Properties.Add(<span style="color: rgb(0, 96, 128);">&quot;Windows.Media.Protection.MediaProtectionSystemIdMapping&quot;</span>, cpSystems);<br />    protectionManager.Properties.Add(<span style="color: rgb(0, 96, 128);">&quot;Windows.Media.Protection.MediaProtectionSystemId&quot;</span>, <span style="color: rgb(0, 96, 128);">&quot;{F4637010-03C3-42CD-B932-B48ADF3A6A54}&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">this</span>.Player.ProtectionManager = protectionManager;<br />    <br />    <span style="color: rgb(0, 128, 0);">// PlayReady Events registration</span><br />    Player.ProtectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed;<br />    Player.ProtectionManager.ServiceRequested += ProtectionManager_ServiceRequested;<br />}<br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    Application.Current.Suspending += App_Suspending;<br />    Application.Current.Resuming += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br /><span style="color: rgb(204, 102, 51);">#if</span> WINDOWS_PHONE_APP<br />    DisplayInformation.GetForCurrentView().OrientationChanged += OnOrientationChanged;<br /><span style="color: rgb(204, 102, 51);">#endif</span><br />    RegisterPlugins();<br />}<br /><br /></pre>

  <br /></div>

<p>Pour supporter PlayReady l’application doit appeler le serveur de licence pour acquérir la licence PlayReady associé au contenu à jouer par le Player. Il faut pour cela inclure le fichier <b><i>CommonLicenseRequest.cs</i></b> dans le projet. Ce fichier contient le code source de la classe commune utilisant HttpClient pour l’acquisition de la licence PlayReady. </p>

<p>La méthode ProtectionManager_ServiceRequested est appelée à chaque demande d’acquisition de licence ou à chaque demande d’invidualisation. S’il s’agit d’une demande d’individualisation la méthode ReactiveIndivRequest est appelée. S’il s’agit d’une demande d’acquisition de licence la méthode LicenseAcquisitionRequest est appelée.&#160;&#160;&#160;&#160; </p>

<p>Si l’URL utilisée pour l’acquisition de licence PlayReady n’est pas précisée par l’utilisateur, l’application utilisera l’URL définie dans l’entête de protection PlayReady du manifeste de la vidéo, la méthode LicenseAcquisitionRequest appelle licenseRequest.BeginServiceRequest. Si l’URL utilisée pour l’acquisition de licence PlayReady est précisée par l’utilisateur, la méthode LicenseAcquisitionRequest crée un challenge PlayReady en utilisant la valeur du champ ChallengeCustomData et appelle la méthode licenseAcquisition.AcquireLicense en utilisant l’URL définie par l’utilisateur. </p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">const</span> <span style="color: rgb(0, 0, 255);">int</span> MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED = -2147174251;<br /><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">string</span> PlayReadyLicenseUrl;<br /><span style="color: rgb(0, 0, 255);">private</span> <span style="color: rgb(0, 0, 255);">string</span> PlayReadyChallengeCustomData;<br /><br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked when the Protection Manager can't load some components</span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br /><span style="color: rgb(0, 0, 255);">void</span> ProtectionManager_ComponentLoadFailed(MediaProtectionManager sender, ComponentLoadFailedEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager ComponentLoadFailed&quot;</span>);<br />    e.Completion.Complete(<span style="color: rgb(0, 0, 255);">false</span>);<br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked to acquire the PlayReady License</span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async <span style="color: rgb(0, 0, 255);">void</span> LicenseAcquisitionRequest(PlayReadyLicenseAcquisitionServiceRequest licenseRequest, MediaProtectionServiceCompletion CompletionNotifier, <span style="color: rgb(0, 0, 255);">string</span> Url, <span style="color: rgb(0, 0, 255);">string</span> ChallengeCustomData)<br />{<br />    <span style="color: rgb(0, 0, 255);">bool</span> bResult = <span style="color: rgb(0, 0, 255);">false</span>;<br />    <span style="color: rgb(0, 0, 255);">string</span> ExceptionMessage = <span style="color: rgb(0, 0, 255);">string</span>.Empty;<br /><br />    <span style="color: rgb(0, 0, 255);">try</span><br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(Url))<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Manual License Acquisition Service Request in progress - URL: &quot;</span> + Url);<br /><br />            <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(ChallengeCustomData))<br />            {<br />                System.Text.UTF8Encoding encoding = <span style="color: rgb(0, 0, 255);">new</span> System.Text.UTF8Encoding();<br />                <span style="color: rgb(0, 0, 255);">byte</span>[] b = encoding.GetBytes(ChallengeCustomData);<br />                licenseRequest.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);<br />            }<br /><br />            PlayReadySoapMessage soapMessage = licenseRequest.GenerateManualEnablingChallenge();<br /><br />            <span style="color: rgb(0, 0, 255);">byte</span>[] messageBytes = soapMessage.GetMessageBody();<br />            HttpContent httpContent = <span style="color: rgb(0, 0, 255);">new</span> ByteArrayContent(messageBytes);<br /><br />            IPropertySet propertySetHeaders = soapMessage.MessageHeaders;<br />            <span style="color: rgb(0, 0, 255);">foreach</span> (<span style="color: rgb(0, 0, 255);">string</span> strHeaderName <span style="color: rgb(0, 0, 255);">in</span> propertySetHeaders.Keys)<br />            {<br />                <span style="color: rgb(0, 0, 255);">string</span> strHeaderValue = propertySetHeaders[strHeaderName].ToString();<br /><br />                <span style="color: rgb(0, 128, 0);">// The Add method throws an ArgumentException try to set protected headers like &quot;Content-Type&quot;</span><br />                <span style="color: rgb(0, 128, 0);">// so set it via &quot;ContentType&quot; property</span><br />                <span style="color: rgb(0, 0, 255);">if</span> (strHeaderName.Equals(<span style="color: rgb(0, 96, 128);">&quot;Content-Type&quot;</span>, StringComparison.OrdinalIgnoreCase))<br />                    httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse(strHeaderValue);<br />                <span style="color: rgb(0, 0, 255);">else</span><br />                    httpContent.Headers.Add(strHeaderName.ToString(), strHeaderValue);<br />            }<br />            CommonLicenseRequest licenseAcquision = <span style="color: rgb(0, 0, 255);">new</span> CommonLicenseRequest();<br />            HttpContent responseHttpContent = await licenseAcquision.AcquireLicense(<span style="color: rgb(0, 0, 255);">new</span> Uri(Url), httpContent);<br />            <span style="color: rgb(0, 0, 255);">if</span> (responseHttpContent != <span style="color: rgb(0, 0, 255);">null</span>)<br />            {<br />                Exception exResult = licenseRequest.ProcessManualEnablingResponse(await responseHttpContent.ReadAsByteArrayAsync());<br />                <span style="color: rgb(0, 0, 255);">if</span> (exResult != <span style="color: rgb(0, 0, 255);">null</span>)<br />                {<br />                    <span style="color: rgb(0, 0, 255);">throw</span> exResult;<br />                }<br />                bResult = <span style="color: rgb(0, 0, 255);">true</span>;<br />            }<br />            <span style="color: rgb(0, 0, 255);">else</span><br />                ExceptionMessage = licenseAcquision.GetLastErrorMessage();<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady License Acquisition Service Request in progress - URL: &quot;</span> + licenseRequest.Uri.ToString());<br />            await licenseRequest.BeginServiceRequest();<br />            bResult = <span style="color: rgb(0, 0, 255);">true</span>;<br />        }<br />    }<br />    <span style="color: rgb(0, 0, 255);">catch</span> (Exception e)<br />    {<br />        ExceptionMessage = e.Message;<br />    }<br /><br />    <span style="color: rgb(0, 0, 255);">if</span> (bResult == <span style="color: rgb(0, 0, 255);">true</span>)<br />        LogMessage(!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(Url) ? <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager Manual PlayReady License Acquisition Service Request successful&quot;</span> :<br />            <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady License Acquisition Service Request successful&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">else</span><br />        LogMessage(!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(Url) ? <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager Manual PlayReady License Acquisition Service Request failed: &quot;</span> + ExceptionMessage :<br />            <span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady License Acquisition Service Request failed: &quot;</span> + ExceptionMessage);<br />    CompletionNotifier.Complete(bResult);<br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Proactive Individualization Request </span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async <span style="color: rgb(0, 0, 255);">void</span> ProActiveIndivRequest()<br />{<br />    PlayReadyIndividualizationServiceRequest indivRequest = <span style="color: rgb(0, 0, 255);">new</span> PlayReadyIndividualizationServiceRequest();<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady ProActive Individualization Service Request in progress...&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">bool</span> bResultIndiv = await ReactiveIndivRequest(indivRequest, <span style="color: rgb(0, 0, 255);">null</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (bResultIndiv == <span style="color: rgb(0, 0, 255);">true</span>)<br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady ProActive Individualization Service Request successful&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">else</span><br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady ProActive Individualization Service Request failed&quot;</span>);<br /><br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked to send the Individualization Request </span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async Task&lt;<span style="color: rgb(0, 0, 255);">bool</span>&gt; ReactiveIndivRequest(PlayReadyIndividualizationServiceRequest IndivRequest, MediaProtectionServiceCompletion CompletionNotifier)<br />{<br />    <span style="color: rgb(0, 0, 255);">bool</span> bResult = <span style="color: rgb(0, 0, 255);">false</span>;<br />    Exception exception = <span style="color: rgb(0, 0, 255);">null</span>;<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Individualization Service Request in progress...&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">try</span><br />    {<br />        await IndivRequest.BeginServiceRequest();<br />    }<br />    <span style="color: rgb(0, 0, 255);">catch</span> (Exception ex)<br />    {<br />        exception = ex;<br />    }<br />    <span style="color: rgb(0, 0, 255);">finally</span><br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (exception == <span style="color: rgb(0, 0, 255);">null</span>)<br />        {<br />            bResult = <span style="color: rgb(0, 0, 255);">true</span>;<br />        }<br />        <span style="color: rgb(0, 0, 255);">else</span><br />        {<br />            COMException comException = exception <span style="color: rgb(0, 0, 255);">as</span> COMException;<br />            <span style="color: rgb(0, 0, 255);">if</span> (comException != <span style="color: rgb(0, 0, 255);">null</span> &amp;&amp; comException.HResult == MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED)<br />            {<br />                IndivRequest.NextServiceRequest();<br />            }<br />        }<br />    }<br />    <span style="color: rgb(0, 0, 255);">if</span> (bResult == <span style="color: rgb(0, 0, 255);">true</span>)<br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Individualization Service Request successful&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">else</span><br />        LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager PlayReady Individualization Service Request failed&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (CompletionNotifier != <span style="color: rgb(0, 0, 255);">null</span>) CompletionNotifier.Complete(bResult);<br />    <span style="color: rgb(0, 0, 255);">return</span> bResult;<br /><br />}<br /><span style="color: rgb(0, 128, 0);">/// &lt;summary&gt;</span><br /><span style="color: rgb(0, 128, 0);">/// Invoked to send a PlayReady request (Individualization or License request)</span><br /><span style="color: rgb(0, 128, 0);">/// &lt;/summary&gt;</span><br />async <span style="color: rgb(0, 0, 255);">void</span> ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;ProtectionManager ServiceRequested&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (srEvent.Request <span style="color: rgb(0, 0, 255);">is</span> PlayReadyIndividualizationServiceRequest)<br />    {<br />        PlayReadyIndividualizationServiceRequest IndivRequest = srEvent.Request <span style="color: rgb(0, 0, 255);">as</span> PlayReadyIndividualizationServiceRequest;<br />        <span style="color: rgb(0, 0, 255);">bool</span> bResultIndiv = await ReactiveIndivRequest(IndivRequest, srEvent.Completion);<br />    }<br />    <span style="color: rgb(0, 0, 255);">else</span> <span style="color: rgb(0, 0, 255);">if</span> (srEvent.Request <span style="color: rgb(0, 0, 255);">is</span> PlayReadyLicenseAcquisitionServiceRequest)<br />    {<br />        PlayReadyLicenseAcquisitionServiceRequest licenseRequest = srEvent.Request <span style="color: rgb(0, 0, 255);">as</span> PlayReadyLicenseAcquisitionServiceRequest;<br />        LicenseAcquisitionRequest(licenseRequest, srEvent.Completion, PlayReadyLicenseUrl, PlayReadyChallengeCustomData);<br />    }<br />}<br /></pre>

  <br /></div>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », initialiser PlayReadyLicenseUrl avec l’Url du serveur PlayReady (si celui-ci est défini), initialiser PlayReadyChallengeCustomData avec les données nécessaires pour la génération du challenge PlayReady (si celles-ci sont définies), initialiser la Source du Player avec l’url du fichier à jouer. S’il s’agit d’un contenu MPEG DASH, appeler la méthode RegisterDashPlugin préalablement.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">PlayReadyLicenseUrl = PlayReadyUri.Text;<br />PlayReadyChallengeCustomData = CustomData.Text;<br />RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><br /></pre>

  <br /></div>

<p>Les urls associées aux contenus Smooth Streaming et MPEG DASH protégés par PlayReady sont disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest<br />http://wams.edgesuite.net/media/SintelTrailer_Smooth_from_WAME_CENC/NoSubSampleAdjustment/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)<br />http://wams.edgesuite.net/media/Tears_of_Steel_Smooth_1080p_Protected2/tears_of_steel_1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p>Par défaut, le contenu Smooth Streaming suivant 
  <br /><a href="http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest">http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest</a> utilisé pour les tests PlayReady est associé à l’URL suivante, la licence retournée par le serveur PlayReady sera persistante: 

  <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx">http://playready.directtaps.net/pr/svc/rightsmanager.asmx</a> 

  <br />En utilisant l’URL suivante pour l’acquisition de licence: 

  <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1">http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1</a> 

  <br />Cette URL renverra une licence non persistante. A chaque tentative de lecture du contenu smooth streaming, une requête sera transmise au serveur PlayReady. 

  <br />Enfin, par défaut, le challenge custom data est vide, vous devez modifier ce champ si le serveur PlayReady attend un challenge custom data spécifique.</p>

<p><b>Applications Windows Phone 8.0:</b></p>

<p>Ajouter une référence au: 
  <br />« Microsoft.Web.Media.SmoothStreaming », 

  <br />« Microsoft Player Framework », 

  <br />« Microsoft Player Framework Adaptive Streaming Plugin», 

  <br />« Microsoft Player Framework Dash Plugin» pour l’application Windows Phone 8.0. 

  <br />

  <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2273.image_2BECB35A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2273.image_5F00_2BECB35A.png"><img title="image" style="margin: 0px; display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5340.image_thumb_0E0E2F59.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5340.image_5F00_thumb_5F00_0E0E2F59.png" width="244" height="113" /></a>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4111.image_36AC9B60.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4111.image_5F00_36AC9B60.png"><img title="image" style="display: inline; background-image: none;" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6675.image_thumb_6AE0C4A6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6675.image_5F00_thumb_5F00_6AE0C4A6.png" width="296" height="49" /></a></p>

<p><b><i>Librairie Http Client:</i></b><b> 
    <br /></b>Les exemples d’application PlayReady fournis avec cet article sont basés sur Player Framework V2.0 et l’acquisition des licences PlayReady est basée sur la classe HttpClient pour les deux plates-formes Windows et Windows Phone.&#160;&#160; <br />HttpClient fait partie intégrante de NET Framework 4.5 et des applications Windows Store et fournit aux développeurs la possibilité d’écrire très facilement des applications se connectant à des services Internet incluant les services basés sur des APIs REST. HttpClient est également disponible pour les développeurs Windows Phone 8.0 si vous installez le package Nuget : « Microsoft http Client Libraries » 

  <br />Sur la MainPage XAML insérer le « PlayerFramework:MediaPlayer » et nommer le « Player »</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">PlayerFramework:MediaPlayer</span>  <span style="color: rgb(255, 0, 0);">Visibility</span><span style="color: rgb(0, 0, 255);">=&quot;Visible&quot;</span> <span style="color: rgb(255, 0, 0);">x:Name</span><span style="color: rgb(0, 0, 255);">=&quot;Player&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Row</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span> <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">Column</span><span style="color: rgb(0, 0, 255);">=&quot;0&quot;</span> <br /><span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">ColumnSpan</span><span style="color: rgb(0, 0, 255);">=&quot;3&quot;</span>  <span style="color: rgb(255, 0, 0);">Grid</span>.<span style="color: rgb(255, 0, 0);">RowSpan</span><span style="color: rgb(0, 0, 255);">=&quot;1&quot;</span>  <span style="color: rgb(255, 0, 0);">Margin</span><span style="color: rgb(0, 0, 255);">=&quot;10,10,10,10&quot;</span> <span style="color: rgb(255, 0, 0);">Background</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <span style="color: rgb(255, 0, 0);">Foreground</span><span style="color: rgb(0, 0, 255);">=&quot;Black&quot;</span> <br /><span style="color: rgb(255, 0, 0);">IsAudioSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(255, 0, 0);">IsCaptionSelectionVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span>     <span style="color: rgb(255, 0, 0);">HorizontalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">VerticalAlignment</span><span style="color: rgb(0, 0, 255);">=&quot;Center&quot;</span>  <span style="color: rgb(255, 0, 0);">IsFullScreenVisible</span><span style="color: rgb(0, 0, 255);">=&quot;False&quot;</span> <span style="color: rgb(0, 0, 255);">/&gt;</span><br /></pre>

  <br /></div>

<p>Créez une méthode RegisterPlugins qui associe le plugin Adaptive avec le Player et initialise LicenseAcquirer du Media Element du Player. Cette méthode est appelée dans la méthode OnNavigatedTo. 
  <br />Créez une méthode RegisterDashPlugins qui associe le plugin DashDownloaderPlugin avec le plugin Adaptive du Player. Cette méthode est appelée avant de jouer un contenu MPEG DASH.</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin adaptivePlugin;<br /><span style="color: rgb(0, 0, 255);">public</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin dashDownloaderPlugin;<br /><br /><span style="color: rgb(0, 0, 255);">void</span> RegisterDashPlugin(<span style="color: rgb(0, 0, 255);">bool</span> bRegister)<br />{<br />    Microsoft.PlayerFramework.Adaptive.AdaptivePlugin plugin = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().First();<br />    <span style="color: rgb(0, 0, 255);">if</span> (plugin != <span style="color: rgb(0, 0, 255);">null</span>)<br />    {<br />        <span style="color: rgb(0, 0, 255);">if</span> (bRegister == <span style="color: rgb(0, 0, 255);">true</span>)<br />        {<br />            LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register DASH plugin&quot;</span>);<br />            <span style="color: rgb(0, 0, 255);">if</span> (dashDownloaderPlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />                dashDownloaderPlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.Media.AdaptiveStreaming.Dash.DashDownloaderPlugin();<br />            plugin.DownloaderPlugin = dashDownloaderPlugin;<br />        }<br />    }<br />}<br /><span style="color: rgb(0, 0, 255);">void</span> RegisterPlugins()<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;Register plugins&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">if</span> (adaptivePlugin == <span style="color: rgb(0, 0, 255);">null</span>)<br />        adaptivePlugin = <span style="color: rgb(0, 0, 255);">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br />    Player.Plugins.Add(adaptivePlugin);<br /><br />    <span style="color: rgb(0, 128, 0);">// PlayReady</span><br />    <span style="color: rgb(0, 128, 0);">// Init PlayReady </span><br />    adaptivePlugin.MediaElement.LicenseAcquirer = <span style="color: rgb(0, 0, 255);">new</span> WindowsPhoneLicenseAcquisition(<span style="color: rgb(0, 0, 255);">null</span>);<br />}<br /><br /><span style="color: rgb(0, 0, 255);">protected</span> <span style="color: rgb(0, 0, 255);">override</span> <span style="color: rgb(0, 0, 255);">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    LogMessage(<span style="color: rgb(0, 96, 128);">&quot;OnNavigatedTo&quot;</span>);<br />    <span style="color: rgb(0, 0, 255);">base</span>.OnNavigatedTo(e);<br />    PhoneApplicationService.Current.Deactivated += App_Suspending;<br />    PhoneApplicationService.Current.Activated += App_Resuming;<br />    Player.MediaEnded += Player_MediaEnded;<br />    Player.MediaOpened += Player_MediaOpened;<br />    Player.MediaFailed += Player_MediaFailed;<br />    RegisterPlugins();<br />}<br /></pre>

  <br /></div>

<p>Pour supporter PlayReady l’application doit appeler le serveur de licence pour acquérir la licence PlayReady associé au contenu à jouer par le Player. Il faut pour cela inclure les fichiers <b><i>CommonLicenseRequest.cs</i></b> et <b><i>WindowsPhoneLicenseAcquisition.cs</i></b> dans le projet. Le fichier <b><i>CommonLicenseRequest.cs</i></b> contient le code source de la classe commune utilisant HttpClient pour l’acquisition de la licence PlayReady. Le fichier <b><i>WindowsPhoneLicenseAcquisition.cs</i></b> contient le code source de la classe WindowsPhoneLicenseAcquisition dérivée de la classe PlayReady LicenseAcquirer utilisée pour l’acquisition de licence PlayReady. </p>

<p>Dans la méthode associée à l’événement Click sur le bouton « Play », 
  <br />- initialiser PlayReadyLicenseUrl avec l’Url du serveur PlayReady (si celui-ci est défini), 

  <br />- initialiser PlayReadyChallengeCustomData avec les données nécessaires pour la génération du challenge PlayReady (si celles-ci sont définies), 

  <br />- initialiser la Source du Player à null et 

  <br />- appeler la méthode « Close » du Player 

  <br />- Si PlayReadyChallengeCustomData est renseigné, initialiser LicenseAcquirer.ChallengeCustomData du Media Element associé au Player. 

  <br />- Si PlayReadyLicenseUrl est renseigné, initialiser LicenseAcquirer.LicenseServerUriOverride du Media Element associé au Player. 

  <br />- appeler la méthode RegisterDashPlugin 

  <br />- puis initialiser la Source du Player avec l’url du fichier à jouer. </p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);">PlayReadyLicenseUrl = PlayReadyUri.Text;<br />     PlayReadyChallengeCustomData = CustomData.Text;<br /><br />     <span style="color: rgb(0, 128, 0);">// Reset the source and close the player</span><br />     Player.Source = <span style="color: rgb(0, 0, 255);">null</span>;<br />     Player.Close();<br /><br />     Microsoft.PlayerFramework.Adaptive.AdaptivePlugin ap = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().FirstOrDefault();<br />     <span style="color: rgb(0, 0, 255);">if</span> (ap != <span style="color: rgb(0, 0, 255);">null</span>)<br />     {<br />         <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(PlayReadyChallengeCustomData))<br />         {<br />             System.Text.UTF8Encoding encoding = <span style="color: rgb(0, 0, 255);">new</span> System.Text.UTF8Encoding();<br />             <span style="color: rgb(0, 0, 255);">byte</span>[] b = encoding.GetBytes(PlayReadyChallengeCustomData);<br />             ap.MediaElement.LicenseAcquirer.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);<br />         }<br />         <span style="color: rgb(0, 0, 255);">if</span> (!<span style="color: rgb(0, 0, 255);">string</span>.IsNullOrEmpty(PlayReadyLicenseUrl))<br />             ap.MediaElement.LicenseAcquirer.LicenseServerUriOverride = <span style="color: rgb(0, 0, 255);">new</span> Uri(PlayReadyLicenseUrl, UriKind.Absolute);<br />         <span style="color: rgb(0, 0, 255);">else</span><br />             ap.MediaElement.LicenseAcquirer.LicenseServerUriOverride = <span style="color: rgb(0, 0, 255);">null</span>;<br />     }<br /> <br />       Player.Visibility = System.Windows.Visibility.Visible;<br />       PlayerSSME.Visibility = System.Windows.Visibility.Collapsed;<br /><br />     <span style="color: rgb(0, 128, 0);">/// if MPEG DASH Uri Register Dash Plugin </span><br />     RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br /><br />     Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br />Player.Source = <span style="color: rgb(0, 0, 255);">null</span>;<br />Player.Close();<br /><br />RegisterDashPlugin((MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;.mpd&quot;</span>, StringComparison.CurrentCultureIgnoreCase) || <br />                     MediaUri.Text.EndsWith(<span style="color: rgb(0, 96, 128);">&quot;manifest(format=mpd-time-csf)&quot;</span>, StringComparison.CurrentCultureIgnoreCase)));<br />Player.Source = <span style="color: rgb(0, 0, 255);">new</span> Uri(MediaUri.Text);<br /><br /></pre>

  <br /></div>

<p>Les urls associées au contenu Smooth Streaming et MPEG DASH protégés par PlayReady sont disponibles sur Microsoft Azure</p>

<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: rgb(244, 244, 244);">
  <pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: &quot;Courier New&quot;, courier, monospace; font-size: 8pt; direction: ltr; background-color: rgb(244, 244, 244);"><br />http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest<br />http://wams.edgesuite.net/media/SintelTrailer_Smooth_from_WAME_CENC/NoSubSampleAdjustment/sintel_trailer-1080p.ism/manifest(format=mpd-time-csf)<br />http://wams.edgesuite.net/media/Tears_of_Steel_Smooth_1080p_Protected2/tears_of_steel_1080p.ism/manifest(format=mpd-time-csf)</pre>

  <br /></div>

<p><b>GENERATION DES APPLICATIONS</b></p>

<p>Pour générer les exemples d’application pour Windows Phone 8.0, Windows Phone 8.1 et Windows 8.1 vous devez disposer d’un ordinateur sous Windows 8.1, du Visual Studio 2013 Update 2 avec le Windows Phone 8.1 SDK et des SDKs supplémentaires : </p>

<ul>
  <li>Smooth Streaming Client SDK for Windows 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40">http://visualstudiogallery.msdn.microsoft.com/0170c67c-c183-4fee-8dd4-c2b44d710d40</a></li>

  <li>Smooth Streaming Client 2.5 SDK for Silverlight and Windows Phone 8 applications: 
    <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">http://</a><a href="http://www.microsoft.com/en-us/download/details.aspx?id=42080">www.microsoft.com/en-us/download/details.aspx?id=42080</a></li>

  <li>Smooth Streaming Client SDK for Windows Phone 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933">visualstudiogallery.msdn.microsoft.com/b837ddf3-6884-436e-aeb7-35c6151a8933</a></li>

  <li>Player Framework for Windows and Windows Phone V2.0: 
    <br /><a href="http://playerframework.codeplex.com/releases/view/121773">http://playerframework.codeplex.com/releases/view/121773</a></li>

  <li>PlayReady Client SDK for Windows 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b">http://visualstudiogallery.msdn.microsoft.com/59be4d26-7f00-463e-9d61-2803c36b576b</a></li>

  <li>PlayReady Client SDK for Windows Phone 8.1: 
    <br /><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">http://</a><a href="http://visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f">visualstudiogallery.msdn.microsoft.com/477225f7-cb03-4fe6-8c5b-bfc76db7c09f</a> 

    <br /></li>
</ul>

<p><b>TELECHARGEMENT DES PROJETS</b></p>

<p>Téléchargement:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/0218.MediaPlayer.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39/0218.MediaPlayer.zip">C# (15.7 MB)</a> 

  <br />Pre-requis:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Windows Phone 8, Windows 8.1, Windows Phone 8.1, Visual Studio 2013 Update 2 

  <br />Dernière modification:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 5/28/2014 

  <br />Licence:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/7824.license.rtf" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/7824.license.rtf">MS-LPL</a> 

  <br />Technologies:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PlayReady, WMV, MP4, MPEG2-TS, Smooth Streaming, MPEG DASH,&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Player Framework, C#, XAML 

  <br />Thème:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PlayReady Smooth Streaming MPEG DASH Player for Windows Phone and Windows Store </p>]]></content:encoded>
    </item>
    <item>
      <title>Communication Bluetooth entre Applications Windows Phone et Applications Windows Store</title>
      <link>https://docs.microsoft.com/archive/blogs/flecoqui/communication-bluetooth-entre-applications-windows-phone-et-applications-windows-store</link>
      <pubDate>Fri, 13 Dec 2013 09:56:00 GMT</pubDate>
      <dc:creator><![CDATA[FRED LE COQUIL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/flecoqui/2013/12/13/communication-bluetooth-entre-applications-windows-phone-et-applications-windows-store/</guid>
      <description><![CDATA[Introduction
Cet article explique comment cr&eacute;er des applications Windows 8.1 et Windows...]]></description>
      <content:encoded><![CDATA[<p><strong><span style="font-size: large;">Introduction</span></strong></p>
<p>Cet article explique comment cr&eacute;er des applications Windows 8.1 et Windows Phone 8 supportant une communication d&rsquo;application &agrave; application via Bluetooth. Avec ces applications, l'utilisateur peut : <br />-transmettre et recevoir des messages texte <br />-transmettre des photos (Application Windows Phone 8 ) <br />-recevoir et enregistrer des photos (Application Windows 8.1) <br />L'application Windows Store s'ex&eacute;cute comme un serveur Bluetooth et l'application Windows Phone s'ex&eacute;cute comme un client Bluetooth.</p>
<p>Afin de supporter une communication d&rsquo;application-&agrave;-application via Bluetooth, vous n'avez pas besoin d&rsquo;utiliser les services de p&eacute;riph&eacute;riques suppl&eacute;mentaires comme un routeur Wi-Fi, un c&acirc;ble USB. Le Windows Phone et l'ordinateur ou la tablette ex&eacute;cutant Windows 8.1 s&rsquo;auto suffisent pour la communication Bluetooth. <br /> <br />Quand j'ai commenc&eacute; &agrave; &eacute;crire les applications Windows Phone et Windows Store, je souhaitais utiliser l'API PeerFinder qui est disponible sur les deux plates-formes, malheureusement actuellement il ne semble pas possible de faire communiquer une application Windows Phone avec une application Windows Store en utilisant cette API.&nbsp; J'ai donc d&eacute;cid&eacute; d'utiliser Bluetooth Rfcomm pour la communication entre les deux plates-formes. Cette approche n&eacute;cessite de pr&eacute;alablement appairer les deux p&eacute;riph&eacute;riques avant de lancer les applications</p>
<p>D&egrave;s que vous &ecirc;tes en mesure de cr&eacute;er une application Windows Phone communicant avec une application Windows Store, vous pouvez lier le d&eacute;ploiement d&rsquo;une application Windows Store avec une application Windows Phone qui peut jouer le r&ocirc;le d&rsquo;application compagnon de l&rsquo;application Windows Store. <br /> <br />Pour g&eacute;n&eacute;rer les applications de cet article Visual Studio 2013 et le SDK Windows Phone 8 sont n&eacute;cessaires. <br /> <br /><strong><span style="font-size: large;">Appairer le Windows Phone avec l&rsquo;ordinateur </span></strong></p>
<p>Avant de lancer les applications vous devez appairer votre Windows Phone avec votre ordinateur ex&eacute;cutant Windows 8.1.</p>
<p>1. Sur l&rsquo;ordinateur sous Windows 8.1, s&eacute;lectionnez la page de configuration <em>&rdquo;PC and Devices&rdquo;</em> . Puis s&eacute;lectionnez la page de configuration <em>&ldquo;Bluetooth&rdquo;</em>. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7180.clip_image002_thumb1_74C1E633.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7180.clip_5F00_image002_5F00_thumb1_5F00_74C1E633.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image002_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1663.clip_image002_thumb1_thumb_7D45457D.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1663.clip_5F00_image002_5F00_thumb1_5F00_thumb_5F00_7D45457D.jpg" alt="clip_image002_thumb[1]" width="505" height="206" border="0" /></a></p>
<p>2. Sur le Windows Phone, assurez-vous que le Bluetooth est activ&eacute;. S&eacute;lectionnez la page de configuration &ldquo;<em>Bluetooth&rdquo;</em> et activez le Bluetooth. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5710.clip_image004_thumb1_34222A75.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5710.clip_5F00_image004_5F00_thumb1_5F00_34222A75.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image004_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0523.clip_image004_thumb1_thumb_685653BB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0523.clip_5F00_image004_5F00_thumb1_5F00_thumb_5F00_685653BB.png" alt="clip_image004_thumb[1]" width="182" height="300" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2110.clip_image006_thumb1_1C8A7D02.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2110.clip_5F00_image006_5F00_thumb1_5F00_1C8A7D02.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image006_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7750.clip_image006_thumb1_thumb_7A357839.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7750.clip_5F00_image006_5F00_thumb1_5F00_thumb_5F00_7A357839.png" alt="clip_image006_thumb[1]" width="182" height="300" border="0" /></a></p>
<p>3. Sur l&rsquo;ordinateur, s&eacute;lectionnez le Windows Phone que vous souhaitez appairer dans la liste des p&eacute;riph&eacute;riques Bluetooth, et cliquez sur le bouton <em>&ldquo;Pair&rdquo;</em> . <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1563.clip_image008_thumb1_351CAB03.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1563.clip_5F00_image008_5F00_thumb1_5F00_351CAB03.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image008_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0334.clip_image008_thumb1_thumb_6950D449.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0334.clip_5F00_image008_5F00_thumb1_5F00_thumb_5F00_6950D449.jpg" alt="clip_image008_thumb[1]" width="329" height="96" border="0" /></a></p>
<p>4. Sur le Windows Phone, acceptez la demande d&rsquo;appairage. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4087.clip_image010_thumb2_4B725048.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4087.clip_5F00_image010_5F00_thumb2_5F00_4B725048.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image010_thumb[2]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2364.clip_image010_thumb2_thumb_42191BC5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2364.clip_5F00_image010_5F00_thumb2_5F00_thumb_5F00_42191BC5.png" alt="clip_image010_thumb[2]" width="208" height="344" border="0" /></a></p>
<p>5. Sur l&rsquo;ordinateur, confirmez l&rsquo;appairage. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6433.clip_image012_thumb1_7FA90A3F.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6433.clip_5F00_image012_5F00_thumb1_5F00_7FA90A3F.jpg"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="clip_image012_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2656.clip_image012_thumb1_thumb_27DB4352.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2656.clip_5F00_image012_5F00_thumb1_5F00_thumb_5F00_27DB4352.jpg" alt="clip_image012_thumb[1]" width="352" height="155" border="0" /></a></p>
<p>6. Sur les deux p&eacute;riph&eacute;riques, le p&eacute;riph&eacute;rique pair est affich&eacute; comme &eacute;tant connect&eacute;. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6560.clip_image014_thumb1_1E820ECF.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6560.clip_5F00_image014_5F00_thumb1_5F00_1E820ECF.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image014_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7077.clip_image014_thumb1_thumb_67A7BA88.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7077.clip_5F00_image014_5F00_thumb1_5F00_thumb_5F00_67A7BA88.jpg" alt="clip_image014_thumb[1]" width="337" height="80" border="0" /></a> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1541.clip_image016_thumb1_70974CC7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1541.clip_5F00_image016_5F00_thumb1_5F00_70974CC7.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image016_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6862.clip_image016_thumb1_thumb_7D912CD8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6862.clip_5F00_image016_5F00_thumb1_5F00_thumb_5F00_7D912CD8.png" alt="clip_image016_thumb[1]" width="183" height="302" border="0" /></a></p>
<p>7. Les p&eacute;riph&eacute;riques sont maintenant appair&eacute;s, vous pouvez lancer les applications sur les deux plates-formes.</p>
<p><strong><span style="font-size: large;">Connecter les applications</span></strong></p>
<p>1. Sur l&rsquo;ordinateur, lancez l&rsquo;application server Bluetooth. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5633.clip_image018_thumb_4D69E215.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5633.clip_5F00_image018_5F00_thumb_5F00_4D69E215.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image018_thumb" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8546.clip_image018_thumb_thumb_019E0B5C.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8546.clip_5F00_image018_5F00_thumb_5F00_thumb_5F00_019E0B5C.jpg" alt="clip_image018_thumb" width="112" height="111" border="0" /></a> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7823.clip_image020_thumb1_78B109CD.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7823.clip_5F00_image020_5F00_thumb1_5F00_78B109CD.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image020_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3542.clip_image020_thumb1_thumb_0853A590.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3542.clip_5F00_image020_5F00_thumb1_5F00_thumb_5F00_0853A590.jpg" alt="clip_image020_thumb[1]" width="653" height="369" border="0" /></a></p>
<p>2. Sur le Windows Phone, lancez l&rsquo;application Bluetooth cliente. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2313.clip_image022_thumb_17F64152.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2313.clip_5F00_image022_5F00_thumb_5F00_17F64152.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image022_thumb" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5226.clip_image022_thumb_thumb_4C2A6A98.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5226.clip_5F00_image022_5F00_thumb_5F00_thumb_5F00_4C2A6A98.jpg" alt="clip_image022_thumb" width="244" height="93" border="0" /></a></p>
<p>3. V&eacute;rifiez sur le Windows Phone et l&rsquo;ordinateur que dans la section Settings le &ldquo;Service Name&rdquo; est le m&ecirc;me, le GUID doit &ecirc;tre le m&ecirc;me sur les deux plates-formes pour autoriser une communication entre les applications. Le GUID est d&eacute;fini dans le code source de l&rsquo;application et dans le manifeste de l&rsquo;application Windows Store. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4503.clip_image024_thumb1_005E93DF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4503.clip_5F00_image024_5F00_thumb1_5F00_005E93DF.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image024_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7178.clip_image024_thumb1_thumb_24F2B214.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7178.clip_5F00_image024_5F00_thumb1_5F00_thumb_5F00_24F2B214.png" alt="clip_image024_thumb[1]" width="213" height="353" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0247.clip_image026_thumb2_4671E1A3.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0247.clip_5F00_image026_5F00_thumb2_5F00_4671E1A3.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image026_thumb[2]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6076.clip_image026_thumb2_thumb_03959D29.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6076.clip_5F00_image026_5F00_thumb2_5F00_thumb_5F00_03959D29.jpg" alt="clip_image026_thumb[2]" width="579" height="196" border="0" /></a></p>
<p>4. Sur l&rsquo;application Windows Phone naviguer vers le pivot <em>&ldquo;Connection&rdquo;</em>. S&eacute;lectionnez le nom de l&rsquo;ordinateur dans la liste &ldquo;Paired devices&rdquo; et cliquez sur le bouton <em>&ldquo;Connect&rdquo;</em>. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3276.clip_image028_thumb1_015BA51E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3276.clip_5F00_image028_5F00_thumb1_5F00_015BA51E.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image028_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5775.clip_image028_thumb1_thumb_5BF1B1AF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5775.clip_5F00_image028_5F00_thumb1_5F00_thumb_5F00_5BF1B1AF.png" alt="clip_image028_thumb[1]" width="212" height="351" border="0" /></a></p>
<p>5. Comme il s''agit de la premi&egrave;re connexion une bo&icirc;te de dialogue appara&icirc;t sur l&rsquo;&eacute;cran de l&rsquo;ordinateur. Autorisez l&rsquo;application Windows &agrave; utiliser votre Windows Phone <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0508.clip_image030_thumb1_327D706F.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0508.clip_5F00_image030_5F00_thumb1_5F00_327D706F.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image030_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4645.clip_image030_thumb1_thumb_29906EE1.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4645.clip_5F00_image030_5F00_thumb1_5F00_thumb_5F00_29906EE1.jpg" alt="clip_image030_thumb[1]" width="458" height="82" border="0" /></a></p>
<p>6. D&egrave;s que la connexion est accept&eacute; sur le serveur, l&rsquo;&eacute;tat de l&rsquo;application client est affich&eacute; comme <em>&ldquo;Connect&eacute;&rdquo;</em> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4188.clip_image032_thumb2_5DC49827.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4188.clip_5F00_image032_5F00_thumb2_5F00_5DC49827.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image032_thumb[2]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6170.clip_image032_thumb2_thumb_5875B176.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6170.clip_5F00_image032_5F00_thumb2_5F00_thumb_5F00_5875B176.png" alt="clip_image032_thumb[2]" width="214" height="355" border="0" /></a></p>
<p>7. L&rsquo;&eacute;tat de l&rsquo;application serveur&nbsp; est aussi affich&eacute; comme <em>&ldquo;Connect&eacute;&rdquo;</em> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7612.clip_image034_thumb1_2A8AEF6F.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7612.clip_5F00_image034_5F00_thumb1_5F00_2A8AEF6F.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image034_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2746.clip_image034_thumb1_thumb_7A63A4AB.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2746.clip_5F00_image034_5F00_thumb1_5F00_thumb_5F00_7A63A4AB.jpg" alt="clip_image034_thumb[1]" width="373" height="193" border="0" /></a></p>
<p>8. Les applications sont maintenant connect&eacute;es, vous pouvez &eacute;changer des informations comme des messages et des photos entre les applications.</p>
<p><strong><span style="font-size: large;">Transmettre et recevoir des messages</span></strong></p>
<p>1. Sur le Windows Phone, naviguez vers le pivot &ldquo;Messages&rdquo;, entrez une cha&icirc;ne de caract&egrave;res dans le champ d&rsquo;&eacute;dition &ldquo;Message&rdquo; et cliquez sur le bouton &ldquo;<em>Send&rdquo;</em>. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8168.clip_image036_thumb1_2A214D2B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8168.clip_5F00_image036_5F00_thumb1_5F00_2A214D2B.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image036_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1830.clip_image036_thumb1_thumb_4076F270.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1830.clip_5F00_image036_5F00_thumb1_5F00_thumb_5F00_4076F270.png" alt="clip_image036_thumb[1]" width="223" height="369" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6545.clip_image038_thumb1_50198E32.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6545.clip_5F00_image038_5F00_thumb1_5F00_50198E32.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image038_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1207.clip_image038_thumb1_thumb_31CED73C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1207.clip_5F00_image038_5F00_thumb1_5F00_thumb_5F00_31CED73C.png" alt="clip_image038_thumb[1]" width="223" height="369" border="0" /></a></p>
<p>2. Le m&ecirc;me message est affich&eacute; quelques secondes plus tard dans la section &ldquo;Messages&rdquo; de l&rsquo;application Windows 8.1. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4762.clip_image040_thumb1_13842046.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4762.clip_5F00_image040_5F00_thumb1_5F00_13842046.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image040_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1050.clip_image040_thumb1_thumb_635CD582.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1050.clip_5F00_image040_5F00_thumb1_5F00_thumb_5F00_635CD582.jpg" alt="clip_image040_thumb[1]" width="418" height="213" border="0" /></a></p>
<p>3. Vous pouvez aussi transmettre un message&nbsp; de l&rsquo;application Windows vers l&rsquo;application Windows Phone. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5314.clip_image042_thumb1_1A39BA7A.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5314.clip_5F00_image042_5F00_thumb1_5F00_1A39BA7A.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image042_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4263.clip_image042_thumb1_thumb_0E37CA46.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4263.clip_5F00_image042_5F00_thumb1_5F00_thumb_5F00_0E37CA46.jpg" alt="clip_image042_thumb[1]" width="419" height="212" border="0" /></a></p>
<p>4. Et recevoir le m&ecirc;me message sur votre Windows Phone. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3531.clip_image044_thumb1_4514AF3D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3531.clip_5F00_image044_5F00_thumb1_5F00_4514AF3D.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image044_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6281.clip_image044_thumb1_thumb_746624C7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6281.clip_5F00_image044_5F00_thumb1_5F00_thumb_5F00_746624C7.png" alt="clip_image044_thumb[1]" width="218" height="361" border="0" /></a></p>
<p><strong><span style="font-size: large;"><strong><span style="font-size: large;">Transmettre et recevoir&nbsp; des photos</span></strong></span></strong></p>
<p>1. Sur votre Windows Phone, naviguez vers le pivot &ldquo;<em>Files&rdquo;</em> , et cliquez sur le bouton &ldquo;<em>Select Picture&rdquo;</em>. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0755.clip_image046_thumb1_0408C08A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0755.clip_5F00_image046_5F00_thumb1_5F00_0408C08A.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image046_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7723.clip_image046_thumb1_thumb_3AE5A581.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7723.clip_5F00_image046_5F00_thumb1_5F00_thumb_5F00_3AE5A581.png" alt="clip_image046_thumb[1]" width="226" height="374" border="0" /></a></p>
<p>2. Naviguez parmi les diff&eacute;rents albums et s&eacute;lectionnez la photo que vous souhaitez transmettre &agrave; l&rsquo;application Windows. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1803.clip_image048_thumb1_2EE3B54D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1803.clip_5F00_image048_5F00_thumb1_5F00_2EE3B54D.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image048_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0763.clip_image048_thumb1_thumb_2C3D8A4D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0763.clip_5F00_image048_5F00_thumb1_5F00_thumb_5F00_2C3D8A4D.png" alt="clip_image048_thumb[1]" width="204" height="338" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3757.clip_image050_thumb1_7DE69550.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3757.clip_5F00_image050_5F00_thumb1_5F00_7DE69550.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image050_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6837.clip_image050_thumb1_thumb_62449A0B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6837.clip_5F00_image050_5F00_thumb1_5F00_thumb_5F00_62449A0B.png" alt="clip_image050_thumb[1]" width="204" height="337" border="0" /></a></p>
<p>3. D&egrave;s que la photo est s&eacute;lectionn&eacute;e, le chemin du fichier et la taille du fichier sont affich&eacute;s sur l&rsquo;&eacute;cran du Windows Phone. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0412.clip_image052_thumb2_03C3C99B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0412.clip_5F00_image052_5F00_thumb2_5F00_03C3C99B.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image052_thumb[2]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5722.clip_image052_thumb2_thumb_539C7ED7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5722.clip_5F00_image052_5F00_thumb2_5F00_thumb_5F00_539C7ED7.png" alt="clip_image052_thumb[2]" width="207" height="341" border="0" /></a></p>
<p>4. Cliquez sur le bouton <em>&ldquo;Send Picture&rdquo;</em>&nbsp; pour transmettre la photo. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3108.clip_image054_thumb1_7587E15B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3108.clip_5F00_image054_5F00_thumb1_5F00_7587E15B.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image054_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5280.clip_image054_thumb1_thumb_573D2A65.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5280.clip_5F00_image054_5F00_thumb1_5F00_thumb_5F00_573D2A65.png" alt="clip_image054_thumb[1]" width="215" height="356" border="0" /></a></p>
<p>5. La photo s&rsquo;affiche sur l&rsquo;&eacute;cran de l&rsquo;ordinateur dans le section &ldquo;Files&rdquo; de l&rsquo;application. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5040.clip_image056_thumb1_66DFC627.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5040.clip_5F00_image056_5F00_thumb1_5F00_66DFC627.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image056_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2018.clip_image056_thumb1_thumb_1DBCAB1F.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2018.clip_5F00_image056_5F00_thumb1_5F00_thumb_5F00_1DBCAB1F.jpg" alt="clip_image056_thumb[1]" width="423" height="200" border="0" /></a></p>
<p>6. Si vous double-cliquez sur la photo, celle-ci s&rsquo;affiche en plein &eacute;cran. Enfin, vous pouvez sauvegarder la photo sur le disque dur de votre ordinateur en cliquant sur le bouton &ldquo;Save image&rdquo;.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1778.clip_image058_thumb1_3FA80DA3.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1778.clip_5F00_image058_5F00_thumb1_5F00_3FA80DA3.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image058_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2364.clip_image058_thumb1_thumb_21C989A2.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2364.clip_5F00_image058_5F00_thumb1_5F00_thumb_5F00_21C989A2.jpg" alt="clip_image058_thumb[1]" width="191" height="108" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4035.clip_image060_thumb1_6EF9832D.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4035.clip_5F00_image060_5F00_thumb1_5F00_6EF9832D.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image060_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3312.clip_image060_thumb1_thumb_65A04EAA.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3312.clip_5F00_image060_5F00_thumb1_5F00_thumb_5F00_65A04EAA.jpg" alt="clip_image060_thumb[1]" width="389" height="227" border="0" /></a></p>
<p><strong><span style="font-size: large;">Utiliser le protocole&nbsp; Bluetooth Rfcomm pour la communication entre applications Windows et applications Windows Phone</span></strong></p>
<p>Une fois que la connexion est &eacute;tablie entre l'application Windows Phone et l'application Windows &agrave; l'aide de l&rsquo;API Windows.Networking.Sockets.StreamSocket, les deux applications peuvent &eacute;changer des commandes en utilisant les services du&nbsp; protocole Bluetooth Rfcomm.</p>
<p>Avec les applications disponibles avec cet article, une commande Bluetooth&nbsp; peut transporter&nbsp; un message texte, une photo.</p>
<p>Par exemple: <br /><strong>Commande Message :</strong> <br /><em>command=message|content=&lt;Message Content&gt; <br /></em><strong>Commande Picture File :</strong> <br /><em>command=picture|path=&lt;Picture Path&gt;|size=&lt;Picture Size&gt;|content=&lt;Picture Content&gt; <br /></em> <br />Ce mod&egrave;le d&rsquo;&eacute;changes peut &ecirc;tre &eacute;tendu pour supporter de nouveaux sc&eacute;narios de type compagnon o&ugrave; une commande pourrait transporter un fichier audio, un fichier vid&eacute;o, un &eacute;v&egrave;nement de type appuie d&rsquo;une touche clavier , &hellip; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7558.clip_image062_thumb1_0A346CE0.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7558.clip_5F00_image062_5F00_thumb1_5F00_0A346CE0.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image062_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1638.clip_image062_thumb1_thumb_44AF6CB4.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1638.clip_5F00_image062_5F00_thumb1_5F00_thumb_5F00_44AF6CB4.jpg" alt="clip_image062_thumb[1]" width="803" height="334" border="0" /></a></p>
<p><strong><span style="font-size: large;">G&eacute;n&eacute;rer les applications avec Visual Studio 2013</span></strong></p>
<p>Pour g&eacute;n&eacute;rer l&rsquo;application serveur Bluetooth pour Windows Store et l&rsquo;application client Bluetooth pour Windows Phone, assurez-vous d&rsquo;avoir:&nbsp; <br />1. un ordinateur supportant Windows 8.1 <br />2. un smart phone supportant Windows Phone 8&nbsp; <br />3. Visual Studio 2013, <br />4. Windows Phone 8 SDK.</p>
<p><strong><span style="font-size: large;">Explorer le projet de l&rsquo;application&nbsp; Windows Store </span></strong></p>
<p>Le projet de l&rsquo;application Windows Store est un projet XAML/C#.&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3730.clip_image064_thumb1_56FAC427.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3730.clip_5F00_image064_5F00_thumb1_5F00_56FAC427.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image064_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0028.clip_image064_thumb1_thumb_38B00D31.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0028.clip_5F00_image064_5F00_thumb1_5F00_thumb_5F00_38B00D31.jpg" alt="clip_image064_thumb[1]" width="390" height="359" border="0" /></a></p>
<ul>
<li><strong><em>MainPage.xaml.cs</em></strong> contient le code source de la page principale.</li>
<li><strong><em>App.xaml.cs</em></strong> contient le code source de la classe App.</li>
<li><strong><em>WindowsBluetoothRfcommServer.cs</em></strong> contient l&rsquo;impl&eacute;mentation de la classe WindowsBluetoothRfcommServer.</li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contient le code source utilis&eacute; pour sauvegarder et restaurer les param&egrave;tres de l&rsquo;application.</li>
</ul>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>Code source partag&eacute; entre l&rsquo;application Windows et l&rsquo;application Windows Phone</strong></p>
<ul>
<li><strong><em>BluetoothService.cs</em></strong> contient le Service ID utiliser pour la communication Bluetooth et identification des applications.</li>
<li><strong><em>BluetoothServer.cs</em></strong> contient la d&eacute;finition de l&rsquo;interface du serveur Bluetooth.</li>
<li><strong><em>BluetoothDevice.cs</em></strong> contient la d&eacute;finition de la classe BluetoothDevice.</li>
<li><strong><em>BluetoothCommand.cs</em></strong> contient la d&eacute;finition des classes BluetoothCommand, BluetoothCommandMessage, et BluetoothCommandPicture. <br /> <br /><strong>Les &eacute;tats du serveur Bluetooth:</strong> <br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7823.image_thumb3_5624EEEE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7823.image_5F00_thumb3_5F00_5624EEEE.png"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="image_thumb[3]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8345.image_thumb3_thumb_25917136.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8345.image_5F00_thumb3_5F00_thumb_5F00_25917136.png" alt="image_thumb[3]" width="497" height="456" border="0" /></a></li>
</ul>
<p><strong>WindowsBluetoothRfcommServer m&eacute;thode Initialization:</strong> <br />Cette m&eacute;thode cr&eacute;e RfcommServiceProvider et v&eacute;rifie si le Bluetooth est activ&eacute; sur l&rsquo;ordinateur</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothServerReturnCode&gt; Initialization()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        rfcommProvider = await RfcommServiceProvider.CreateAsync(<br />            RfcommServiceId.FromUuid(_BluetoothServiceUuid));<br />        <span style="color: #0000ff;">if</span> (rfcommProvider != <span style="color: #0000ff;">null</span>)<br />        {<br />            SetState(BluetoothServerState.Stopped);<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />        }<br />        <span style="color: #0000ff;">else</span><br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitError;<br /><br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_BLUETOOTH_OFF)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitBluetoothOff;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_MISSING_CAPS)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitMissingCaps;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_NOT_ADVERTISING)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitNotAdvertising;<br /><br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Initialization - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitException;<br />    }<br />}</pre>
</div>
<p><strong>WindowsBluetoothRfcommServer m&eacute;thode Start:</strong> <br />Cette m&eacute;thode cr&eacute;e un StreamSocketListener et attend les connexions pour le BluetoothServiceUuid. Elle lance &eacute;galement le Bluetooth Advertising pour le service Rfcomm.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothServerReturnCode&gt; Start()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Starting the server..."</span>);<br />        <span style="color: #0000ff;">if</span> (rfcommProvider == <span style="color: #0000ff;">null</span>)<br />            rfcommProvider = await RfcommServiceProvider.CreateAsync(<br />                RfcommServiceId.FromUuid(_BluetoothServiceUuid));<br /><br />        <span style="color: #0000ff;">if</span> (rfcommProvider != <span style="color: #0000ff;">null</span>)<br />        {<br />            <span style="color: #0000ff;">if</span> (socketListener != <span style="color: #0000ff;">null</span>)<br />            {<br />                socketListener.Dispose();<br />                socketListener = <span style="color: #0000ff;">null</span>;<br />            }<br /><br /><br />            <span style="color: #008000;">// Create a listener for this service and start listening</span><br />            socketListener = <span style="color: #0000ff;">new</span> StreamSocketListener();<br />            socketListener.ConnectionReceived += OnConnectionReceived;<br /><br />            await socketListener.BindServiceNameAsync(rfcommProvider.ServiceId.AsString(),<br />                SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);<br /><br />            <span style="color: #008000;">// Set the SDP attributes and start Bluetooth advertising</span><br />            DataWriter sdpWriter = <span style="color: #0000ff;">new</span> DataWriter();<br /><br />            <span style="color: #008000;">// Write the Service Name Attribute.</span><br />            sdpWriter.WriteByte(SdpServiceNameAttributeType);<br /><br />            <span style="color: #008000;">// The length of the UTF-8 encoded Service Name SDP Attribute.</span><br />            sdpWriter.WriteByte((<span style="color: #0000ff;">byte</span>)BluetoothServiceDisplayName.Length);<br /><br />            <span style="color: #008000;">// The UTF-8 encoded Service Name value.</span><br />            sdpWriter.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;<br />            sdpWriter.WriteString(BluetoothServiceDisplayName);<br /><br />            <span style="color: #008000;">// Set the SDP Attribute on the RFCOMM Service Provider.</span><br />            <span style="color: #0000ff;">if</span>(rfcommProvider.SdpRawAttributes.ContainsKey(SdpServiceNameAttributeId))<br />                rfcommProvider.SdpRawAttributes.Remove(SdpServiceNameAttributeId);<br />            rfcommProvider.SdpRawAttributes.Add(SdpServiceNameAttributeId, sdpWriter.DetachBuffer());<br />            <span style="color: #008000;">// Start Bluetooth advertising</span><br />            SetState(BluetoothServerState.Started); <br />            rfcommProvider.StartAdvertising(socketListener);<br />            NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Server Started"</span>);<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span>(Exception e)<br />    {<br />        <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_BLUETOOTH_OFF)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartBluetoothOff;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_MISSING_CAPS)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartMissingCaps;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_NOT_ADVERTISING)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartNotAdvertising;<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Start - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartException;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartError;<br />}</pre>
</div>
<p><strong>WindowsBluetoothRfcommServer m&eacute;thode OnConnectionReceived:</strong> <br />Cette m&eacute;thode est appel&eacute;e quand le serveur re&ccedil;oit une demande de connexion. Elle sauvegarde les information sur le client Bluetooth. Enfin elle appelle la m&eacute;thode ReceiveIncommingCommands pour recevoir les commandes Bluetooth.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> OnConnectionReceived(StreamSocketListener sender, <br />    StreamSocketListenerConnectionReceivedEventArgs args)<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        <span style="color: #008000;">// Don't need the listener anymore</span><br />        socketListener.Dispose();<br />        socketListener = <span style="color: #0000ff;">null</span>;<br /><br />        socket = args.Socket;<br />        <span style="color: #0000ff;">if</span>((socket!=<span style="color: #0000ff;">null</span>) &amp;&amp; (socket.Information!=<span style="color: #0000ff;">null</span>))<br />        {<br />            _connectedDeviceDisplayName = <span style="color: #006080;">"Remote Address: "</span> + socket.Information.RemoteAddress.DisplayName + <span style="color: #006080;">" Remote Port: "</span> + socket.Information.RemotePort + <span style="color: #006080;">" Remote Service: "</span> + socket.Information.RemoteServiceName;<br />            _connectedDeviceHostName = socket.Information.RemoteHostName.DisplayName;<br />            _connectedDeviceServiceName = socket.Information.RemoteServiceName;<br />        }<br /><br />        SetState(BluetoothServerState.Connected);<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client connected"</span> );<br /><br />        <span style="color: #0000ff;">if</span> (ConnectionReceived != <span style="color: #0000ff;">null</span>)<br />        {<br />            BluetoothDevice device = <span style="color: #0000ff;">new</span> BluetoothDevice(_connectedDeviceHostName,_connectedDeviceServiceName,_connectedDeviceDisplayName);<br />            ConnectionReceived(<span style="color: #0000ff;">this</span>, device);<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in OnConnectionReceived - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span>;<br />    }<br />    ReceiveIncomingCommands();<br />}</pre>
</div>
<p><strong> <br />WindowsBluetoothRfcommServer m&eacute;thode Disconnect:</strong> <br />Cette m&eacute;thode appelle ForceDisconnect pour d&eacute;connecter la connexion en cours, elle cr&eacute;e un nouveau StreamSocketListener et attend les demandes de connexion.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothServerReturnCode&gt; Disconnect()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        ForceDisconnect();<br />        <span style="color: #008000;">// Create a listener for this service and start listening</span><br />        <span style="color: #0000ff;">if</span>(socketListener==<span style="color: #0000ff;">null</span>)<br />        {<br />            socketListener = <span style="color: #0000ff;">new</span> StreamSocketListener();<br />            socketListener.ConnectionReceived += OnConnectionReceived;<br /><br />            await socketListener.BindServiceNameAsync(rfcommProvider.ServiceId.AsString(),<br />                SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);<br />        }<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client Disconnected"</span>);<br />      <br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Disconnect - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.DisconnectException;<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        reader = <span style="color: #0000ff;">null</span>;<br />        writer = <span style="color: #0000ff;">null</span>;<br />        socket = <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />}</pre>
</div>
<p><br /><strong>WindowsBluetoothRfcommServer m&eacute;thode Stop:</strong> <br />Si le serveur &eacute;tait connect&eacute;, cette m&eacute;thode appelle la m&eacute;thode ForceDisconnect pour d&eacute;connecter la connexion en cours. Elle stoppe &eacute;galement l&rsquo;advertising Bluetooth en cours et lib&egrave;re les sockets.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span>  BluetoothServerReturnCode Stop()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Stopping the server..."</span> );<br />        <span style="color: #0000ff;">if</span> (GetState() == BluetoothServerState.Connected)<br />        {<br />            ForceDisconnect();<br />        }<br />        SetState(BluetoothServerState.Stopped);<br />        <span style="color: #0000ff;">if</span> (rfcommProvider != <span style="color: #0000ff;">null</span>)<br />        {<br />            rfcommProvider.StopAdvertising();<br />            rfcommProvider = <span style="color: #0000ff;">null</span>;<br />        }<br /><br />        <span style="color: #0000ff;">if</span> (socketListener != <span style="color: #0000ff;">null</span>)<br />        {<br />            socketListener.Dispose();<br />            socketListener = <span style="color: #0000ff;">null</span>;<br />        }<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Server stopped"</span>);<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Stop - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StopException;<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        rfcommProvider = <span style="color: #0000ff;">null</span>;<br />        socketListener = <span style="color: #0000ff;">null</span>;<br />        writer = <span style="color: #0000ff;">null</span>;<br />        socket = <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />}</pre>
</div>
<p>&nbsp;</p>
<p>L&rsquo;application Windows et l&rsquo;application Windows Phone utilisent le m&ecirc;me Service Uuid pour permettre une communication entre les deux applications. Pour l&rsquo;application Windows Store le Service Uuid est d&eacute;fini dans le manifeste de l&rsquo;application et dans le code source. <br />La section suivante est ajout&eacute;e dans le manifeste de l&rsquo;application:</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">&lt;</span><span style="color: #800000;">Capabilities</span><span style="color: #0000ff;">&gt;</span><br />  <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">Capability</span> <span style="color: #ff0000;">Name</span><span style="color: #0000ff;">="internetClient"</span> <span style="color: #0000ff;">/&gt;</span><br />  <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">Capability</span> <span style="color: #ff0000;">Name</span><span style="color: #0000ff;">="picturesLibrary"</span> <span style="color: #0000ff;">/&gt;</span><br />  <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">m2:DeviceCapability</span> <span style="color: #ff0000;">Name</span><span style="color: #0000ff;">="bluetooth.rfcomm"</span><span style="color: #0000ff;">&gt;</span><br />    <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">m2:Device</span> <span style="color: #ff0000;">Id</span><span style="color: #0000ff;">="any"</span><span style="color: #0000ff;">&gt;</span><br />      <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">m2:Function</span> <span style="color: #ff0000;">Type</span><span style="color: #0000ff;">="serviceId:17890000-0068-0069-1532-1992D79BE4D8"</span> <span style="color: #0000ff;">/&gt;</span><br />    <span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">m2:Device</span><span style="color: #0000ff;">&gt;</span><br />  <span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">m2:DeviceCapability</span><span style="color: #0000ff;">&gt;</span><br /><span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">Capabilities</span><span style="color: #0000ff;">&gt;</span></pre>
</div>
<p>Le fichier BluetoothService.cs contient &eacute;galement la d&eacute;claration du ServiceID :</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> BluetoothRfcommGlobal<br />{<br />   <span style="color: #008000;">// Service uuid: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Guid BluetoothServiceUuid = <span style="color: #0000ff;">new</span> Guid(<span style="color: #006080;">"17890000-0068-0069-1532-1992D79BE4D8"</span>);<br />   <span style="color: #008000;">// Service display name: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> BluetoothServiceDisplayName = <span style="color: #006080;">"My Bluetooth Rfcomm Service"</span>;<br />}</pre>
</div>
<p><br />La classe WindowsBluetoothRfcommServer est instanci&eacute;e dans le constructeur de la classe App.&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> App()<br />{<br />    <span style="color: #0000ff;">this</span>.InitializeComponent();<br /><br />    <span style="color: #0000ff;">this</span>.Suspending += OnSuspending;<br />    <span style="color: #0000ff;">this</span>.Resuming += OnResuming;<br />    BluetoothRfcommServer = <span style="color: #0000ff;">new</span> WindowsBluetoothRfcommServer(BluetoothServiceUuid, BluetoothServiceDisplayName, ApplicationConfiguration.AutoStart);<br />}</pre>
</div>
<p>La classe WindowsBluetoothRfcommServer est Initialis&eacute;e et d&eacute;marr&eacute;e (M&eacute;thode Start)&nbsp; dans la m&eacute;thode OnNavigatedTo de la MainPage.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">// Initialize Blutooth Server to check whether the bluetooth is on</span><br /><span style="color: #0000ff;">if</span> (((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer != <span style="color: #0000ff;">null</span>) &amp;&amp; ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.GetState() == BluetoothServerState.Created))<br />{<br />    BluetoothServerReturnCode r = await(App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.Initialization();<br />    <span style="color: #0000ff;">if</span> ((r == BluetoothServerReturnCode.Success) &amp;&amp; ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.AutoStart == <span style="color: #0000ff;">true</span>))<br />    {<br />        r = await(App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.Start();<br />    }<br />    <span style="color: #0000ff;">if</span> (r != BluetoothServerReturnCode.Success)<br />    {<br />        <span style="color: #0000ff;">if</span> ((r == BluetoothServerReturnCode.InitMissingCaps) || (r == BluetoothServerReturnCode.StartMissingCaps))<br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"bluetooth.rfcomm Capability missing in the application manifest"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((r == BluetoothServerReturnCode.InitBluetoothOff) || (r == BluetoothServerReturnCode.StartBluetoothOff))<br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"Bluetooth is off, bluetooth is required to launch the server"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (r == BluetoothServerReturnCode.StartNotAdvertising)<br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"Bluetooth Advertising Error, restart the application"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"Error occurs while initializing the server"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />    }<br />}</pre>
</div>
<p>D&egrave;s que la classe WindowsBluetoothRfcommServer est dans l&rsquo;&eacute;tat &ldquo;started&rdquo;, elle peut recevoir les demandes de connexion en provenance des applications Bluetooth. Quand l&rsquo;application est connect&eacute;e avec un client Bluetooth, la classe WindowsBluetoothRfcommServer appelle la m&eacute;thode WindowsBluetoothRfcomm_ConnectionReceived.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">void</span> BluetoothRfcommServer_ConnectionReceived(IBluetoothServer sender, BluetoothDevice args)<br />{<br />    ClearMessage();<br />    AddLog(<span style="color: #006080;">"Connected with "</span> + (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.ConnectedDeviceDisplayName);<br />}</pre>
</div>
<p><br />Quand la classe WindowsBluetoothRfcommServer est dans l&rsquo;&eacute;tat &ldquo;connected&rdquo;, elle peut recevoir et transmettre des commandes Bluetouth. Quand elle re&ccedil;oit une commande la classe WindowsBluetoothRfcommServer appelle la m&eacute;thode BluetoothRfcommServer_CommandReceived.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">void</span> BluetoothRfcommServer_CommandReceived(IBluetoothServer sender, BluetoothCommand args)<br /> {<br />     AddLog(<span style="color: #006080;">"Command received "</span> + args.ToString());<br />     <br />     <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandMessage))<br />     {<br />         BluetoothCommandMessage bm = args <span style="color: #0000ff;">as</span> BluetoothCommandMessage;<br />         <span style="color: #0000ff;">if</span>(bm!=<span style="color: #0000ff;">null</span>)<br />             AddMessage(<span style="color: #006080;">"Message Received: "</span> + bm.MessageContent);<br />     }<br />     <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandPicture))<br />     {<br />         RunOnDispatcherThread(() =&gt;<br />         {<br />             BluetoothCommandPicture bp = args <span style="color: #0000ff;">as</span> BluetoothCommandPicture;<br />             <span style="color: #0000ff;">if</span> (bp != <span style="color: #0000ff;">null</span>)<br />             {<br />                 DisplayImage(bp.PictureContent);<br />                 <span style="color: #0000ff;">if</span> (bp.PictureContent.Length &gt; 0)<br />                 {<br />                     _ImageBuffer = <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">byte</span>[bp.PictureSize];<br />                     <span style="color: #0000ff;">if</span> (_ImageBuffer != <span style="color: #0000ff;">null</span>)<br />                         Array.Copy(bp.PictureContent, _ImageBuffer, bp.PictureContent.Length);<br />                 }<br />             }<br />         }); <br /><br />     }<br /> }</pre>
</div>
<p><span style="font-size: large;"><span style="font-size: large;"><strong>Explorer le projet de l&rsquo;application</strong>&nbsp; </span><strong>Windows Phone 8 </strong></span></p>
<p>Le projet de l&rsquo;application Windows Phone est un projet XAML/C#.&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6622.clip_image066_thumb1_74FDF37D.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6622.clip_5F00_image066_5F00_thumb1_5F00_74FDF37D.jpg"><img style="margin: 0px; border: 0px currentcolor; display: inline; background-image: none;" title="clip_image066_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5008.clip_image066_thumb1_thumb_199211B3.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5008.clip_5F00_image066_5F00_thumb1_5F00_thumb_5F00_199211B3.jpg" alt="clip_image066_thumb[1]" width="331" height="308" border="0" /></a></p>
<ul>
<li><strong><em>MainPage.xaml.cs</em></strong> contient le code source de la page principale.</li>
<li><strong><em>App.xaml.cs</em></strong> contient l&rsquo;impl&eacute;mentation de la classe App.</li>
<li><strong><em>WindowsBluetoothRfcommClient.cs</em></strong> contient l&rsquo;impl&eacute;mentation de la classe WindowsBluetoothRfcommClient.</li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contient le code source utilis&eacute; pour sauvegarder et restaurer les param&egrave;tres de l&rsquo;application.</li>
</ul>
<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Code source partag&eacute; entre l&rsquo;application Windows et l&rsquo;application Windows Phone</strong></p>
<ul>
<li><strong><em>BluetoothService.cs</em></strong> contient le Service ID utilis&eacute; pour la communication Bluetooth.</li>
<li><strong><em>BluetoothClient.cs</em></strong> contient la d&eacute;finition de l&rsquo;interface BluetoothClient.</li>
<li><strong><em>BluetoothDevice.cs</em></strong> contient la d&eacute;finition de la classe BluetoothDevice.</li>
<li><strong><em>BluetoothCommand.cs</em></strong> contient la d&eacute;finition des classes BluetoothCommand, BluetoothCommandMessage, BluetoothCommandPicture.</li>
</ul>
<p><br /><strong>Les &eacute;tats de la classe BluetoothRfcommClient:</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2783.image_thumb1_7B475ABC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2783.image_5F00_thumb1_5F00_7B475ABC.png"><img style="border: 0px currentcolor; display: inline; background-image: none;" title="image_thumb[1]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4863.image_thumb1_thumb_5FA55F77.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4863.image_5F00_thumb1_5F00_thumb_5F00_5FA55F77.png" alt="image_thumb[1]" width="434" height="489" border="0" /></a></p>
<p><strong>WindowsPhoneBluetoothRfcommClient m&eacute;thode Initialization:</strong> <br />Cette m&eacute;thode v&eacute;rifie que l&rsquo;application ne s&rsquo;ex&eacute;cute pas dans l&rsquo;&eacute;mulateur et le Bluetooth est activ&eacute; sur le Windows Phone.&nbsp; </p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothClientReturnCode&gt; Initialization()<br />{<br />    <span style="color: #0000ff;">if</span> (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator)<br />    {<br />        <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitEmulator;<br />    }<br /><br />    <span style="color: #0000ff;">try</span><br />    {<br />        PeerFinder.AlternateIdentities[<span style="color: #006080;">"Bluetooth:Paired"</span>] = <span style="color: #006080;">""</span>;<br />        var Peers = await PeerFinder.FindAllPeersAsync();<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception ex)<br />    {<br />        <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)ex.HResult == ERR_BLUETOOTH_OFF)<br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitBluetoothOff;<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)ex.HResult == ERR_MISSING_CAPS)<br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitMissingCaps;<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)ex.HResult == ERR_NOT_ADVERTISING)<br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitNotAdvertising;<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitError;<br />        }<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        PeerFinder.Stop();<br />    }<br />    SetState(BluetoothClientState.Initialized);<br />    <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.Success;<br /><br />}</pre>
</div>
<p><strong><strong> <br />WindowsPhoneBluetoothRfcommClient m&eacute;thode Connect </strong>:</strong> <br />Cette m&eacute;thode cr&eacute;e une StreamSocket utilis&eacute;e pour &eacute;tablir une connexion avec le serveur Bluetooth. Si la connexion est r&eacute;ussie, les informations sur le serveur Bluetooth sont sauvegard&eacute;es. Elle appelle ensuite la m&eacute;thode ReceiveIncommingCommands pour recevoir les commandes Bluetooth.<strong><strong><strong> <br /></strong></strong></strong></p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothClientReturnCode&gt; Connect(BluetoothDevice device)<br />{<br />    NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Connecting Client..."</span>);<br />    <span style="color: #0000ff;">if</span> (socket == <span style="color: #0000ff;">null</span>)<br />        socket = <span style="color: #0000ff;">new</span> StreamSocket();<br />    <span style="color: #0000ff;">try</span><br />    {<br />        await socket.ConnectAsync(<span style="color: #0000ff;">new</span> Windows.Networking.HostName(device.HostName), BluetoothServiceName);<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception ex)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Connect - "</span> + ex.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.ConnectError;<br />    }<br />    SetState(BluetoothClientState.Connected);<br /><br />    <span style="color: #008000;">// Connected no need for advertising anymore</span><br />    PeerFinder.Stop();<br />    _connectedDeviceDisplayName = device.DisplayName;<br />    _connectedDeviceHostName = device.HostName;<br />    _connectedDeviceServiceName = BluetoothServiceName;<br />    NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client connected"</span>);<br /><br />    <span style="color: #008000;">// Reception loop</span><br />    ReceiveIncomingCommands();<br /><br />    <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.Success;<br />}</pre>
</div>
<p><strong><strong><br />WindowsPhoneBluetoothRfcommClient m&eacute;thode </strong>Disconnect :</strong> <br />Cette m&eacute;thode lib&egrave;re l&rsquo;ensemble des ressources utilis&eacute;es pour la communication Bluetooth (StreamSocket) .</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> BluetoothClientReturnCode Disconnect()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Disconnecting Client..."</span>);<br />        SetState(BluetoothClientState.Initialized);<br /><br />        _connectedDeviceDisplayName = <span style="color: #006080;">""</span>;<br />        _connectedDeviceHostName = <span style="color: #006080;">""</span>;<br />        _connectedDeviceServiceName = <span style="color: #006080;">""</span>;<br /><br />        <span style="color: #0000ff;">if</span> (socket != <span style="color: #0000ff;">null</span>)<br />        {<br />            socket.Dispose();<br />            socket = <span style="color: #0000ff;">null</span>;<br />        }<br /><br />        <span style="color: #0000ff;">if</span> (writer != <span style="color: #0000ff;">null</span>)<br />        {<br />            writer.DetachStream(); <br />            writer.Dispose();<br />            writer = <span style="color: #0000ff;">null</span>;<br />        }<br />        <span style="color: #0000ff;">if</span> (reader != <span style="color: #0000ff;">null</span>)<br />        {<br />            <br />            reader.Dispose();<br />            reader = <span style="color: #0000ff;">null</span>;<br />        }<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client Disconnected"</span>);<br /><br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Disconnect - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.DisconnectException;<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        reader = <span style="color: #0000ff;">null</span>;<br />        writer = <span style="color: #0000ff;">null</span>;<br />        socket = <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.Success;<br />}</pre>
</div>
<p><br />L&rsquo;application Windows et l&rsquo;application Windows Phone utilisent le m&ecirc;me Service Uuid pour permettre une communication entre les deux applications. Pour l&rsquo;application Windows Phone le Service Uuid est d&eacute;fini dans le code source dans le fichier BluetoothService.cs.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> BluetoothRfcommGlobal<br />{<br />   <span style="color: #008000;">// Service uuid: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Guid BluetoothServiceUuid = <span style="color: #0000ff;">new</span> Guid(<span style="color: #006080;">"17890000-0068-0069-1532-1992D79BE4D8"</span>);<br />   <span style="color: #008000;">// Service display name: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> BluetoothServiceDisplayName = <span style="color: #006080;">"My Bluetooth Rfcomm Service"</span>;<br />}</pre>
</div>
<p>La classe WindowsBluetoothRfcommClient est instanci&eacute;e dans le constructeur de la classe App.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> App()<br />{<br />    <span style="color: #008000;">// Global handler for uncaught exceptions.</span><br />    UnhandledException += Application_UnhandledException;<br /><br />    <span style="color: #008000;">// Standard XAML initialization</span><br />    InitializeComponent();<br /><br />    <span style="color: #008000;">// Phone-specific initialization</span><br />    InitializePhoneApplication();<br /><br />    <span style="color: #008000;">// Language display initialization</span><br />    InitializeLanguage();<br /><br />    <span style="color: #008000;">// Show graphics profiling information while debugging.</span><br />    <span style="color: #0000ff;">if</span> (Debugger.IsAttached)<br />    {<br />        <span style="color: #008000;">// Display the current frame rate counters</span><br />        Application.Current.Host.Settings.EnableFrameRateCounter = <span style="color: #0000ff;">true</span>;<br /><br />        <span style="color: #008000;">// Show the areas of the app that are being redrawn in each frame.</span><br />        <span style="color: #008000;">//Application.Current.Host.Settings.EnableRedrawRegions = true;</span><br /><br />        <span style="color: #008000;">// Enable non-production analysis visualization mode,</span><br />        <span style="color: #008000;">// which shows areas of a page that are handed off to GPU with a colored overlay.</span><br />        <span style="color: #008000;">//Application.Current.Host.Settings.EnableCacheVisualization = true;</span><br /><br />        <span style="color: #008000;">// Prevent the screen from turning off while under the debugger by disabling</span><br />        <span style="color: #008000;">// the application's idle detection.</span><br />        <span style="color: #008000;">// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run</span><br />        <span style="color: #008000;">// and consume battery power when the user is not using the phone.</span><br />        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;<br />    }<br />    <span style="color: #008000;">// Call BluetoothRfcommClient constructor</span><br />    BluetoothRfcommClient = <span style="color: #0000ff;">new</span> WindowsPhoneBluetoothRfcommClient(BluetoothServiceUuid, BluetoothServiceDisplayName, ApplicationConfiguration.AutoStart);<br />}</pre>
</div>
<p>&nbsp;&nbsp; <br />La classe WindowsBluetoothRfcommClient est initialis&eacute;e dans la m&eacute;thode OnNavigatedTo de la classe MainPage.&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> async <span style="color: #0000ff;">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    <span style="color: #008000;">// Check if BluetoothRfcommClient instance</span><br />    <span style="color: #0000ff;">if</span> ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient == <span style="color: #0000ff;">null</span>)<br />        <span style="color: #0000ff;">return</span>;<br />    <span style="color: #008000;">// Check BluetoothRfcommClient State</span><br />    <span style="color: #008000;">// If State == BluetoothClientState.Created, the bluetooth client didn't start</span><br />    <span style="color: #0000ff;">if</span> ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.GetState() == BluetoothClientState.Created)<br />    {<br />        BluetoothClientReturnCode r = await(App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.Initialization();<br />        <span style="color: #0000ff;">if</span> (r != BluetoothClientReturnCode.Success)<br />        {<br />            <span style="color: #0000ff;">if</span> ((r == BluetoothClientReturnCode.InitMissingCaps) || (r == BluetoothClientReturnCode.StartMissingCaps))<br />            {<br />                MessageBox.Show(<span style="color: #006080;">"bluetooth.rfcomm Capability missing in the application manifest"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />            }<br />            <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((r == BluetoothClientReturnCode.InitBluetoothOff) || (r == BluetoothClientReturnCode.StartBluetoothOff))<br />            {<br />                MessageBox.Show(<span style="color: #006080;">"Bluetooth is off, bluetooth is required to launch the client"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />                {<br />                    ConnectionSettingsTask connectionSettingsTask = <span style="color: #0000ff;">new</span> ConnectionSettingsTask();<br />                    connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;<br />                    connectionSettingsTask.Show();<br />                }<br />            }<br />            <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (r == BluetoothClientReturnCode.StartNotAdvertising)<br />            {<br />                MessageBox.Show(<span style="color: #006080;">"Bluetooth Advertising Error, restart the application"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />            }<br />            <span style="color: #0000ff;">else</span><br />            {<br />                MessageBox.Show(<span style="color: #006080;">"Error occurs while initializing the client"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />            }<br />            <span style="color: #0000ff;">return</span>;<br />        }<br />    }<br /><br />    <span style="color: #008000;">// Subscribe to CommandReceived, LogReceived and StateChanged</span><br />    (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.LogReceived += BluetoothRfcommClient_LogReceived;<br />    (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.CommandReceived += BluetoothRfcommClient_CommandReceived;<br />    (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.StateChanged += BluetoothRfcommClient_StateChanged;<br /><br />    <span style="color: #008000;">// Update IsConnected state</span><br />    UpdateIsConnectedAndImageLoaded();<br /><br />    <span style="color: #008000;">// Fill the list of Paired Devices </span><br />    FillListPairedDevices();<br /><br />}</pre>
</div>
<p><br />D&egrave;s que la classe WindowsBluetoothRfcommClient est initialis&eacute;e, l&rsquo;utilisateur peut connecter l&rsquo;application Windows Phone avec l&rsquo;application s&oelig;ur s&rsquo;ex&eacute;cutant sur l&rsquo;ordinateur Windows 8.1. Dans ce cas, l&rsquo;application appelle la m&eacute;thode ButtonConnect_Click.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">private</span> async <span style="color: #0000ff;">void</span> ButtonConnect_Click(<span style="color: #0000ff;">object</span> sender, RoutedEventArgs e)<br />{<br />    <span style="color: #0000ff;">if</span> ((ListDevices.SelectedIndex &gt;= 0) &amp;&amp; (ListDevices.SelectedIndex &lt; ListDevices.Items.Count))<br />    {<br />        BluetoothDevice d = ListDevices.Items[ListDevices.SelectedIndex] <span style="color: #0000ff;">as</span> BluetoothDevice;<br />        <span style="color: #0000ff;">if</span>(d!=<span style="color: #0000ff;">null</span>)<br />        {<br />            BluetoothClientReturnCode r = await (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.Connect(d);<br />            <span style="color: #0000ff;">if</span>(r == BluetoothClientReturnCode.Success)<br />            {<br />                <span style="color: #008000;">// Start Message loop</span><br />                ClearMessage();<br />                ClearFile();<br />            }<br />        }<br />    };<br />}</pre>
</div>
<p>Quand la classe WindowsBluetoothRfcommClient est connect&eacute;e, elle peut recevoir les commandes Bluetooth, dans ce cas la classe WindowsBluetoothRfcommClient appelle la m&eacute;thode BluetoothRfcommClient_CommandReceived.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">void</span> BluetoothRfcommClient_CommandReceived(IBluetoothClient sender, BluetoothCommand args)<br />{<br />    AddLog(<span style="color: #006080;">"Command received "</span> + args.ToString());<br />    <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandMessage))<br />    {<br />        BluetoothCommandMessage bm = args <span style="color: #0000ff;">as</span> BluetoothCommandMessage;<br />        <span style="color: #0000ff;">if</span>(bm!=<span style="color: #0000ff;">null</span>)<br />            AddMessage(<span style="color: #006080;">"Message Received: "</span> + bm.MessageContent);<br />    }<br />    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandPicture))<br />    {<br />        BluetoothCommandPicture bp = args <span style="color: #0000ff;">as</span> BluetoothCommandPicture;<br />        <span style="color: #0000ff;">if</span>(bp!=<span style="color: #0000ff;">null</span>)<br />            AddFile(<span style="color: #006080;">"File Received: "</span> + bp.PicturePath);<br />    }<br />}</pre>
</div>
<p><br />Quand la classe WindowsBluetoothRfcommClient est connect&eacute;e, l&rsquo;utilisateur peut &eacute;galement transmettre des commandes Bluetooth, dans ce cas l&rsquo;application appelle la m&eacute;thode ButtonSend_Click.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">private</span> async <span style="color: #0000ff;">void</span> ButtonSend_Click(<span style="color: #0000ff;">object</span> sender, RoutedEventArgs e)<br />{<br />    <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Message.Text))<br />    {<br />        BluetoothCommandMessage bm = <span style="color: #0000ff;">new</span> BluetoothCommandMessage();<br />        <span style="color: #0000ff;">if</span> (bm != <span style="color: #0000ff;">null</span>)<br />        {<br />            bm.CreateMessageCommand(Message.Text);<br />            BluetoothClientReturnCode r = await (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.SendCommand(bm);<br />            <span style="color: #0000ff;">if</span> (r == BluetoothClientReturnCode.Success)<br />                AddMessage(<span style="color: #006080;">"Message Sent: "</span> + Message.Text);<br />        }<br />    }<br />}</pre>
</div>
<p><strong><span style="font-size: large;">T&eacute;l&eacute;charger le projet</span></strong></p>
<blockquote>
<p>T&eacute;l&eacute;chargement:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/6012.BluetoothRfcommWin8WP8.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39/6012.BluetoothRfcommWin8WP8.zip">C# (200 KB)</a> <br />Pr&eacute;requis:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows 8.1, Windows Phone 8, Visual Studio 2013, Windows Phone 8 SDK&nbsp; <br />Derni&egrave;re modification:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12/13/2013 <br />Licence:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/7824.license.rtf" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/7824.license.rtf">MS-LPL</a> <br />Technologies:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bluetooth, Rfcomm, StreamSocket, PeerFinder, RfcommServiceProvider, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StreamSocketListener, C#, XAML <br />Th&egrave;me:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Communication Bluetooth entre applications Windows Store et Windows Phone</p>
</blockquote>]]></content:encoded>
    </item>
    <item>
      <title>Windows Store and Windows Phone App-to-App communication over Bluetooth</title>
      <link>https://docs.microsoft.com/archive/blogs/flecoqui/windows-store-and-windows-phone-app-to-app-communication-over-bluetooth</link>
      <pubDate>Fri, 13 Dec 2013 06:51:00 GMT</pubDate>
      <dc:creator><![CDATA[FRED LE COQUIL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/flecoqui/2013/12/13/windows-store-and-windows-phone-app-to-app-communication-over-bluetooth/</guid>
      <description><![CDATA[Introduction
This article describes how to create Windows 8.1 and Windows Phone 8 applications...]]></description>
      <content:encoded><![CDATA[<p><strong><span style="font-size: large;">Introduction</span></strong></p>
<p>This article describes how to create Windows 8.1 and Windows Phone 8 applications supporting App-to-App communication over Bluetooth. With these applications, the user can: <br />- send and receive text messages <br />- send pictures (Windows Phone 8 Application) <br />- receive and save pictures (Windows 8.1 Application) <br />The Windows Store application is running as a Bluetooth server and the Windows Phone application is running as a Bluetooth client.</p>
<p>In order to successfully support App-to-App communication over Bluetooth, you don&rsquo;t need any specific peripherals like Wi-Fi router, USB cable. The Windows Phone and the computer or tablet running Windows 8.1 are self-sufficient regarding the Bluetooth communication.</p>
<p>Initially, when I started to write these samples, I wanted to use the PeerFinder API which is available on both platforms, unfortunately I didn't find any way to use this API to allow a communication between a computer running Windows 8.1 and a Windows Phone 8. Finally I decided to use Bluetooth Rfcomm for the communication between both platforms. This approach requires to pair both devices at least one time before launching the applications.</p>
<p>Once you are able to create a Windows Store application and a Windows Phone application talking to each other over Bluetooth, you can bundle a Windows Store application with a Windows Phone application which could be a companion application of the Windows Store application.</p>
<p>To build the sample the Visual Studio 2013, the Windows Phone 8 SDK are required. <br /> <br /><strong><span style="font-size: large;">Pairing devices</span></strong></p>
<p>Before launching the applications you need to pair over Bluetooth the Windows Phone and the computer running Windows 8.1.</p>
<p>1. On the computer running Windows 8.1, select <em>&rdquo;PC and Devices&rdquo;</em> settings page. Select <em>&ldquo;Bluetooth&rdquo;</em> settings page. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3021.clip_image002_3A5295AD.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3021.clip_5F00_image002_5F00_3A5295AD.jpg"><img style="display: inline; background-image: none;" title="clip_image002" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7651.clip_image002_thumb_0E3598BC.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7651.clip_5F00_image002_5F00_thumb_5F00_0E3598BC.jpg" alt="clip_image002" width="505" height="206" border="0" /></a></p>
<p>2. On the Windows Phone, ensure Bluetooth is ON. Select &ldquo;<em>Bluetooth&rdquo;</em> settings page and turn on Bluetooth. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4540.clip_image004_0BFBA0B1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4540.clip_5F00_image004_5F00_0BFBA0B1.png"><img style="display: inline; background-image: none;" title="clip_image004" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8686.clip_image004_thumb_2B3E4784.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8686.clip_5F00_image004_5F00_thumb_5F00_2B3E4784.png" alt="clip_image004" width="182" height="300" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6064.clip_image006_225145F6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6064.clip_5F00_image006_5F00_225145F6.png"><img style="display: inline; background-image: none;" title="clip_image006" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0537.clip_image006_thumb_04068F00.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0537.clip_5F00_image006_5F00_thumb_5F00_04068F00.png" alt="clip_image006" width="182" height="300" border="0" /></a></p>
<p>3. On the computer, select the Windows Phone in the list of the Bluetooth device, and tap on the<em> &ldquo;Pair&rdquo;</em> button. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2703.clip_image008_25F1F184.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2703.clip_5F00_image008_5F00_25F1F184.jpg"><img style="display: inline; background-image: none;" title="clip_image008" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2112.clip_image008_thumb_5A261ACA.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2112.clip_5F00_image008_5F00_thumb_5F00_5A261ACA.jpg" alt="clip_image008" width="329" height="96" border="0" /></a></p>
<p>4. On the Windows Phone, accept the pair request. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0488.clip_image010_5139193C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0488.clip_5F00_image010_5F00_5139193C.png"><img style="display: inline; background-image: none;" title="clip_image010" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2260.clip_image010_thumb_4BEA328B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2260.clip_5F00_image010_5F00_thumb_5F00_4BEA328B.png" alt="clip_image010" width="208" height="344" border="0" /></a></p>
<p>5. On the computer, confirm the pairing. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7317.clip_image012_14A3AB50.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7317.clip_5F00_image012_5F00_14A3AB50.jpg"><img style="display: inline; background-image: none;" title="clip_image012" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6266.clip_image012_thumb_0BB6A9C2.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6266.clip_5F00_image012_5F00_thumb_5F00_0BB6A9C2.jpg" alt="clip_image012" width="352" height="155" border="0" /></a></p>
<p>6. On both devices, the peer devices should be displayed as connected. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6761.clip_image014_2DA20C46.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6761.clip_5F00_image014_5F00_2DA20C46.jpg"><img style="display: inline; background-image: none;" title="clip_image014" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7183.clip_image014_thumb_7AD205D1.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7183.clip_5F00_image014_5F00_thumb_5F00_7AD205D1.jpg" alt="clip_image014" width="337" height="80" border="0" /></a> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3808.clip_image016_5CF381D0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3808.clip_5F00_image016_5F00_5CF381D0.png"><img style="display: inline; background-image: none;" title="clip_image016" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0876.clip_image016_thumb_6C961D92.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0876.clip_5F00_image016_5F00_thumb_5F00_6C961D92.png" alt="clip_image016" width="183" height="302" border="0" /></a></p>
<p>7. The devices are now paired, you can launch the applications on both platforms.</p>
<p><strong><span style="font-size: large;">Connecting the applications</span></strong></p>
<p>1. On the computer running Windows 8.1, launch the Bluetooth Server application. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4024.clip_image018_2373028A.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4024.clip_5F00_image018_5F00_2373028A.jpg"><img style="display: inline; background-image: none;" title="clip_image018" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0160.clip_image018_thumb_57A72BD0.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0160.clip_5F00_image018_5F00_thumb_5F00_57A72BD0.jpg" alt="clip_image018" width="112" height="111" border="0" /></a> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7446.clip_image020_2713AE18.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7446.clip_5F00_image020_5F00_2713AE18.jpg"><img style="display: inline; background-image: none;" title="clip_image020" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6813.clip_image020_thumb_4BA7CC4D.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6813.clip_5F00_image020_5F00_thumb_5F00_4BA7CC4D.jpg" alt="clip_image020" width="653" height="369" border="0" /></a></p>
<p>2. On the Windows Phone, launch the Bluetooth client application. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4375.clip_image022_1B144E95.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4375.clip_5F00_image022_5F00_1B144E95.jpg"><img style="display: inline; background-image: none;" title="clip_image022" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8422.clip_image022_thumb_03E8D417.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8422.clip_5F00_image022_5F00_thumb_5F00_03E8D417.jpg" alt="clip_image022" width="244" height="93" border="0" /></a></p>
<p>3. Check in the Settings section that the &ldquo;Service Name&rdquo; are the same, it&rsquo;s mandatory to successfully connect the client application with the server application. The GUID is defined in the application source code and in the Windows 8 application manifest. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5710.clip_image024_660A5015.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5710.clip_5F00_image024_5F00_660A5015.png"><img style="display: inline; background-image: none;" title="clip_image024" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0363.clip_image024_thumb_5A085FE1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0363.clip_5F00_image024_5F00_thumb_5F00_5A085FE1.png" alt="clip_image024" width="213" height="353" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2538.clip_image026_7E9C7E16.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2538.clip_5F00_image026_5F00_7E9C7E16.jpg"><img style="display: inline; background-image: none;" title="clip_image026" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7750.clip_image026_thumb_32D0A75D.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7750.clip_5F00_image026_5F00_thumb_5F00_32D0A75D.jpg" alt="clip_image026" width="579" height="196" border="0" /></a></p>
<p>4. On the Windows Phone application navigate to <em>&ldquo;Connection&rdquo;</em> pivot. Select the computer name in the list of paired devices and tap on the <em>&ldquo;Connect&rdquo;</em> button. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0250.clip_image028_26CEB729.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0250.clip_5F00_image028_5F00_26CEB729.png"><img style="display: inline; background-image: none;" title="clip_image028" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8284.clip_image028_thumb_7D5A75E8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8284.clip_5F00_image028_5F00_thumb_5F00_7D5A75E8.png" alt="clip_image028" width="212" height="351" border="0" /></a></p>
<p>5. As it&rsquo;s the first application connection a dialog box appears on the computer running the server application. Allow the Windows application to use your Windows Phone <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6253.clip_image030_21EE941E.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6253.clip_5F00_image030_5F00_21EE941E.jpg"><img style="display: inline; background-image: none;" title="clip_image030" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7585.clip_image030_thumb_67FF5131.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7585.clip_5F00_image030_5F00_thumb_5F00_67FF5131.jpg" alt="clip_image030" width="458" height="82" border="0" /></a></p>
<p>6. Once the connection is accepted on the server side, the client application state is displayed as <em>&ldquo;Connected&rdquo;</em> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1665.clip_image032_4A20CD30.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1665.clip_5F00_image032_5F00_4A20CD30.png"><img style="display: inline; background-image: none;" title="clip_image032" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8032.clip_image032_thumb_00917F33.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8032.clip_5F00_image032_5F00_thumb_5F00_00917F33.png" alt="clip_image032" width="214" height="355" border="0" /></a></p>
<p>7. The server application state is also displayed as <em>&ldquo;Connected&rdquo;</em> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6011.clip_image034_25259D68.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6011.clip_5F00_image034_5F00_25259D68.jpg"><img style="display: inline; background-image: none;" title="clip_image034" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0574.clip_image034_thumb_4710FFEC.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0574.clip_5F00_image034_5F00_thumb_5F00_4710FFEC.jpg" alt="clip_image034" width="373" height="193" border="0" /></a></p>
<p>8. The applications are now connected, you can exchange text messages and pictures between both applications.</p>
<p><strong><span style="font-size: large;">Sending and receiving text messages</span></strong></p>
<p>1. On the Windows Phone, navigate to the Messages pivot, enter a text and tap on &ldquo;<em>Send&rdquo;</em> button. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3632.clip_image036_01F832B6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3632.clip_5F00_image036_5F00_01F832B6.png"><img style="display: inline; background-image: none;" title="clip_image036" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3666.clip_image036_thumb_268C50EB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3666.clip_5F00_image036_5F00_thumb_5F00_268C50EB.png" alt="clip_image036" width="223" height="369" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7220.clip_image038_5A54473C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7220.clip_5F00_image038_5F00_5A54473C.png"><img style="display: inline; background-image: none;" title="clip_image038" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6366.clip_image038_thumb_50FB12B9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6366.clip_5F00_image038_5F00_thumb_5F00_50FB12B9.png" alt="clip_image038" width="223" height="369" border="0" /></a></p>
<p>2. You should receive the same message on your application running on Windows 8.1. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0841.clip_image040_32B05BC3.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0841.clip_5F00_image040_5F00_32B05BC3.jpg"><img style="display: inline; background-image: none;" title="clip_image040" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1348.clip_image040_thumb_698D40BA.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1348.clip_5F00_image040_5F00_thumb_5F00_698D40BA.jpg" alt="clip_image040" width="418" height="213" border="0" /></a></p>
<p>3. You can also send a message from the Windows application towards the Windows Phone application. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7536.clip_image042_0B78A33F.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7536.clip_5F00_image042_5F00_0B78A33F.jpg"><img style="display: inline; background-image: none;" title="clip_image042" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6014.clip_image042_thumb_34170F46.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6014.clip_5F00_image042_5F00_thumb_5F00_34170F46.jpg" alt="clip_image042" width="419" height="212" border="0" /></a></p>
<p>4. And receive the message on the Windows Phone. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5531.clip_image044_71A6FDC0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5531.clip_5F00_image044_5F00_71A6FDC0.png"><img style="display: inline; background-image: none;" title="clip_image044" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3817.clip_image044_thumb_65A50D8C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3817.clip_5F00_image044_5F00_thumb_5F00_65A50D8C.png" alt="clip_image044" width="218" height="361" border="0" /></a></p>
<p><strong><span style="font-size: large;">Sending and receiving pictures</span></strong></p>
<p>1. On the Windows Phone, navigate to the &ldquo;<em>Files&rdquo;</em> pivot, and tap on &ldquo;<em>Select Picture&rdquo;</em> button. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6472.clip_image046_0A392BC2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6472.clip_5F00_image046_5F00_0A392BC2.png"><img style="display: inline; background-image: none;" title="clip_image046" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6332.clip_image046_thumb_7E373B8D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6332.clip_5F00_image046_5F00_thumb_5F00_7E373B8D.png" alt="clip_image046" width="226" height="374" border="0" /></a></p>
<p>2. Navigate among the albums and select the picture you want to send to the Windows Application. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6763.clip_image048_35142085.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6763.clip_5F00_image048_5F00_35142085.png"><img style="display: inline; background-image: none;" title="clip_image048" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6708.clip_image048_thumb_444A8952.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6708.clip_5F00_image048_5F00_thumb_5F00_444A8952.png" alt="clip_image048" width="204" height="338" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8321.clip_image050_6F91B10A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8321.clip_5F00_image050_5F00_6F91B10A.png"><img style="display: inline; background-image: none;" title="clip_image050" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1016.clip_image050_thumb_0170D589.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1016.clip_5F00_image050_5F00_thumb_5F00_0170D589.png" alt="clip_image050" width="204" height="337" border="0" /></a></p>
<p>3. Once the picture is selected, the path and the size of the picture are displayed on the screen. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6138.clip_image052_22F00518.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6138.clip_5F00_image052_5F00_22F00518.png"><img style="display: inline; background-image: none;" title="clip_image052" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4024.clip_image052_thumb_44DB679C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4024.clip_5F00_image052_5F00_thumb_5F00_44DB679C.png" alt="clip_image052" width="207" height="341" border="0" /></a></p>
<p>4. Tap on the <em>&ldquo;Send Picture&rdquo;</em> button to send the picture. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4848.clip_image054_026B5617.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4848.clip_5F00_image054_5F00_026B5617.png"><img style="display: inline; background-image: none;" title="clip_image054" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5554.clip_image054_thumb_4B24CEDB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5554.clip_5F00_image054_5F00_thumb_5F00_4B24CEDB.png" alt="clip_image054" width="215" height="356" border="0" /></a></p>
<p>5. On the computer screen the picture is displayed in the Files section <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6560.clip_image056_2CDA17E5.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6560.clip_5F00_image056_5F00_2CDA17E5.jpg"><img style="display: inline; background-image: none;" title="clip_image056" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1682.clip_image056_thumb_11A44F95.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1682.clip_5F00_image056_5F00_thumb_5F00_11A44F95.jpg" alt="clip_image056" width="423" height="200" border="0" /></a></p>
<p>6. If you double-tap on the picture, the picture is displayed in full screen. At least you can save the picture on your hard drive if you tap on the <em>&ldquo;Save Image&rdquo;</em> button.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0243.clip_image058_05A25F61.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0243.clip_5F00_image058_5F00_05A25F61.jpg"><img style="display: inline; background-image: none;" title="clip_image058" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6837.clip_image058_thumb_4EC80B1A.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6837.clip_5F00_image058_5F00_thumb_5F00_4EC80B1A.jpg" alt="clip_image058" width="191" height="108" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2148.clip_image060_30E98719.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2148.clip_5F00_image060_5F00_30E98719.jpg"><img style="display: inline; background-image: none;" title="clip_image060" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7701.clip_image060_thumb_4BB5AD25.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7701.clip_5F00_image060_5F00_thumb_5F00_4BB5AD25.jpg" alt="clip_image060" width="389" height="227" border="0" /></a></p>
<p><strong><span style="font-size: large;">Using Bluetooth Rfcomm for the communication between Windows and Windows Phone applications</span></strong></p>
<p>Once the connection is established between the Windows Phone application and the Windows application using Windows.Networking.Sockets.StreamSocket, both applications can exchange commands over Bluetooth Rfcomm. <br />With the current applications, a command can be a text message, a picture. <br />The syntax associated with a command is the following:</p>
<p><em>command=&lt;BluetoothCommand&gt;|[[&lt;Attribute0Key&gt;=&lt;Attribute0&gt;]|[&lt;Attribute1Key&gt;=&lt;Attribute1&gt;] ... |[&lt;AttributeNKey&gt;=&lt;AttributeN&gt;]...]]</em></p>
<p>For instance: <br /><strong>Message Command:</strong> <br /><em>command=message|content=&lt;Message Content&gt; <br /></em><strong>Picture File Command:</strong> <br /><em>command=picture|path=&lt;Picture Path&gt;|size=&lt;Picture Size&gt;|content=&lt;Picture Content&gt; <br /></em> <br />This model can be extended to support new companion scenarios, a command could transport Audio files, Video files, keyboard events, &hellip; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4505.clip_image062_2D6AF62F.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4505.clip_5F00_image062_5F00_2D6AF62F.jpg"><img style="display: inline; background-image: none;" title="clip_image062" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5127.clip_image062_thumb_11C8FAEA.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5127.clip_5F00_image062_5F00_thumb_5F00_11C8FAEA.jpg" alt="clip_image062" width="803" height="334" border="0" /></a></p>
<p><strong><span style="font-size: large;">Building the sample applications</span> </strong></p>
<p>In order to build the Bluetooth server sample application for Windows Store and the Bluetooth client sample application for Windows Phone, make sure you have the basics installed: <br />1. a computer running Windows 8.1 <br />2. a Windows Phone running Windows Phone 8&nbsp; <br />3. Visual Studio 2013, <br />4. Windows Phone 8 SDK.</p>
<p><strong><span style="font-size: large;">Exploring the Windows Store Application project</span></strong></p>
<p>The Windows Store Application project is a XAML based project.&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5460.clip_image064_61357D31.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5460.clip_5F00_image064_5F00_61357D31.jpg"><img style="display: inline; background-image: none;" title="clip_image064" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0880.clip_image064_thumb_70D818F3.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0880.clip_5F00_image064_5F00_thumb_5F00_70D818F3.jpg" alt="clip_image064" width="390" height="359" border="0" /></a></p>
<ul>
<li><strong><em>MainPage.xaml.cs</em></strong> contains the main page source code.</li>
<li><strong><em>App.xaml.cs</em></strong> contains the implementation of the App class.</li>
<li><strong><em>WindowsBluetoothRfcommServer.cs</em></strong> contains the implementation of the WindowsBluetoothRfcommServer class.</li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contains the source code used to store and retrieve the application settings in the local app store.</li>
</ul>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>Shared source code between Windows and Windows Phone</strong></p>
<ul>
<li><strong><em>BluetoothService.cs</em></strong> contains the Service ID used for the Bluetooth Communication.</li>
<li><strong><em>BluetoothServer.cs</em></strong> contains the definition of the Bluetooth Server Interface.</li>
<li><strong><em>BluetoothDevice.cs</em></strong> contains the definition of the BluetoothDevice class.</li>
<li><strong><em>BluetoothCommand.cs</em></strong> contains the definition of the BluetoothCommand, BluetoothCommandMessage, BluetoothCommandPicture classes. <br /> <br /><strong>WindowsBluetoothRfcommServer states:</strong>&nbsp; <br />&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4338.image_1FB09471.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4338.image_5F00_1FB09471.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0636.image_thumb_1174AC32.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0636.image_5F00_thumb_5F00_1174AC32.png" alt="image" width="497" height="456" border="0" /></a></li>
</ul>
<p><strong>WindowsBluetoothRfcommServer Initialization method:</strong> <br />This method creates the RfcommServiceProvider and check if Bluetooth is not off on the computer</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothServerReturnCode&gt; Initialization()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        rfcommProvider = await RfcommServiceProvider.CreateAsync(<br />            RfcommServiceId.FromUuid(_BluetoothServiceUuid));<br />        <span style="color: #0000ff;">if</span> (rfcommProvider != <span style="color: #0000ff;">null</span>)<br />        {<br />            SetState(BluetoothServerState.Stopped);<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />        }<br />        <span style="color: #0000ff;">else</span><br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitError;<br /><br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_BLUETOOTH_OFF)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitBluetoothOff;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_MISSING_CAPS)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitMissingCaps;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_NOT_ADVERTISING)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitNotAdvertising;<br /><br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Initialization - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.InitException;<br />    }<br />}</pre>
</div>
<p><strong>WindowsBluetoothRfcommServer Start method:</strong> <br />This method creates a listener and start listening. It also starts advertising for the Rfcomm Service.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothServerReturnCode&gt; Start()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Starting the server..."</span>);<br />        <span style="color: #0000ff;">if</span> (rfcommProvider == <span style="color: #0000ff;">null</span>)<br />            rfcommProvider = await RfcommServiceProvider.CreateAsync(<br />                RfcommServiceId.FromUuid(_BluetoothServiceUuid));<br /><br />        <span style="color: #0000ff;">if</span> (rfcommProvider != <span style="color: #0000ff;">null</span>)<br />        {<br />            <span style="color: #0000ff;">if</span> (socketListener != <span style="color: #0000ff;">null</span>)<br />            {<br />                socketListener.Dispose();<br />                socketListener = <span style="color: #0000ff;">null</span>;<br />            }<br /><br /><br />            <span style="color: #008000;">// Create a listener for this service and start listening</span><br />            socketListener = <span style="color: #0000ff;">new</span> StreamSocketListener();<br />            socketListener.ConnectionReceived += OnConnectionReceived;<br /><br />            await socketListener.BindServiceNameAsync(rfcommProvider.ServiceId.AsString(),<br />                SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);<br /><br />            <span style="color: #008000;">// Set the SDP attributes and start Bluetooth advertising</span><br />            DataWriter sdpWriter = <span style="color: #0000ff;">new</span> DataWriter();<br /><br />            <span style="color: #008000;">// Write the Service Name Attribute.</span><br />            sdpWriter.WriteByte(SdpServiceNameAttributeType);<br /><br />            <span style="color: #008000;">// The length of the UTF-8 encoded Service Name SDP Attribute.</span><br />            sdpWriter.WriteByte((<span style="color: #0000ff;">byte</span>)BluetoothServiceDisplayName.Length);<br /><br />            <span style="color: #008000;">// The UTF-8 encoded Service Name value.</span><br />            sdpWriter.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8;<br />            sdpWriter.WriteString(BluetoothServiceDisplayName);<br /><br />            <span style="color: #008000;">// Set the SDP Attribute on the RFCOMM Service Provider.</span><br />            <span style="color: #0000ff;">if</span>(rfcommProvider.SdpRawAttributes.ContainsKey(SdpServiceNameAttributeId))<br />                rfcommProvider.SdpRawAttributes.Remove(SdpServiceNameAttributeId);<br />            rfcommProvider.SdpRawAttributes.Add(SdpServiceNameAttributeId, sdpWriter.DetachBuffer());<br />            <span style="color: #008000;">// Start Bluetooth advertising</span><br />            SetState(BluetoothServerState.Started); <br />            rfcommProvider.StartAdvertising(socketListener);<br />            NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Server Started"</span>);<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span>(Exception e)<br />    {<br />        <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_BLUETOOTH_OFF)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartBluetoothOff;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_MISSING_CAPS)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartMissingCaps;<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)e.HResult == ERR_NOT_ADVERTISING)<br />            <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartNotAdvertising;<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Start - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartException;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StartError;<br />}</pre>
</div>
<p><strong>WindowsBluetoothRfcommServer OnConnectionReceived method:</strong> <br />This method is called when the server receives a connection request. It saves the information of the Bluetooth Client device. At least, it calls the method ReceiveIncommingCommands to receive commands.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">void</span> OnConnectionReceived(StreamSocketListener sender, <br />    StreamSocketListenerConnectionReceivedEventArgs args)<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        <span style="color: #008000;">// Don't need the listener anymore</span><br />        socketListener.Dispose();<br />        socketListener = <span style="color: #0000ff;">null</span>;<br /><br />        socket = args.Socket;<br />        <span style="color: #0000ff;">if</span>((socket!=<span style="color: #0000ff;">null</span>) &amp;&amp; (socket.Information!=<span style="color: #0000ff;">null</span>))<br />        {<br />            _connectedDeviceDisplayName = <span style="color: #006080;">"Remote Address: "</span> + socket.Information.RemoteAddress.DisplayName + <span style="color: #006080;">" Remote Port: "</span> + socket.Information.RemotePort + <span style="color: #006080;">" Remote Service: "</span> + socket.Information.RemoteServiceName;<br />            _connectedDeviceHostName = socket.Information.RemoteHostName.DisplayName;<br />            _connectedDeviceServiceName = socket.Information.RemoteServiceName;<br />        }<br /><br />        SetState(BluetoothServerState.Connected);<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client connected"</span> );<br /><br />        <span style="color: #0000ff;">if</span> (ConnectionReceived != <span style="color: #0000ff;">null</span>)<br />        {<br />            BluetoothDevice device = <span style="color: #0000ff;">new</span> BluetoothDevice(_connectedDeviceHostName,_connectedDeviceServiceName,_connectedDeviceDisplayName);<br />            ConnectionReceived(<span style="color: #0000ff;">this</span>, device);<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in OnConnectionReceived - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span>;<br />    }<br />    ReceiveIncomingCommands();<br />}</pre>
</div>
<p><strong> <br />WindowsBluetoothRfcommServer Disconnect method:</strong> <br />This method calls ForceDisconnect to disconnect the current connection, it creates a new listener and start listening for the next connection.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothServerReturnCode&gt; Disconnect()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        ForceDisconnect();<br />        <span style="color: #008000;">// Create a listener for this service and start listening</span><br />        <span style="color: #0000ff;">if</span>(socketListener==<span style="color: #0000ff;">null</span>)<br />        {<br />            socketListener = <span style="color: #0000ff;">new</span> StreamSocketListener();<br />            socketListener.ConnectionReceived += OnConnectionReceived;<br /><br />            await socketListener.BindServiceNameAsync(rfcommProvider.ServiceId.AsString(),<br />                SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);<br />        }<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client Disconnected"</span>);<br />      <br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Disconnect - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.DisconnectException;<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        reader = <span style="color: #0000ff;">null</span>;<br />        writer = <span style="color: #0000ff;">null</span>;<br />        socket = <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />}</pre>
</div>
<p><br /><strong>WindowsBluetoothRfcommServer Stop method:</strong> <br />IF the server was connected this method call ForceDisconnect to disconnect the current connection, it stops Bluetooth advertising and clears all the sockets.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span>  BluetoothServerReturnCode Stop()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Stopping the server..."</span> );<br />        <span style="color: #0000ff;">if</span> (GetState() == BluetoothServerState.Connected)<br />        {<br />            ForceDisconnect();<br />        }<br />        SetState(BluetoothServerState.Stopped);<br />        <span style="color: #0000ff;">if</span> (rfcommProvider != <span style="color: #0000ff;">null</span>)<br />        {<br />            rfcommProvider.StopAdvertising();<br />            rfcommProvider = <span style="color: #0000ff;">null</span>;<br />        }<br /><br />        <span style="color: #0000ff;">if</span> (socketListener != <span style="color: #0000ff;">null</span>)<br />        {<br />            socketListener.Dispose();<br />            socketListener = <span style="color: #0000ff;">null</span>;<br />        }<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Server stopped"</span>);<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Stop - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.StopException;<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        rfcommProvider = <span style="color: #0000ff;">null</span>;<br />        socketListener = <span style="color: #0000ff;">null</span>;<br />        writer = <span style="color: #0000ff;">null</span>;<br />        socket = <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothServerReturnCode.Success;<br />}</pre>
</div>
<p><br /> <br />The Windows Application and the Windows Phone Application use the same Service Uuid to enable the communication between both applications. For the Windows Store application the Service Uuid is defined in the application manifest and in the source code. <br />The following section is added in the Capabilities of the manifest:</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">&lt;</span><span style="color: #800000;">Capabilities</span><span style="color: #0000ff;">&gt;</span><br />  <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">Capability</span> <span style="color: #ff0000;">Name</span><span style="color: #0000ff;">="internetClient"</span> <span style="color: #0000ff;">/&gt;</span><br />  <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">Capability</span> <span style="color: #ff0000;">Name</span><span style="color: #0000ff;">="picturesLibrary"</span> <span style="color: #0000ff;">/&gt;</span><br />  <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">m2:DeviceCapability</span> <span style="color: #ff0000;">Name</span><span style="color: #0000ff;">="bluetooth.rfcomm"</span><span style="color: #0000ff;">&gt;</span><br />    <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">m2:Device</span> <span style="color: #ff0000;">Id</span><span style="color: #0000ff;">="any"</span><span style="color: #0000ff;">&gt;</span><br />      <span style="color: #0000ff;">&lt;</span><span style="color: #800000;">m2:Function</span> <span style="color: #ff0000;">Type</span><span style="color: #0000ff;">="serviceId:17890000-0068-0069-1532-1992D79BE4D8"</span> <span style="color: #0000ff;">/&gt;</span><br />    <span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">m2:Device</span><span style="color: #0000ff;">&gt;</span><br />  <span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">m2:DeviceCapability</span><span style="color: #0000ff;">&gt;</span><br /><span style="color: #0000ff;">&lt;/</span><span style="color: #800000;">Capabilities</span><span style="color: #0000ff;">&gt;</span></pre>
</div>
<p>The file BluetoothService.cs contains the declaration of the ServiceID as well:</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> BluetoothRfcommGlobal<br />{<br />   <span style="color: #008000;">// Service uuid: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Guid BluetoothServiceUuid = <span style="color: #0000ff;">new</span> Guid(<span style="color: #006080;">"17890000-0068-0069-1532-1992D79BE4D8"</span>);<br />   <span style="color: #008000;">// Service display name: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> BluetoothServiceDisplayName = <span style="color: #006080;">"My Bluetooth Rfcomm Service"</span>;<br />}</pre>
</div>
<p><br />The WindowsBluetoothRfcommServer is instantiated in the App constructor.&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> App()<br />{<br />    <span style="color: #0000ff;">this</span>.InitializeComponent();<br /><br />    <span style="color: #0000ff;">this</span>.Suspending += OnSuspending;<br />    <span style="color: #0000ff;">this</span>.Resuming += OnResuming;<br />    BluetoothRfcommServer = <span style="color: #0000ff;">new</span> WindowsBluetoothRfcommServer(BluetoothServiceUuid, BluetoothServiceDisplayName, ApplicationConfiguration.AutoStart);<br />}</pre>
</div>
<p>The WindowsBluetoothRfcommServer is Initialized and Started in the method OnNavigatedTo of MainPage class.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">// Initialize Blutooth Server to check whether the bluetooth is on</span><br /><span style="color: #0000ff;">if</span> (((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer != <span style="color: #0000ff;">null</span>) &amp;&amp; ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.GetState() == BluetoothServerState.Created))<br />{<br />    BluetoothServerReturnCode r = await(App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.Initialization();<br />    <span style="color: #0000ff;">if</span> ((r == BluetoothServerReturnCode.Success) &amp;&amp; ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.AutoStart == <span style="color: #0000ff;">true</span>))<br />    {<br />        r = await(App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.Start();<br />    }<br />    <span style="color: #0000ff;">if</span> (r != BluetoothServerReturnCode.Success)<br />    {<br />        <span style="color: #0000ff;">if</span> ((r == BluetoothServerReturnCode.InitMissingCaps) || (r == BluetoothServerReturnCode.StartMissingCaps))<br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"bluetooth.rfcomm Capability missing in the application manifest"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((r == BluetoothServerReturnCode.InitBluetoothOff) || (r == BluetoothServerReturnCode.StartBluetoothOff))<br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"Bluetooth is off, bluetooth is required to launch the server"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (r == BluetoothServerReturnCode.StartNotAdvertising)<br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"Bluetooth Advertising Error, restart the application"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            Windows.UI.Popups.MessageDialog messageDialog = <span style="color: #0000ff;">new</span> Windows.UI.Popups.MessageDialog(<span style="color: #006080;">"Error occurs while initializing the server"</span>, <span style="color: #006080;">"Windows Bluetooth Server"</span>);<br />            await messageDialog.ShowAsync();<br />        }<br />    }<br />}</pre>
</div>
<p>Once the WindowsBluetoothRfcommServer is started, it&rsquo;s waiting for incoming connection requests from client devices. When the application is connected, the WindowsBluetoothRfcommServer calls the method WindowsBluetoothRfcomm_ConnectionReceived.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">void</span> BluetoothRfcommServer_ConnectionReceived(IBluetoothServer sender, BluetoothDevice args)<br />{<br />    ClearMessage();<br />    AddLog(<span style="color: #006080;">"Connected with "</span> + (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommServer.ConnectedDeviceDisplayName);<br />}</pre>
</div>
<p><br />When the WindowsBluetoothRfcommServer is connected, it can receive Bluetooth commands, in that case the WindowsBluetoothRfcommServer calls the method BluetoothRfcommServer_CommandReceived.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">void</span> BluetoothRfcommServer_CommandReceived(IBluetoothServer sender, BluetoothCommand args)<br /> {<br />     AddLog(<span style="color: #006080;">"Command received "</span> + args.ToString());<br />     <br />     <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandMessage))<br />     {<br />         BluetoothCommandMessage bm = args <span style="color: #0000ff;">as</span> BluetoothCommandMessage;<br />         <span style="color: #0000ff;">if</span>(bm!=<span style="color: #0000ff;">null</span>)<br />             AddMessage(<span style="color: #006080;">"Message Received: "</span> + bm.MessageContent);<br />     }<br />     <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandPicture))<br />     {<br />         RunOnDispatcherThread(() =&gt;<br />         {<br />             BluetoothCommandPicture bp = args <span style="color: #0000ff;">as</span> BluetoothCommandPicture;<br />             <span style="color: #0000ff;">if</span> (bp != <span style="color: #0000ff;">null</span>)<br />             {<br />                 DisplayImage(bp.PictureContent);<br />                 <span style="color: #0000ff;">if</span> (bp.PictureContent.Length &gt; 0)<br />                 {<br />                     _ImageBuffer = <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">byte</span>[bp.PictureSize];<br />                     <span style="color: #0000ff;">if</span> (_ImageBuffer != <span style="color: #0000ff;">null</span>)<br />                         Array.Copy(bp.PictureContent, _ImageBuffer, bp.PictureContent.Length);<br />                 }<br />             }<br />         }); <br /><br />     }<br /> }</pre>
</div>
<p><strong><span style="font-size: large;">Exploring the Windows Phone 8 Application project</span> </strong><strong></strong></p>
<p>The Windows Phone 8 Application project is a XAML based project.&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7522.clip_image066_4BDCE92B.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7522.clip_5F00_image066_5F00_4BDCE92B.jpg"><img style="display: inline; background-image: none;" title="clip_image066" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6557.clip_image066_thumb_7FA4DF7C.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6557.clip_5F00_image066_5F00_thumb_5F00_7FA4DF7C.jpg" alt="clip_image066" width="331" height="308" border="0" /></a></p>
<ul>
<li><strong><em>MainPage.xaml.cs</em></strong> contains the main page source code.</li>
<li><strong><em>App.xaml.cs</em></strong> contains the implementation of the App class.</li>
<li><strong><em>WindowsBluetoothRfcommClient.cs</em></strong> contains the implementation of the WindowsBluetoothRfcommClient class.</li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contains the source code used to store and retrieve the application settings in the local app store.</li>
</ul>
<p><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Shared source code between Windows and Windows Phone</strong></p>
<ul>
<li><strong><em>BluetoothService.cs</em></strong> contains the Service ID used for the Bluetooth Communication.</li>
<li><strong><em>BluetoothClient.cs</em></strong> contains the definition of the Bluetooth Client Interface.</li>
<li><strong><em>BluetoothDevice.cs</em></strong> contains the definition of the BluetoothDevice class.</li>
<li><strong><em>BluetoothCommand.cs</em></strong> contains the definition of the BluetoothCommand, BluetoothCommandMessage, BluetoothCommandPicture classes.</li>
</ul>
<p><br /><strong>BluetoothRfcommClient states:</strong></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8562.image_27CA5177.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8562.image_5F00_27CA5177.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5861.image_thumb_16E5AD87.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5861.image_5F00_thumb_5F00_16E5AD87.png" alt="image" width="434" height="489" border="0" /></a></p>
<p><strong>WindowsPhoneBluetoothRfcommClient Initialization method:</strong> <br />This method checks if&nbsp; the application is not running in the Windows Phone Emulator, it also checks if Bluetooth is not off on the Windows Phone.&nbsp; </p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothClientReturnCode&gt; Initialization()<br />{<br />    <span style="color: #0000ff;">if</span> (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator)<br />    {<br />        <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitEmulator;<br />    }<br /><br />    <span style="color: #0000ff;">try</span><br />    {<br />        PeerFinder.AlternateIdentities[<span style="color: #006080;">"Bluetooth:Paired"</span>] = <span style="color: #006080;">""</span>;<br />        var Peers = await PeerFinder.FindAllPeersAsync();<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception ex)<br />    {<br />        <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)ex.HResult == ERR_BLUETOOTH_OFF)<br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitBluetoothOff;<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)ex.HResult == ERR_MISSING_CAPS)<br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitMissingCaps;<br />        }<br />        <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((<span style="color: #0000ff;">uint</span>)ex.HResult == ERR_NOT_ADVERTISING)<br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitNotAdvertising;<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.InitError;<br />        }<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        PeerFinder.Stop();<br />    }<br />    SetState(BluetoothClientState.Initialized);<br />    <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.Success;<br /><br />}</pre>
</div>
<p><strong><strong> <br />WindowsPhoneBluetoothRfcommClient Connect </strong> method:</strong> <br />This method creates a StreamSocket used to create a connection with the Bluetooth Device. If the connection is sucessful, It saves the information of the Bluetooth Server device. At least it calls the method ReceiveIncommingCommands to receive commands.<strong><strong><strong> <br /></strong></strong></strong></p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> async Task&lt;BluetoothClientReturnCode&gt; Connect(BluetoothDevice device)<br />{<br />    NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Connecting Client..."</span>);<br />    <span style="color: #0000ff;">if</span> (socket == <span style="color: #0000ff;">null</span>)<br />        socket = <span style="color: #0000ff;">new</span> StreamSocket();<br />    <span style="color: #0000ff;">try</span><br />    {<br />        await socket.ConnectAsync(<span style="color: #0000ff;">new</span> Windows.Networking.HostName(device.HostName), BluetoothServiceName);<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception ex)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Connect - "</span> + ex.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.ConnectError;<br />    }<br />    SetState(BluetoothClientState.Connected);<br /><br />    <span style="color: #008000;">// Connected no need for advertising anymore</span><br />    PeerFinder.Stop();<br />    _connectedDeviceDisplayName = device.DisplayName;<br />    _connectedDeviceHostName = device.HostName;<br />    _connectedDeviceServiceName = BluetoothServiceName;<br />    NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client connected"</span>);<br /><br />    <span style="color: #008000;">// Reception loop</span><br />    ReceiveIncomingCommands();<br /><br />    <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.Success;<br />}</pre>
</div>
<p><strong><strong><br />WindowsPhoneBluetoothRfcommClient </strong>Disconnect method:</strong> <br />This method clears the StreamSocket to disconnect the current connection.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> BluetoothClientReturnCode Disconnect()<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Disconnecting Client..."</span>);<br />        SetState(BluetoothClientState.Initialized);<br /><br />        _connectedDeviceDisplayName = <span style="color: #006080;">""</span>;<br />        _connectedDeviceHostName = <span style="color: #006080;">""</span>;<br />        _connectedDeviceServiceName = <span style="color: #006080;">""</span>;<br /><br />        <span style="color: #0000ff;">if</span> (socket != <span style="color: #0000ff;">null</span>)<br />        {<br />            socket.Dispose();<br />            socket = <span style="color: #0000ff;">null</span>;<br />        }<br /><br />        <span style="color: #0000ff;">if</span> (writer != <span style="color: #0000ff;">null</span>)<br />        {<br />            writer.DetachStream(); <br />            writer.Dispose();<br />            writer = <span style="color: #0000ff;">null</span>;<br />        }<br />        <span style="color: #0000ff;">if</span> (reader != <span style="color: #0000ff;">null</span>)<br />        {<br />            <br />            reader.Dispose();<br />            reader = <span style="color: #0000ff;">null</span>;<br />        }<br />        NotifyLog(<span style="color: #006080;">"Information"</span>, <span style="color: #006080;">"Client Disconnected"</span>);<br /><br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        NotifyLog(<span style="color: #006080;">"Error"</span>, <span style="color: #006080;">"Exception in Disconnect - "</span> + e.Message);<br />        <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.DisconnectException;<br />    }<br />    <span style="color: #0000ff;">finally</span><br />    {<br />        reader = <span style="color: #0000ff;">null</span>;<br />        writer = <span style="color: #0000ff;">null</span>;<br />        socket = <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> BluetoothClientReturnCode.Success;<br />}</pre>
</div>
<p><br />The Windows Application and the Windows Phone Application use the same Service Uuid to enable the communication between both applications. For the Windows Phone application the Service Uuid is defined in the source code in the file BluetoothService.cs which contains the declaration of the ServiceID as well:</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">class</span> BluetoothRfcommGlobal<br />{<br />   <span style="color: #008000;">// Service uuid: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> Guid BluetoothServiceUuid = <span style="color: #0000ff;">new</span> Guid(<span style="color: #006080;">"17890000-0068-0069-1532-1992D79BE4D8"</span>);<br />   <span style="color: #008000;">// Service display name: shared between the bluetooth server (Windows 8 Application) and the bluetoth client (Windows Phone Application)</span><br />   <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> BluetoothServiceDisplayName = <span style="color: #006080;">"My Bluetooth Rfcomm Service"</span>;<br />}</pre>
</div>
<p>The WindowsBluetoothRfcommClient is instantiated in the App constructor.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> App()<br />{<br />    <span style="color: #008000;">// Global handler for uncaught exceptions.</span><br />    UnhandledException += Application_UnhandledException;<br /><br />    <span style="color: #008000;">// Standard XAML initialization</span><br />    InitializeComponent();<br /><br />    <span style="color: #008000;">// Phone-specific initialization</span><br />    InitializePhoneApplication();<br /><br />    <span style="color: #008000;">// Language display initialization</span><br />    InitializeLanguage();<br /><br />    <span style="color: #008000;">// Show graphics profiling information while debugging.</span><br />    <span style="color: #0000ff;">if</span> (Debugger.IsAttached)<br />    {<br />        <span style="color: #008000;">// Display the current frame rate counters</span><br />        Application.Current.Host.Settings.EnableFrameRateCounter = <span style="color: #0000ff;">true</span>;<br /><br />        <span style="color: #008000;">// Show the areas of the app that are being redrawn in each frame.</span><br />        <span style="color: #008000;">//Application.Current.Host.Settings.EnableRedrawRegions = true;</span><br /><br />        <span style="color: #008000;">// Enable non-production analysis visualization mode,</span><br />        <span style="color: #008000;">// which shows areas of a page that are handed off to GPU with a colored overlay.</span><br />        <span style="color: #008000;">//Application.Current.Host.Settings.EnableCacheVisualization = true;</span><br /><br />        <span style="color: #008000;">// Prevent the screen from turning off while under the debugger by disabling</span><br />        <span style="color: #008000;">// the application's idle detection.</span><br />        <span style="color: #008000;">// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run</span><br />        <span style="color: #008000;">// and consume battery power when the user is not using the phone.</span><br />        PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;<br />    }<br />    <span style="color: #008000;">// Call BluetoothRfcommClient constructor</span><br />    BluetoothRfcommClient = <span style="color: #0000ff;">new</span> WindowsPhoneBluetoothRfcommClient(BluetoothServiceUuid, BluetoothServiceDisplayName, ApplicationConfiguration.AutoStart);<br />}</pre>
</div>
<p>&nbsp;&nbsp; <br />The WindowsBluetoothRfcommClient is Initialized in the method OnNavigatedTo of MainPage class.&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">protected</span> <span style="color: #0000ff;">override</span> async <span style="color: #0000ff;">void</span> OnNavigatedTo(NavigationEventArgs e)<br />{<br />    <span style="color: #008000;">// Check if BluetoothRfcommClient instance</span><br />    <span style="color: #0000ff;">if</span> ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient == <span style="color: #0000ff;">null</span>)<br />        <span style="color: #0000ff;">return</span>;<br />    <span style="color: #008000;">// Check BluetoothRfcommClient State</span><br />    <span style="color: #008000;">// If State == BluetoothClientState.Created, the bluetooth client didn't start</span><br />    <span style="color: #0000ff;">if</span> ((App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.GetState() == BluetoothClientState.Created)<br />    {<br />        BluetoothClientReturnCode r = await(App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.Initialization();<br />        <span style="color: #0000ff;">if</span> (r != BluetoothClientReturnCode.Success)<br />        {<br />            <span style="color: #0000ff;">if</span> ((r == BluetoothClientReturnCode.InitMissingCaps) || (r == BluetoothClientReturnCode.StartMissingCaps))<br />            {<br />                MessageBox.Show(<span style="color: #006080;">"bluetooth.rfcomm Capability missing in the application manifest"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />            }<br />            <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> ((r == BluetoothClientReturnCode.InitBluetoothOff) || (r == BluetoothClientReturnCode.StartBluetoothOff))<br />            {<br />                MessageBox.Show(<span style="color: #006080;">"Bluetooth is off, bluetooth is required to launch the client"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />                {<br />                    ConnectionSettingsTask connectionSettingsTask = <span style="color: #0000ff;">new</span> ConnectionSettingsTask();<br />                    connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;<br />                    connectionSettingsTask.Show();<br />                }<br />            }<br />            <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (r == BluetoothClientReturnCode.StartNotAdvertising)<br />            {<br />                MessageBox.Show(<span style="color: #006080;">"Bluetooth Advertising Error, restart the application"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />            }<br />            <span style="color: #0000ff;">else</span><br />            {<br />                MessageBox.Show(<span style="color: #006080;">"Error occurs while initializing the client"</span>, <span style="color: #006080;">"Windows Phone Bluetooth Client"</span>, MessageBoxButton.OK);<br />            }<br />            <span style="color: #0000ff;">return</span>;<br />        }<br />    }<br /><br />    <span style="color: #008000;">// Subscribe to CommandReceived, LogReceived and StateChanged</span><br />    (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.LogReceived += BluetoothRfcommClient_LogReceived;<br />    (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.CommandReceived += BluetoothRfcommClient_CommandReceived;<br />    (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.StateChanged += BluetoothRfcommClient_StateChanged;<br /><br />    <span style="color: #008000;">// Update IsConnected state</span><br />    UpdateIsConnectedAndImageLoaded();<br /><br />    <span style="color: #008000;">// Fill the list of Paired Devices </span><br />    FillListPairedDevices();<br /><br />}</pre>
</div>
<p><br />Once the WindowsBluetoothRfcommClient is initialized, the user can connect the application with the service running on a device running Windows 8.1 in that case the application calls the method ButtonConnect_Click.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">private</span> async <span style="color: #0000ff;">void</span> ButtonConnect_Click(<span style="color: #0000ff;">object</span> sender, RoutedEventArgs e)<br />{<br />    <span style="color: #0000ff;">if</span> ((ListDevices.SelectedIndex &gt;= 0) &amp;&amp; (ListDevices.SelectedIndex &lt; ListDevices.Items.Count))<br />    {<br />        BluetoothDevice d = ListDevices.Items[ListDevices.SelectedIndex] <span style="color: #0000ff;">as</span> BluetoothDevice;<br />        <span style="color: #0000ff;">if</span>(d!=<span style="color: #0000ff;">null</span>)<br />        {<br />            BluetoothClientReturnCode r = await (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.Connect(d);<br />            <span style="color: #0000ff;">if</span>(r == BluetoothClientReturnCode.Success)<br />            {<br />                <span style="color: #008000;">// Start Message loop</span><br />                ClearMessage();<br />                ClearFile();<br />            }<br />        }<br />    };<br />}</pre>
</div>
<p><br /> <br />When the WindowsBluetoothRfcommClient is connected, it can receive Bluetooth commands, in that case the WindowsBluetoothRfcommClient calls the method BluetoothRfcommClient_CommandReceived.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">void</span> BluetoothRfcommClient_CommandReceived(IBluetoothClient sender, BluetoothCommand args)<br />{<br />    AddLog(<span style="color: #006080;">"Command received "</span> + args.ToString());<br />    <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandMessage))<br />    {<br />        BluetoothCommandMessage bm = args <span style="color: #0000ff;">as</span> BluetoothCommandMessage;<br />        <span style="color: #0000ff;">if</span>(bm!=<span style="color: #0000ff;">null</span>)<br />            AddMessage(<span style="color: #006080;">"Message Received: "</span> + bm.MessageContent);<br />    }<br />    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (args.GetType() == <span style="color: #0000ff;">typeof</span>(BluetoothCommandPicture))<br />    {<br />        BluetoothCommandPicture bp = args <span style="color: #0000ff;">as</span> BluetoothCommandPicture;<br />        <span style="color: #0000ff;">if</span>(bp!=<span style="color: #0000ff;">null</span>)<br />            AddFile(<span style="color: #006080;">"File Received: "</span> + bp.PicturePath);<br />    }<br />}</pre>
</div>
<p><br />When the WindowsBluetoothRfcommClient is connected, the user can send Bluetooth commands as well, in that case the application calls the method ButtonSend_Click.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">private</span> async <span style="color: #0000ff;">void</span> ButtonSend_Click(<span style="color: #0000ff;">object</span> sender, RoutedEventArgs e)<br />{<br />    <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Message.Text))<br />    {<br />        BluetoothCommandMessage bm = <span style="color: #0000ff;">new</span> BluetoothCommandMessage();<br />        <span style="color: #0000ff;">if</span> (bm != <span style="color: #0000ff;">null</span>)<br />        {<br />            bm.CreateMessageCommand(Message.Text);<br />            BluetoothClientReturnCode r = await (App.Current <span style="color: #0000ff;">as</span> App).BluetoothRfcommClient.SendCommand(bm);<br />            <span style="color: #0000ff;">if</span> (r == BluetoothClientReturnCode.Success)<br />                AddMessage(<span style="color: #006080;">"Message Sent: "</span> + Message.Text);<br />        }<br />    }<br />}</pre>
</div>
<p><strong><span style="font-size: large;">Downloading the projects</span></strong></p>
<p>Download:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/6012.BluetoothRfcommWin8WP8.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39/6012.BluetoothRfcommWin8WP8.zip">C# (200 KB)</a> <br />Requires:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows 8.1, Windows Phone 8, Visual Studio 2013, Windows Phone 8 SDK <br />Last updated:&nbsp;&nbsp;&nbsp; 12/13/2013 <br />License:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/7824.license.rtf" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/7824.license.rtf">MS-LPL</a> <br />Technologies:&nbsp;&nbsp;&nbsp; Bluetooth, Rfcomm, StreamSocket, PeerFinder, C#, XAML <br />Topics:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows Store and Windows Phone App-to-App communication over Bluetooth</p>]]></content:encoded>
    </item>
    <item>
      <title>Application de lecture Audio/Vidéo pour Windows 8 et Windows Phone 8 utilisant les services de la classe HttpClient pour l’acquisition de la licence PlayReady</title>
      <link>https://docs.microsoft.com/archive/blogs/flecoqui/application-de-lecture-audiovido-pour-windows-8-et-windows-phone-8-utilisant-les-services-de-la-classe-httpclient-pour-lacquisition-de-la-licence-playready</link>
      <pubDate>Fri, 18 Oct 2013 06:30:00 GMT</pubDate>
      <dc:creator><![CDATA[FRED LE COQUIL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/flecoqui/2013/10/18/application-de-lecture-audiovido-pour-windows-8-et-windows-phone-8-utilisant-les-services-de-la-classe-httpclient-pour-lacquisition-de-la-licence-playready/</guid>
      <description><![CDATA[Introduction
Cet article d&eacute;crit comment cr&eacute;er des applications Windows 8 et Windows...]]></description>
      <content:encoded><![CDATA[<h1><strong>Introduction</strong></h1>
<p>Cet article d&eacute;crit comment cr&eacute;er des applications Windows 8 et Windows Phone 8 capables de jouer des vid&eacute;os Smooth Streaming prot&eacute;g&eacute;es par PlayReady.&nbsp; Avec les exemples d&rsquo;application fournis avec cet article l&rsquo;utilisateur peut d&eacute;finir: <br />- l&rsquo;URL de la vid&eacute;o Smooth Streaming, <br />- l&rsquo;URL utilis&eacute;e pour l&rsquo;acquisition de la licence PlayReady, <br />- le &laquo; Challenge Custom Data &raquo; transmis au serveur PlayReady pour acqu&eacute;rir la licence PlayReady. <br />Si l&rsquo;URL utilis&eacute;e pour l&rsquo;acquisition de licence n&rsquo;est pas d&eacute;finie, l&rsquo;application utilisera l&rsquo;URL inclue dans l&rsquo;en-t&ecirc;te de protection PlayReady du manifeste de la vid&eacute;o. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8054.image_4978D38F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8054.image_5F00_4978D38F.png"><img style="display: inline; background-image: none;" title="clip_image002" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2474.clip_image002_1E6533BB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2474.clip_5F00_image002_5F00_1E6533BB.png" alt="clip_image002" width="182" height="319" border="0" /></a> <br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1781.image_1398FFD7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1781.image_5F00_1398FFD7.png"><img style="display: inline; background-image: none;" title="clip_image004" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3718.clip_image004_149FCC43.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3718.clip_5F00_image004_5F00_149FCC43.png" alt="clip_image004" width="523" height="338" border="0" /></a></p>
<h2><strong>Les &eacute;tapes pour l&rsquo;acquisition d&rsquo;une licence PlayReady pour les applications du Windows Store:</strong></h2>
<p>Avant de d&eacute;crire comment le client PlayReady acquiert la licence PlayReady, quelques mots sur le m&eacute;canisme d&rsquo;individualisation. Chaque client PlayReady est associ&eacute; &agrave; un unique certificat et &agrave; une cl&eacute; unique, l&rsquo;installation de ce certificat et de cette cl&eacute; s&rsquo;appelle l&rsquo;individualisation. <br />De plus avant que le client PlayReady ne demande une licence pour d&eacute;crypter le contenu, il doit d&rsquo;abord d&eacute;terminer si le logiciel PlayReady ad hoc est install&eacute; sur l&rsquo;ordinateur de l&rsquo;utilisateur. Ce logiciel est appel&eacute; &ldquo;Individualized Black boX&rdquo; (appel&eacute; aussi IBX) et est le composant PlayReady client n&eacute;cessaire pour pouvoir jouer des contenus prot&eacute;g&eacute;s par PlayReady. Ce composant logiciel permet &agrave; l&rsquo;application cliente de demander et d&rsquo;utiliser une licence PlayReady. <br />Le client PlayReady pour les applications du Windows Store supporte l&rsquo;individualisation dynamique: l&rsquo;IBX est t&eacute;l&eacute;lcharg&eacute; depuis le serveur d&rsquo;individualisation. Dans votre application Windows Store vous pouvez impl&eacute;menter une demande d&rsquo;individualisation r&eacute;active ou une demande d&rsquo;individualisation pro-active.</p>
<ul>
<li>&middot; <strong>La demande pro-active d&rsquo;individualisation </strong>peut &ecirc;tre transmise apr&egrave;s l&rsquo;installation de l&rsquo;application ou quand l&rsquo;utilisateur lance l&rsquo;application pour la premi&egrave;re fois.</li>
<li>&middot; <strong>La demande r&eacute;active d&rsquo;individualisation </strong>est automatiquement pr&eacute;par&eacute;e par le client PlayReady quand l&rsquo;application est sur le point de jouer un contenu prot&eacute;g&eacute; par PlayReady et si l&rsquo;IBX n&rsquo;est pas d&eacute;j&agrave; install&eacute; sur l&rsquo;ordinateur.</li>
</ul>
<p>Le sch&eacute;ma ci-dessous d&eacute;crit l&rsquo;acquisition d&rsquo;une licence PlayReady pour jouer un contenu prot&eacute;g&eacute; par PlayReady avec la transmission d&rsquo;une requ&ecirc;te r&eacute;active d&rsquo;individualisation pr&eacute;alable:&nbsp; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4035.image_368DCB73.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4035.image_5F00_368DCB73.png"><img style="display: inline; background-image: none;" title="clip_image006" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8547.clip_image006_18ACAAC6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8547.clip_5F00_image006_5F00_18ACAAC6.png" alt="clip_image006" width="696" height="301" border="0" /></a></p>
<p>Le sch&eacute;ma ci-dessous d&eacute;crit l&rsquo;acquisition d&rsquo;une licence PlayReady pour jouer un contenu prot&eacute;g&eacute; par PlayReady sans transmission d&rsquo;une requ&ecirc;te d&rsquo;individualisation comme l&rsquo;IBX est d&eacute;j&agrave; install&eacute;:&nbsp; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5824.image_08396728.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5824.image_5F00_08396728.png"><img style="display: inline; background-image: none;" title="clip_image008" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7418.clip_image008_03BDB904.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7418.clip_5F00_image008_5F00_03BDB904.png" alt="clip_image008" width="710" height="251" border="0" /></a></p>
<p>Le sch&eacute;ma ci-dessous d&eacute;crit les &eacute;changes entre le client et le serveur quand l&rsquo;application joue un contenu prot&eacute;g&eacute; par PlayReady quand l&rsquo;IBX est d&eacute;j&agrave; install&eacute; et la licence PlayReady d&eacute;j&agrave; acquise:&nbsp; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7026.image_74AE9837.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7026.image_5F00_74AE9837.png"><img style="display: inline; background-image: none;" title="clip_image010" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8030.clip_image010_6C260B90.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8030.clip_5F00_image010_5F00_6C260B90.png" alt="clip_image010" width="719" height="278" border="0" /></a></p>
<h2><strong>Librairie Http Client: </strong></h2>
<p><strong> <br /></strong>Les exemples d&rsquo;application PlayReady fournis avec cet article sont bas&eacute;s sur Player Framework V1.2 et l&rsquo;acquisition des licences PlayReady est bas&eacute;e sur la classe HttpClient pour les deux plates-formes Windows et Windows Phone.&nbsp;&nbsp; <br />HttpClient fait partie int&eacute;grante de NET Framework 4.5 et des applications Windows Store et fournit aux d&eacute;veloppeurs la possibilit&eacute; d&rsquo;&eacute;crire tr&egrave;s facilement des applications se connectant &agrave; des services Internet incluant les services bas&eacute;s sur des APIs REST. HttpClient est maintenant disponible pour les d&eacute;veloppeurs Windows Phone si vous installez le package Nuget : &laquo; Microsoft http Client Libraries &raquo; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8780.image_6740D0F7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8780.image_5F00_6740D0F7.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image012" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4152.clip_image012_3B928DD8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4152.clip_5F00_image012_5F00_3B928DD8.png" alt="clip_image012" width="244" height="49" border="0" /></a></p>
<h1><strong>G&eacute;n&eacute;rer les exemples d&rsquo;application </strong></h1>
<p>Pour g&eacute;n&eacute;rer les exemples d&rsquo;application PlayReady pour Windows Store et Windows Phone vous devez disposer: <br />1. d&rsquo;un ordinateur sous Windows 8, <br />2. du Visual Studio 2012, <br />3. du Windows Phone 8 SDK.</p>
<p>Pour g&eacute;n&eacute;rer l&rsquo;application pour Windows Store vous devez installer: <br />1. Le <a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">Smooth Streaming Client SDK for Windows 8</a> <br />2. Le <a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">PlayReady Client SDK for Windows Store Apps</a> <br />3. Le <a href="http://playerframework.codeplex.com/releases/view/105214">Player Framework for Windows 8 and Windows Phone 8 (v1.2)</a>.</p>
<p>Pour g&eacute;n&eacute;rer l&rsquo;application pour Windows Phone vous devez installer: <br />1. Le <a href="http://www.microsoft.com/en-us/download/details.aspx?id=29940">Microsoft Smooth Streaming Client 2.0 RTW</a> <br />2. Le <a href="http://playerframework.codeplex.com/releases/view/105214">Player Framework for Windows 8 and Windows Phone 8 (v1.2)</a>. <br />L&rsquo;application pour Windows Phone 8 est livr&eacute;e avec les packages Nuget suivants: <br />1. <a href="http://blogs.msdn.com/b/bclteam/p/httpclient.aspx">Microsoft HTTP Client Libraries: Microsof.Net.Http&nbsp; </a> <br />2. <a href="http://blogs.msdn.com/b/bclteam/p/bcl.aspx">Microsoft BCL Portability Pack: Microsoft.BCL </a> <br />3. <a href="http://blogs.msdn.com/b/bclteam/p/bclbuild.aspx">Microsoft BCL Build Components: Microsoft.BCL.Build </a></p>
<h2><strong>Installer le Microsoft Smooth Streaming Client SDK pour Windows 8 </strong></h2>
<p>1. T&eacute;l&eacute;chargez le SDK client Smooth Streaming depuis ce lien: <br /><a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a> <br />2. Double-cliquez sur le fichier VSIX pour lancer l&rsquo;installation <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1780.image_5995C702.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1780.image_5F00_5995C702.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image014" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8484.clip_image014_205CC588.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8484.clip_5F00_image014_5F00_205CC588.png" alt="clip_image014" width="244" height="26" border="0" /></a> <br />3. Sur la bo&icirc;te de dialogue &laquo; VSIX Installer &raquo; cliquez sur le bouton <strong>Install </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8726.image_0D604E05.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8726.image_5F00_0D604E05.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image016" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0474.clip_image016_6D8CBF13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0474.clip_5F00_image016_5F00_6D8CBF13.png" alt="clip_image016" width="244" height="199" border="0" /></a> <br />4. Apr&egrave;s quelques secondes, le SDK est install&eacute;. Cliquez sur le bouton <strong>Close </strong>pour fermer la bo&icirc;te de dialogue &laquo; VSIX Installer &raquo;. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2845.image_36FBCB4B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2845.image_5F00_36FBCB4B.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image018" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0334.clip_image018_4F42081D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0334.clip_5F00_image018_5F00_4F42081D.png" alt="clip_image018" width="244" height="197" border="0" /></a></p>
<h2><strong>Installer le Microsoft PlayReady Client SDK for Windows Store Apps </strong></h2>
<p>1. T&eacute;l&eacute;chargez le SDK PlayReady Client depuis ce lien: <br /><a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483</a> <br />2. Double-cliquez sur le fichier VSIX pour lancer l&rsquo;installation <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2627.image_08021A23.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2627.image_5F00_08021A23.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image020" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2500.clip_image020_340C3FCD.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2500.clip_5F00_image020_5F00_340C3FCD.png" alt="clip_image020" width="244" height="28" border="0" /></a> <br />3. Sur la bo&icirc;te de dialogue &laquo; VSIX Installer &raquo; cliquez sur le bouton <strong>Install </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4442.image_0DE1DF1E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4442.image_5F00_0DE1DF1E.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image022" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5670.clip_image022_534EE6A0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5670.clip_5F00_image022_5F00_534EE6A0.png" alt="clip_image022" width="244" height="186" border="0" /></a> <br />4. Apr&egrave;s quelques secondes, le SDK est install&eacute;. Cliquez sur le bouton <strong>Close </strong>pour fermer la bo&icirc;te de dialogue &laquo; VSIX Installer &raquo;. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6708.image_4E98FCD1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6708.image_5F00_4E98FCD1.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image024" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8244.clip_image024_37ACEB5B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8244.clip_5F00_image024_5F00_37ACEB5B.png" alt="clip_image024" width="244" height="186" border="0" /></a></p>
<h2><strong>Installer le Microsoft Smooth Streaming Client 2.0 RTW </strong></h2>
<p>1. T&eacute;l&eacute;chargez le SDK Smooth Streaming Client depuis ce ligne: <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=29940">http://www.microsoft.com/en-us/download/details.aspx?id=29940</a> <br />2. Double-cliquez sur le fichier MSI pour lancer l&rsquo;installation <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3007.image_5CF99065.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3007.image_5F00_5CF99065.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image026" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3301.clip_image026_6E89D052.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3301.clip_5F00_image026_5F00_6E89D052.png" alt="clip_image026" width="244" height="31" border="0" /></a> <br />3. Sur la bo&icirc;te de dialogue &laquo; Microsoft Smooth Streaming Client 2.0 Setup &raquo; cliquez sur le bouton <strong>Next </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0020.image_39CEB664.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0020.image_5F00_39CEB664.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image028" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1667.clip_image028_22BDF999.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1667.clip_5F00_image028_5F00_22BDF999.png" alt="clip_image028" width="244" height="194" border="0" /></a> <br />4. Sur la bo&icirc;te de dialogue &laquo; Microsoft Smooth Streaming Client 2.0 Setup &raquo; cliquez sur le bouton <strong>Next </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3051.image_6A1D3D2D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3051.image_5F00_6A1D3D2D.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image030" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1185.clip_image030_047342A3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1185.clip_5F00_image030_5F00_047342A3.png" alt="clip_image030" width="244" height="193" border="0" /></a> <br />5. Sur la bo&icirc;te de dialogue &laquo; Microsoft Smooth Streaming Client 2.0 Setup &raquo; cliquez sur le bouton <strong>Next </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1638.image_77D627FA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1638.image_5F00_77D627FA.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image032" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8154.clip_image032_01CD17A3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8154.clip_5F00_image032_5F00_01CD17A3.png" alt="clip_image032" width="244" height="192" border="0" /></a> <br />6. Sur la bo&icirc;te de dialogue &laquo; Microsoft Smooth Streaming Client 2.0 Setup &raquo; cliquez sur le bouton <strong>Install </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2804.image_68C46A82.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2804.image_5F00_68C46A82.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image034" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0160.clip_image034_23B87A27.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0160.clip_5F00_image034_5F00_23B87A27.png" alt="clip_image034" width="244" height="194" border="0" /></a> <br />7. Sur la bo&icirc;te de dialogue &laquo; Microsoft Smooth Streaming Client 2.0 Setup &raquo; cliquez sur le bouton <strong>Finish </strong> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3286.image_1673B6B8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3286.image_5F00_1673B6B8.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image036" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8446.clip_image036_73912F63.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8446.clip_5F00_image036_5F00_73912F63.png" alt="clip_image036" width="244" height="192" border="0" /></a></p>
<h2><strong>Installer le Player Framework pour Windows 8 et Windows Phone 8 (v1.2) </strong></h2>
<p>1. T&eacute;l&eacute;chargez le Player Framework depuis ce lien: <br /><a href="http://playerframework.codeplex.com/releases/view/105214">http://</a><a href="http://playerframework.codeplex.com/releases/view/105214">playerframework.codeplex.com/releases/view/105214</a> <br />2. Double-cliquez sur le fichier VSIX pour lancer l&rsquo;installation <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5305.image_0F19046E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5305.image_5F00_0F19046E.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image038" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2260.clip_image038_5546786D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2260.clip_5F00_image038_5F00_5546786D.png" alt="clip_image038" width="244" height="31" border="0" /></a> <br />3. On the VSIX Installer dialog box click on the <strong>Install </strong>button <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6864.image_4C3F50A4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6864.image_5F00_4C3F50A4.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image040" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8080.clip_image040_3767F46C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8080.clip_5F00_image040_5F00_3767F46C.png" alt="clip_image040" width="244" height="199" border="0" /></a> <br />4. Apr&egrave;s quelques secondes, le SDK est install&eacute;. Cliquez sur le bouton <strong>Close </strong> pour fermer la bo&icirc;te de dialogue. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4810.image_1AD5FDB3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4810.image_5F00_1AD5FDB3.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image042" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4111.clip_image042_5BFC12A1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4111.clip_5F00_image042_5F00_5BFC12A1.png" alt="clip_image042" width="244" height="185" border="0" /></a></p>
<h2><strong>Ouvrir et G&eacute;n&eacute;rer la solution </strong></h2>
<p>D&egrave;s que les SDKs sont install&eacute;s, vous pouvez ouvrir le fichier Solution pour g&eacute;n&eacute;rer les applications pour Windows Store et Windows Phone.<strong></strong></p>
<p>1. D&eacute;marrez Visual Studio 2012 et s&eacute;lectionnez <strong>File &gt; Open &gt; Project/Solution</strong>.</p>
<p>2. D&eacute;placez-vous dans le r&eacute;pertoire dans lequel vous avez d&eacute;compress&eacute; le fichier ZIP et double-cliquez sur le fichier solution Microsoft Visual Studio. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2061.image_0205B9DB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2061.image_5F00_0205B9DB.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image044" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0160.clip_image044_4FFA226D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0160.clip_5F00_image044_5F00_4FFA226D.png" alt="clip_image044" width="182" height="244" border="0" /></a></p>
<p>3. V&eacute;rifiez qu&rsquo;il n&rsquo;y a pas d&rsquo;avertissement pour les r&eacute;f&eacute;rences Windows 8. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8737.image_4572DC9F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8737.image_5F00_4572DC9F.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image046" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0513.clip_image046_49D7F734.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0513.clip_5F00_image046_5F00_49D7F734.png" alt="clip_image046" width="244" height="140" border="0" /></a></p>
<p>4. V&eacute;rifiez qu&rsquo;il n&rsquo;y a pas d&rsquo;avertissement pour les r&eacute;f&eacute;rences Windows Phone 8. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1261.image_64B81423.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1261.image_5F00_64B81423.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image048" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5327.clip_image048_597A92F6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5327.clip_5F00_image048_5F00_597A92F6.png" alt="clip_image048" width="244" height="162" border="0" /></a></p>
<p>5. Les deux projets utilisent un code source C# commun pour l&rsquo;acquisition de la license PlayReady : CommonLicenseRequest.cs <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7418.image_1CF91BED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7418.image_5F00_1CF91BED.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image050" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2046.clip_image050_0218FEFE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2046.clip_5F00_image050_5F00_0218FEFE.png" alt="clip_image050" width="155" height="244" border="0" /></a></p>
<p>6. Le fichier CommonLicenseRequest.cs a &eacute;t&eacute; partag&eacute; entre les deux projets en utilisant l&rsquo;option <strong>Add As Link </strong>pour l&rsquo;ajout d&rsquo;&eacute;l&eacute;ment existant dans le projet. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3286.image_57E2DF67.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3286.image_5F00_57E2DF67.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image052" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3730.clip_image052_11BB9AC0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3730.clip_5F00_image052_5F00_11BB9AC0.png" alt="clip_image052" width="244" height="162" border="0" /></a></p>
<p>7. Appuyez sur F7 ou utilisez <strong>Build &gt; Build Solution</strong> pour g&eacute;n&eacute;rer les exemples.</p>
<h1><strong>Exploration du projet de l&rsquo;application Windows Store </strong></h1>
<p>Le projet de l&rsquo;application Windows Store est un projet XAML.&nbsp; <br /> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6786.image_4700CC28.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6786.image_5F00_4700CC28.png"><img style="margin: 0px; display: inline; background-image: none;" title="clip_image054" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8053.clip_image054_48987FB7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8053.clip_5F00_image054_5F00_48987FB7.png" alt="clip_image054" width="244" height="200" border="0" /></a></p>
<ul>
<li><strong><em>MainPage.cs</em></strong> contient le code source de la page principale.</li>
<li><strong><em>CommonLicenseRequest.cs</em></strong> contient le code source de la classe commune utilisant HttpClient pour l&rsquo;acquisition de la licence PlayReady.</li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contient le code source pour stocker les param&egrave;tres de l&rsquo;application.</li>
</ul>
<p>Les &eacute;v&eacute;nements PlayReady et Smooth Streaming sont enregistr&eacute;s dans le constructeur de la classe MainPage.&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> MainPage()<br />{<br />    <span style="color: #0000ff;">this</span>.InitializeComponent();<br /><br />    <span style="color: #008000;">// Add Plugins</span><br />    Player.Plugins.Add(<span style="color: #0000ff;">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin());<br /><br />    <span style="color: #008000;">// Init PlayReady Protection Manager</span><br />    var protectionManager = <span style="color: #0000ff;">new</span> MediaProtectionManager();<br />    Windows.Foundation.Collections.PropertySet cpSystems = <span style="color: #0000ff;">new</span> Windows.Foundation.Collections.PropertySet();<br />    cpSystems.Add(<span style="color: #006080;">"{F4637010-03C3-42CD-B932-B48ADF3A6A54}"</span>, <span style="color: #006080;">"Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput"</span>); <span style="color: #008000;">//Playready</span><br />    protectionManager.Properties.Add(<span style="color: #006080;">"Windows.Media.Protection.MediaProtectionSystemIdMapping"</span>, cpSystems);<br />    protectionManager.Properties.Add(<span style="color: #006080;">"Windows.Media.Protection.MediaProtectionSystemId"</span>, <span style="color: #006080;">"{F4637010-03C3-42CD-B932-B48ADF3A6A54}"</span>);<br />    <span style="color: #0000ff;">this</span>.Player.ProtectionManager = protectionManager;<br />    <span style="color: #008000;">// PlayReady Events registration</span><br />    Player.ProtectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed;<br />    Player.ProtectionManager.ServiceRequested += ProtectionManager_ServiceRequested;<br /><br /><br />    <span style="color: #008000;">// Init Smooth Streaming Handler</span><br />    Windows.Media.MediaExtensionManager extensions = <span style="color: #0000ff;">new</span> Windows.Media.MediaExtensionManager();<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".ism"</span>, <span style="color: #006080;">"text/xml"</span>);<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".isml"</span>, <span style="color: #006080;">"text/xml"</span>);<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".ism"</span>, <span style="color: #006080;">"application/vnd.ms-ss"</span>);<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".isml"</span>, <span style="color: #006080;">"application/vnd.ms-ss"</span>);<br />    extensions.RegisterSchemeHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler"</span>, <span style="color: #006080;">"ms-sstr:"</span>);<br />    Player.MediaExtensionManager = extensions;</pre>
</div>
<p>La m&eacute;thode ProtectionManager_ServiceRequested est appel&eacute;e &agrave; chaque demande d&rsquo;acquisition de licence ou &agrave; chaque demande d&rsquo;invidualisation. S&rsquo;il s&rsquo;agit d&rsquo;une demande d&rsquo;individualisation la m&eacute;thode ReactiveIndivRequest est appel&eacute;e. S&rsquo;il s&rsquo;agit d&rsquo;une demande d&rsquo;acquisition de licence la m&eacute;thode LicenseAcquisitionRequest est appel&eacute;e.&nbsp;&nbsp;&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;">async <span style="color: #0000ff;">void</span> ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent)<br />{<br />    LogMessage(<span style="color: #006080;">"ProtectionManager ServiceRequested"</span>);<br />    <span style="color: #0000ff;">if</span> (srEvent.Request <span style="color: #0000ff;">is</span> PlayReadyIndividualizationServiceRequest)<br />    {<br />        PlayReadyIndividualizationServiceRequest IndivRequest = srEvent.Request <span style="color: #0000ff;">as</span> PlayReadyIndividualizationServiceRequest;<br />        <span style="color: #0000ff;">bool</span> bResultIndiv = await ReactiveIndivRequest(IndivRequest, srEvent.Completion);<br />    }<br />    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (srEvent.Request <span style="color: #0000ff;">is</span> PlayReadyLicenseAcquisitionServiceRequest)<br />    {<br />        PlayReadyLicenseAcquisitionServiceRequest licenseRequest = srEvent.Request <span style="color: #0000ff;">as</span> PlayReadyLicenseAcquisitionServiceRequest;<br />        LicenseAcquisitionRequest(licenseRequest, srEvent.Completion, PlayReadyLicenseUrl, PlayReadyChallengeCustomData);<br />    }<br />}</pre>
</div>
<p><br />Si l&rsquo;URL utilis&eacute;e pour l&rsquo;acquisition de licence PlayReady n&rsquo;est pas pr&eacute;cis&eacute;e par l&rsquo;utilisateur, l&rsquo;application utilisera l&rsquo;URL d&eacute;finie dans l&rsquo;ent&ecirc;te de protection PlayReady du manifeste de la vid&eacute;o, la m&eacute;thode LicenseAcquisitionRequest appelle licenseRequest.BeginServiceRequest. Si l&rsquo;URL utilis&eacute;e pour l&rsquo;acquisition de licence PlayReady est pr&eacute;cis&eacute;e par l&rsquo;utilisateur, la m&eacute;thode LicenseAcquisitionRequest cr&eacute;e un challenge PlayReady en utilisant la valeur du champ ChallengeCustomData et appelle la m&eacute;thode licenseAcquisition.AcquireLicense en utilisant l&rsquo;URL d&eacute;finie par l&rsquo;utilisateur.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">/// &lt;summary&gt;</span><br /><span style="color: #008000;">/// Invoked to acquire the PlayReady License</span><br /><span style="color: #008000;">/// &lt;/summary&gt;</span><br />async <span style="color: #0000ff;">void</span> LicenseAcquisitionRequest(PlayReadyLicenseAcquisitionServiceRequest licenseRequest, MediaProtectionServiceCompletion CompletionNotifier, <span style="color: #0000ff;">string</span> Url, <span style="color: #0000ff;">string</span> ChallengeCustomData)<br />{<br />    <span style="color: #0000ff;">bool</span> bResult = <span style="color: #0000ff;">false</span>;<br />    <span style="color: #0000ff;">string</span> ExceptionMessage = <span style="color: #0000ff;">string</span>.Empty;<br /><br />    <span style="color: #0000ff;">try</span><br />    {<br />        <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Url))<br />        {<br />            LogMessage(<span style="color: #006080;">"ProtectionManager PlayReady Manual License Acquisition Service Request in progress - URL: "</span> + Url);<br /><br />            <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(ChallengeCustomData))<br />            {<br />                System.Text.UTF8Encoding encoding = <span style="color: #0000ff;">new</span> System.Text.UTF8Encoding();<br />                <span style="color: #0000ff;">byte</span>[] b = encoding.GetBytes(ChallengeCustomData);<br />                licenseRequest.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);<br />            }<br /><br />            PlayReadySoapMessage soapMessage = licenseRequest.GenerateManualEnablingChallenge(); <br />            <br />            <span style="color: #0000ff;">byte</span>[] messageBytes = soapMessage.GetMessageBody();<br />            HttpContent httpContent = <span style="color: #0000ff;">new</span> ByteArrayContent(messageBytes);<br /><br />            IPropertySet propertySetHeaders = soapMessage.MessageHeaders;<br />            <span style="color: #0000ff;">foreach</span> (<span style="color: #0000ff;">string</span> strHeaderName <span style="color: #0000ff;">in</span> propertySetHeaders.Keys)<br />            {<br />                <span style="color: #0000ff;">string</span> strHeaderValue = propertySetHeaders[strHeaderName].ToString();<br /><br />                <span style="color: #008000;">// The Add method throws an ArgumentException try to set protected headers like "Content-Type"</span><br />                <span style="color: #008000;">// so set it via "ContentType" property</span><br />                <span style="color: #0000ff;">if</span> (strHeaderName.Equals(<span style="color: #006080;">"Content-Type"</span>, StringComparison.OrdinalIgnoreCase))<br />                    httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse(strHeaderValue);<br />                <span style="color: #0000ff;">else</span><br />                    httpContent.Headers.Add(strHeaderName.ToString(), strHeaderValue);<br />            }<br />            CommonLicenseRequest licenseAcquision = <span style="color: #0000ff;">new</span> CommonLicenseRequest();<br />            HttpContent responseHttpContent = await licenseAcquision.AcquireLicense(<span style="color: #0000ff;">new</span> Uri(Url), httpContent);<br />            <span style="color: #0000ff;">if</span> (responseHttpContent != <span style="color: #0000ff;">null</span>)<br />            {<br />                Exception exResult = licenseRequest.ProcessManualEnablingResponse(await responseHttpContent.ReadAsByteArrayAsync());<br />                <span style="color: #0000ff;">if</span> (exResult != <span style="color: #0000ff;">null</span>)<br />                {<br />                    <span style="color: #0000ff;">throw</span> exResult;<br />                }<br />                bResult = <span style="color: #0000ff;">true</span>;<br />            }<br />            <span style="color: #0000ff;">else</span><br />                ExceptionMessage = licenseAcquision.GetLastErrorMessage();<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            LogMessage(<span style="color: #006080;">"ProtectionManager PlayReady License Acquisition Service Request in progress - URL: "</span> + licenseRequest.Uri.ToString());<br />            await licenseRequest.BeginServiceRequest();<br />            bResult = <span style="color: #0000ff;">true</span>;<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        ExceptionMessage = e.Message;<br />    }<br />    <br />    <span style="color: #0000ff;">if</span> (bResult == <span style="color: #0000ff;">true</span>)<br />            LogMessage(!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Url) ? <span style="color: #006080;">"ProtectionManager Manual PlayReady License Acquisition Service Request successful"</span>:<br />                <span style="color: #006080;">"ProtectionManager PlayReady License Acquisition Service Request successful"</span>);<br />    <span style="color: #0000ff;">else</span><br />        LogMessage(!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Url) ? <span style="color: #006080;">"ProtectionManager Manual PlayReady License Acquisition Service Request failed: "</span>+ExceptionMessage :<br />            <span style="color: #006080;">"ProtectionManager PlayReady License Acquisition Service Request failed: "</span> + ExceptionMessage);<br />    CompletionNotifier.Complete(bResult);<br />}</pre>
</div>
<p>The method AcquireLicense sends the PlayReady license Http Request to the PlayReady server. The request contains the PlayReady challenge and add http headers. The method PostAsync of class HttpClient is used to transmit this request.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">/// &lt;summary&gt;</span><br /> <span style="color: #008000;">/// Invoked to acquire the PlayReady license.</span><br /> <span style="color: #008000;">/// &lt;/summary&gt;</span><br /> <span style="color: #008000;">/// &lt;param name="licenseServerUri"&gt;License Server URI to retrieve the PlayReady license.&lt;/param&gt;</span><br /> <span style="color: #008000;">/// &lt;param name="httpRequestContent"&gt;HttpContent including the Challenge transmitted to the PlayReady server.&lt;/param&gt;</span><br /> <span style="color: #0000ff;">public</span> async <span style="color: #0000ff;">virtual</span> Task&lt;HttpContent&gt; AcquireLicense(Uri licenseServerUri, HttpContent httpRequestContent)<br /> {<br />     <span style="color: #0000ff;">try</span><br />     {<br />         HttpClient httpClient = <span style="color: #0000ff;">new</span> HttpClient();<br />         httpClient.DefaultRequestHeaders.Add(<span style="color: #006080;">"msprdrm_server_redirect_compat"</span>, <span style="color: #006080;">"false"</span>);<br />         httpClient.DefaultRequestHeaders.Add(<span style="color: #006080;">"msprdrm_server_exception_compat"</span>, <span style="color: #006080;">"false"</span>);<br /><br />         HttpResponseMessage response = await httpClient.PostAsync(licenseServerUri, httpRequestContent);<br />         response.EnsureSuccessStatusCode();<br /><br />         <span style="color: #0000ff;">if</span> (response.StatusCode == HttpStatusCode.OK)<br />         {<br />             _lastErrorMessage = <span style="color: #0000ff;">string</span>.Empty;<br />             <span style="color: #0000ff;">return</span> response.Content;<br />         }<br />         <span style="color: #0000ff;">else</span><br />         {<br />             _lastErrorMessage = <span style="color: #006080;">"AcquireLicense - Http Response Status Code: "</span> + response.StatusCode.ToString();<br />         }<br />     }<br />     <span style="color: #0000ff;">catch</span> (Exception exception)<br />     {<br />         _lastErrorMessage = exception.Message;<br />         <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;<br />     }<br />     <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;<br /> }</pre>
</div>
<p>&nbsp;</p>
<h1><strong>Exploration du projet de l&rsquo;application Windows Phone 8 </strong><strong></strong></h1>
<p>Le projet de l&rsquo;application Windows Phone 8 est un projet XAML.&nbsp; <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3000.image_228E4FBB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3000.image_5F00_228E4FBB.png"><img style="display: inline; background-image: none;" title="clip_image056" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7737.clip_image056_45F254B7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7737.clip_5F00_image056_5F00_45F254B7.png" alt="clip_image056" width="244" height="232" border="0" /></a></p>
<ul>
<li>&middot; <strong><em>MainPage.cs</em></strong> contient le code source de la page principale.</li>
<li>&middot; <strong><em>CommonLicenseRequest.cs</em></strong> contient le code source commun pour l&rsquo;acquisition de la licence PlayReady en utilisant la classe HttpClient.&nbsp;&nbsp;</li>
<li>&middot; <strong><em>ApplicationConfiguration.cs</em></strong> contient le code source utilis&eacute; pour stocker et restaurer les param&egrave;tres de l&rsquo;application.&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li>&middot; <strong><em>WindowsPhoneLicenseAcquisition.cs</em></strong> contient le code source de la classe WindowsPhoneLicenseAcquisition d&eacute;riv&eacute;e de la classe PlayReady LicenseAcquirer utilis&eacute;e pour l&rsquo;acquisition de licence PlayReady.</li>
</ul>
<p>Dans le constructeur de la page principale, les &eacute;v&eacute;nements PlayReady sont enregistr&eacute;s par la classe WindowsPhoneLicenseAcquisition.&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">//Add Smooth Streaming and Caption plugins </span><br />Microsoft.PlayerFramework.Adaptive.AdaptivePlugin AP = <span style="color: #0000ff;">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br />Player.Plugins.Add(AP);<br />Player.Plugins.Add(<span style="color: #0000ff;">new</span> Microsoft.PlayerFramework.TimedText.CaptionsPlugin());<br />Microsoft.PlayerFramework.Adaptive.AdaptivePlugin ap = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().FirstOrDefault();<br /><span style="color: #0000ff;">if</span> (ap != <span style="color: #0000ff;">null</span>)<br />{<br />    ap.MediaElement.LicenseAcquirer = <span style="color: #0000ff;">new</span> WindowsPhoneLicenseAcquisition(LogMessage);<br />    ap.MediaElement.MediaFailed += Player_MediaFailed;<br />}</pre>
</div>
<p>La m&eacute;thode OnAcquireLicense est appel&eacute;e pour acqu&eacute;rir la licence PlayReady. Si LicenseServerUriOverride est d&eacute;fini il s&rsquo;agit d&rsquo;une acquisition de licence manuelle. La m&eacute;thode converti la Stream qui contient le challenge PlayReady en un objet HttpContent avant d&rsquo;appeler _licenseRequest.AcquireLicense qui est la m&eacute;thode commune pour l&rsquo;acquisition de licence PlayReady pour les applications Windows Phone et Windows Store.</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">protected</span> async <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> OnAcquireLicense(System.IO.Stream licenseChallenge, Uri licenseServerUri)<br />{<br /><br />    <span style="color: #008000;">// Need to resolve the URI for the License Server -- make sure it is correct</span><br />    <span style="color: #008000;">// and store that correct URI as resolvedLicenseServerUri.</span><br />    Uri resolvedLicenseServerUri;<br />    <span style="color: #0000ff;">if</span> (LicenseServerUriOverride == <span style="color: #0000ff;">null</span>)<br />    {<br />        <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition Service Request in progress - URL: "</span> + licenseServerUri.ToString());<br />        resolvedLicenseServerUri = licenseServerUri;<br />    }<br />    <span style="color: #0000ff;">else</span><br />    {<br />        <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady Manual License Acquisition Service Request in progress - URL: "</span> + LicenseServerUriOverride.ToString());<br />        resolvedLicenseServerUri = LicenseServerUriOverride;<br />    }<br /><br />    <span style="color: #0000ff;">try</span><br />    {<br />        StreamReader sr = <span style="color: #0000ff;">new</span> StreamReader(licenseChallenge);<br />        <span style="color: #0000ff;">string</span> challengeString = sr.ReadToEnd();<br />        Byte[] Data = System.Text.Encoding.UTF8.GetBytes(challengeString);<br />        HttpContent httpRequestContent = <span style="color: #0000ff;">new</span> ByteArrayContent(Data);<br /><br />        httpRequestContent.Headers.ContentType = <span style="color: #0000ff;">new</span> MediaTypeHeaderValue(<span style="color: #006080;">"text/xml"</span>);<br />        httpRequestContent.Headers.ContentLength = Data.Length;<br /><br /><br />        HttpContent httpResponseContent = await _licenseRequest.AcquireLicense(resolvedLicenseServerUri, httpRequestContent);<br />        <span style="color: #0000ff;">if</span> (httpResponseContent != <span style="color: #0000ff;">null</span>)<br />        {<br />            Stream srep = await httpResponseContent.ReadAsStreamAsync();<br />            <span style="color: #0000ff;">if</span> (srep != <span style="color: #0000ff;">null</span>)<br />            {<br />                <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition successful."</span>);<br />                SetLicenseResponse(srep);<br />                <span style="color: #0000ff;">return</span>;<br />            }<br />        }<br />        <span style="color: #0000ff;">else</span><br />            <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition failed. Exception: "</span> + _licenseRequest.GetLastErrorMessage());<br />    }<br />    <span style="color: #0000ff;">catch</span>(Exception e)<br />    {<br />        <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition failed. Exception: "</span> + e.Message);<br />    }<br />    <br />    <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition failed."</span>);<br />    <span style="color: #008000;">// Call CancelAsync </span><br />    <span style="color: #008000;">// In that case the MediaElement transitions from the AcquiringLicense state to the error state and</span><br />    <span style="color: #008000;">// calling this method causes playback to fail with a "license acquisition failure" error.</span><br />    <span style="color: #0000ff;">try</span><br />    {<br />        CancelAsync();<br />    }<br />    <span style="color: #0000ff;">catch</span><br />    {<br />    }<br /><br />}</pre>
</div>
<h1><strong>Tests des applications Windows Store and Windows Phone </strong></h1>
<p>Par d&eacute;faut les applications essaieront de jouer le contenu Smooth Streaming suivant: <br /><a href="http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest">http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest</a> <br />en utilisant l&rsquo;URL suivante pour l&rsquo;acquisition de licence: <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1">http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1</a> <br />Cette URL renverra une licence non persistante. A chaque tentative de lecture du contenu smooth streaming, une requ&ecirc;te sera transmise au serveur PlayReady. <br />Par d&eacute;faut, le challenge custom data est vide, vous devez modifier ce champ si le serveur PlayReady attend un challenge custom data sp&eacute;cifique. <br /><strong>Licence persistante:</strong> <br />Si vous utilisez l&rsquo;URL suivante, la licence retourn&eacute;e par le serveur PlayReady sera persistante: <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx">http://playready.directtaps.net/pr/svc/rightsmanager.asmx</a></p>
<h1><strong>T&eacute;l&eacute;chargement des projets</strong></h1>
<p>T&eacute;l&eacute;chargement:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/3162.PlayReadyPlayerforWin8WP8.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/3162.PlayReadyPlayerforWin8WP8.zip">C# (3.3 MB)</a> <br />Pr&eacute;requis:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows 8, Visual Studio 2012, Windows Phone 8 SDK <br />Derni&egrave;re modification:&nbsp;&nbsp;&nbsp; 10/18/2013 <br />Licence:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/7824.license.rtf" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/7824.license.rtf">MS-LPL</a> <br />Technologies:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PlayReady, Smooth Streaming, PlayerFramework, C#, XAML <br />Th&egrave;me:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PlayReady Smooth Streaming Player for Windows Phone and Windows Store</p>]]></content:encoded>
    </item>
    <item>
      <title>Audio/Video Player for Windows 8 and Windows Phone 8 using HttpClient to acquire a PlayReady License</title>
      <link>https://docs.microsoft.com/archive/blogs/flecoqui/audiovideo-player-for-windows-8-and-windows-phone-8-using-httpclient-to-acquire-a-playready-license</link>
      <pubDate>Mon, 14 Oct 2013 09:01:00 GMT</pubDate>
      <dc:creator><![CDATA[FRED LE COQUIL]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/flecoqui/2013/10/14/audiovideo-player-for-windows-8-and-windows-phone-8-using-httpclient-to-acquire-a-playready-license/</guid>
      <description><![CDATA[Introduction


This article describes how to create Windows 8 and Windows Phone 8 applications...]]></description>
      <content:encoded><![CDATA[<blockquote>
<h1>Introduction</h1>
</blockquote>
<blockquote>
<p>This article describes how to create Windows 8 and Windows Phone 8 applications playing Smooth Streaming assets protected with PlayReady.&nbsp; With the sample c# applications provided with this article, the user can define: <br />- the URL of the Smooth Streaming asset you want to play, <br />- the URL used for the PlayReady license acquisition, <br />- the Challenge Custom Data transmitted to the PlayReady server to acquire the license. <br />If the URL used for the license acquisition is empty, the player will use the license acquisition URL included in the PlayReady protection header (if available). <br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8054.image_4978D38F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8054.image_5F00_4978D38F.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7652.image_thumb_6851D81E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7652.image_5F00_thumb_5F00_6851D81E.png" alt="image" width="194" height="344" border="0" /></a>&nbsp;&nbsp;&nbsp; <br />&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1781.image_1398FFD7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1781.image_5F00_1398FFD7.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1323.image_thumb_20293DA4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1323.image_5F00_thumb_5F00_20293DA4.png" alt="image" width="539" height="347" border="0" /></a></p>
<h2><strong>Steps to acquire a PlayReady license for Windows Store Applications</strong></h2>
<p>Before describing how the PlayReady client acquires the PlayReady license, some words about the Individualization. Every PlayReady client has a unique digital certificate and key, the installation of the certificate and the key is called Individualization. <br /> <br />Moreover, before the PlayReady client requests the license to decrypt the content, it must first determine whether the user&rsquo;s computer has the appropriate PlayReady software installed. This software is called the Individualized Black boX (IBX) and is the client component of PlayReady that is required before any protected content can be played. The individualization component software enables the client computer to request and use a PlayReady license. <br /> <br />The PlayReady client for Windows Store applications supports dynamic individualization: the IBX is downloaded from the Individualization Server. In your application you can implement a Pro-Active Individualization Request or a Reactive Individualization Request.</p>
<ul>
<li>A <strong>Pro-Active Individualization Request </strong>can be transmitted just after the installation of the application or when the user launches the application for the first time.</li>
<li>A <strong>Reactive Individualization Request</strong> is automatically prepared by the PlayReady client when the application is about to play an asset protected with PlayReady and if the IBX is not installed on the computer.</li>
</ul>
<p>The schema below describes the acquisition of a PlayReady license to play an asset protected with PlayReady with a Reactive Individualization Request:&nbsp; <br /> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4035.image_368DCB73.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4035.image_5F00_368DCB73.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6471.image_thumb_6F3B0631.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6471.image_5F00_thumb_5F00_6F3B0631.png" alt="image" width="820" height="354" border="0" /></a></p>
<p>The schema below describes the acquisition of a PlayReady license to play an asset protected with PlayReady without any Individualization Request as the Individualized Black Box (IBX) is already installed:&nbsp; <br /> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5824.image_08396728.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5824.image_5F00_08396728.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8156.image_thumb_0C4645AB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8156.image_5F00_thumb_5F00_0C4645AB.png" alt="image" width="824" height="288" border="0" /></a></p>
<p><br />The schema below describes the exchanges between the client and the server when the application plays an asset protected with PlayReady when the Individualized Black Box (IBX) is already installed and the PlayReady license has already been acquired and the license is persistent:&nbsp; <br /> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7026.image_74AE9837.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7026.image_5F00_74AE9837.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7444.image_thumb_1FF5BFF0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7444.image_5F00_thumb_5F00_1FF5BFF0.png" alt="image" width="822" height="314" border="0" /></a></p>
<h2><strong>Http Client Libraries: </strong></h2>
<p>These PlayReady sample applications are based on Player Framework V1.2 and the PlayReady license acquisition is based on HttpClient class for both platforms Windows and Windows Phone.&nbsp;&nbsp; <br />HttpClient is a part of .NET Framework 4.5 and Windows Store applications that provides developers an extremely easy way to connect with services across the Internet including REST-based services. HttpClient is now available for Windows Phone developers provided you install the Microsoft HttpClient Libraries Nuget package. <br /> <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8780.image_6740D0F7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8780.image_5F00_6740D0F7.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2816.image_thumb_6A77DA41.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2816.image_5F00_thumb_5F00_6A77DA41.png" alt="image" width="386" height="72" border="0" /></a></p>
<strong></strong>
<h1>Building the sample applications</h1>
<p><strong></strong>In order to build the Player sample applications for Windows Store and Windows Phone, make sure you have the basics installed: <br />1. a computer running Windows 8, <br /> 2. Visual Studio 2012, <br />3. Windows Phone 8 SDK.</p>
<p>For the Windows Store player application you need to install: <br />1. The <a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">Smooth Streaming Client SDK for Windows 8</a> <br />2. The <a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">PlayReady Client SDK for Windows Store Apps</a> <br />3. The <a href="http://playerframework.codeplex.com/releases/view/105214">Player Framework for Windows 8 and Windows Phone 8 (v1.2)</a>.</p>
<p>For the Windows Phone 8 player application you need to install: <br />1. The <a href="http://www.microsoft.com/en-us/download/details.aspx?id=29940">Microsoft Smooth Streaming Client 2.0 RTW</a> <br />2. The <a href="http://playerframework.codeplex.com/releases/view/105214">Player Framework for Windows 8 and Windows Phone 8 (v1.2)</a>. <br />The <strong>&nbsp;</strong>Windows Phone 8 player application is delivered with the following Nuget packages: <br />1. <a href="http://blogs.msdn.com/b/bclteam/p/httpclient.aspx">Microsoft HTTP Client Libraries: Microsof.Net.Http&nbsp; </a> <br />2. <a href="http://blogs.msdn.com/b/bclteam/p/bcl.aspx">Microsoft BCL Portability Pack: Microsoft.BCL </a> <br />3. <a href="http://blogs.msdn.com/b/bclteam/p/bclbuild.aspx">Microsoft BCL Build Components: Microsoft.BCL.Build </a></p>
<h2><strong>Installing the Microsoft Smooth Streaming Client SDK for Windows 8</strong></h2>
<p><strong></strong> <br />1. Download the Smooth Streaming Client SDK from this link: <a href="http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6">http://visualstudiogallery.msdn.microsoft.com/04423d13-3b3e-4741-a01c-1ae29e84fea6</a> <br />2. Double click on the VSIX file to launch the installation <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1780.image_5995C702.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1780.image_5F00_5995C702.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0640.image_thumb_491D5607.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0640.image_5F00_thumb_5F00_491D5607.png" alt="image" width="316" height="30" border="0" /></a> <br />3. On the VSIX Installer dialog box click on the <strong>Install </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8726.image_0D604E05.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8726.image_5F00_0D604E05.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4150.image_thumb_6C05C9CA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4150.image_5F00_thumb_5F00_6C05C9CA.png" alt="image" width="244" height="198" border="0" /></a> <br />4. After few seconds, the SDK is installed. Click on the <strong>Close </strong>button to close the VSIX Installer dialog box. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2845.image_36FBCB4B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2845.image_5F00_36FBCB4B.png"><img style="margin: 0px; display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7651.image_thumb_0D878A0B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7651.image_5F00_thumb_5F00_0D878A0B.png" alt="image" width="244" height="196" border="0" /></a></p>
<h2>Installing the Microsoft PlayReady Client SDK for Windows Store Apps</h2>
<p><strong> <br /></strong>1. Download the PlayReady Client SDK from this link: <br /><a href="http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483">http://visualstudiogallery.msdn.microsoft.com/e02ccac7-f3eb-4b53-b11a-c657d5631483</a> <br />2. Double click on the VSIX file to launch the installation <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2627.image_08021A23.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2627.image_5F00_08021A23.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1018.image_thumb_32DD0EE6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1018.image_5F00_thumb_5F00_32DD0EE6.png" alt="image" width="291" height="29" border="0" /></a> <br />3. On the VSIX Installer dialog box click on the <strong>Install </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4442.image_0DE1DF1E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4442.image_5F00_0DE1DF1E.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3113.image_thumb_28065C63.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3113.image_5F00_thumb_5F00_28065C63.png" alt="image" width="257" height="194" border="0" /></a> <br />4. After few seconds, the SDK is installed. Click on the <strong>Close </strong>button to close the VSIX Installer dialog box. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6708.image_4E98FCD1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6708.image_5F00_4E98FCD1.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1376.image_thumb_049D7BDF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1376.image_5F00_thumb_5F00_049D7BDF.png" alt="image" width="253" height="191" border="0" /></a></p>
<h2>Installing the Microsoft Smooth Streaming Client 2.0 RTW</h2>
<p><strong> <br /></strong>1. Download the Smooth Streaming Client SDK from this link: <br /><a href="http://www.microsoft.com/en-us/download/details.aspx?id=29940">http://www.microsoft.com/en-us/download/details.aspx?id=29940</a> <br />2. Double click on the MSI file to launch the installation <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3007.image_5CF99065.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3007.image_5F00_5CF99065.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3441.image_thumb_5C8FEE21.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3441.image_5F00_thumb_5F00_5C8FEE21.png" alt="image" width="281" height="31" border="0" /></a> <br />3. On the Microsoft Smooth Streaming Client 2.0 setup dialog box click on the <strong>Next </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0020.image_39CEB664.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0020.image_5F00_39CEB664.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8030.image_thumb_021E8CE5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8030.image_5F00_thumb_5F00_021E8CE5.png" alt="image" width="267" height="211" border="0" /></a> <br />4. On the Microsoft Smooth Streaming Client 2.0 setup dialog box check the check box and click on the <strong>Next </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3051.image_6A1D3D2D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3051.image_5F00_6A1D3D2D.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1680.image_thumb_59871149.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1680.image_5F00_thumb_5F00_59871149.png" alt="image" width="269" height="212" border="0" /></a> <br />5. On the Microsoft Smooth Streaming Client 2.0 setup dialog box click on the <strong>Next </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1638.image_77D627FA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1638.image_5F00_77D627FA.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4237.image_thumb_2C0CE1F2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4237.image_5F00_thumb_5F00_2C0CE1F2.png" alt="image" width="271" height="212" border="0" /></a> <br />6. On the Microsoft Smooth Streaming Client 2.0 setup dialog box click on the <strong>Install </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2804.image_68C46A82.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2804.image_5F00_68C46A82.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6607.image_thumb_54B23E65.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6607.image_5F00_thumb_5F00_54B23E65.png" alt="image" width="273" height="216" border="0" /></a> <br />7. After few seconds, the SDK is installed. Click on the <strong>Finish </strong>button to close the dialog box. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3286.image_1673B6B8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3286.image_5F00_1673B6B8.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1323.image_thumb_69AAB144.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1323.image_5F00_thumb_5F00_69AAB144.png" alt="image" width="276" height="216" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<h2>Installing the Player Framework for Windows 8 and Windows Phone 8 (v1.2)</h2>
<p><strong> <br /></strong>1. Download the Player Framework from this link: <br /><a href="http://playerframework.codeplex.com/releases/view/105214">http://</a><a href="http://playerframework.codeplex.com/releases/view/105214">playerframework.codeplex.com/releases/view/105214</a>&nbsp;&nbsp; <br />2. Double click on the VSIX file to launch the installation <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/5305.image_0F19046E.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/5305.image_5F00_0F19046E.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3617.image_thumb_15CE9EA2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3617.image_5F00_thumb_5F00_15CE9EA2.png" alt="image" width="274" height="31" border="0" /></a> <br />3. On the VSIX Installer dialog box click on the <strong>Install </strong>button <br />&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6864.image_4C3F50A4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6864.image_5F00_4C3F50A4.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7416.image_thumb_7B249339.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7416.image_5F00_thumb_5F00_7B249339.png" alt="image" width="279" height="227" border="0" /></a> <br />4. After few seconds, the SDK is installed. Click on the <strong>Close </strong>button to close the VSIX Installer dialog box. <br />&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4810.image_1AD5FDB3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4810.image_5F00_1AD5FDB3.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1581.image_thumb_5F3DA105.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1581.image_5F00_thumb_5F00_5F3DA105.png" alt="image" width="284" height="214" border="0" /></a></p>
<h2>Opening and building the Solution</h2>
<p><strong> <br /></strong>Once the SDKs are installed you can open the Solution file associated with the sample applications.</p>
<ol>
<li>Start Visual Studio 2012 and select <strong>File &gt; Open &gt; Project/Solution</strong>.</li>
<li>Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Microsoft Visual Studio Solution (.sln) file. <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2061.image_0205B9DB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2061.image_5F00_0205B9DB.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3326.image_thumb_1A97E7DC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3326.image_5F00_thumb_5F00_1A97E7DC.png" alt="image" width="278" height="375" border="0" /></a></li>
<li>Check there is no warning for the Windows 8 references <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/8737.image_4572DC9F.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/8737.image_5F00_4572DC9F.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/4073.image_thumb_154B91DC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/4073.image_5F00_thumb_5F00_154B91DC.png" alt="image" width="324" height="183" border="0" /></a></li>
<li>Check there is no warning for the Windows Phone 8 references <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/1261.image_64B81423.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/1261.image_5F00_64B81423.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0131.image_thumb_3490C960.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0131.image_5F00_thumb_5F00_3490C960.png" alt="image" width="327" height="215" border="0" /></a></li>
<li>Both projects use a common C# source code file for PlayReady license acquisition CommonLicenseRequest.cs <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/7418.image_1CF91BED.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/7418.image_5F00_1CF91BED.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6378.image_thumb_2C9BB7AF.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6378.image_5F00_thumb_5F00_2C9BB7AF.png" alt="image" width="225" height="358" border="0" /></a></li>
<li>The file CommonLicenseRequest.cs has been shared between both projects using the Visual Studio option <strong>Add As Link </strong>for the <em>Add Existing Item </em>menu . <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3286.image_57E2DF67.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3286.image_5F00_57E2DF67.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/0728.image_thumb_02BDD42B.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/0728.image_5F00_thumb_5F00_02BDD42B.png" alt="image" width="529" height="347" border="0" /></a></li>
<li>Press F7 or use <strong>Build &gt; Build Solution</strong> to build the samples.</li>
</ol>
<h1>Exploring the Windows Store Player Application project</h1>
<p>The Windows Store Player Application project is a XAML based project.&nbsp; <br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/6786.image_4700CC28.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/6786.image_5F00_4700CC28.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/2043.image_thumb_68EC2EAC.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/2043.image_5F00_thumb_5F00_68EC2EAC.png" alt="image" width="356" height="290" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<ul>
<li><strong><em>MainPage.cs</em></strong> contains the main page source code.</li>
<li><strong><em>CommonLicenseRequest.cs</em></strong> contains the source code to acquire the PlayReady license using HttpClient class. <strong><em></em></strong></li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contains the source code used to store and retrieve the application settings in the local app store.</li>
</ul>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />In the main page constructor, the PlayReady and Smooth Streaming events are registered.&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">public</span> MainPage()<br />{<br />    <span style="color: #0000ff;">this</span>.InitializeComponent();<br /><br />    <span style="color: #008000;">// Add Plugins</span><br />    Player.Plugins.Add(<span style="color: #0000ff;">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin());<br /><br />    <span style="color: #008000;">// Init PlayReady Protection Manager</span><br />    var protectionManager = <span style="color: #0000ff;">new</span> MediaProtectionManager();<br />    Windows.Foundation.Collections.PropertySet cpSystems = <span style="color: #0000ff;">new</span> Windows.Foundation.Collections.PropertySet();<br />    cpSystems.Add(<span style="color: #006080;">"{F4637010-03C3-42CD-B932-B48ADF3A6A54}"</span>, <span style="color: #006080;">"Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput"</span>); <span style="color: #008000;">//Playready</span><br />    protectionManager.Properties.Add(<span style="color: #006080;">"Windows.Media.Protection.MediaProtectionSystemIdMapping"</span>, cpSystems);<br />    protectionManager.Properties.Add(<span style="color: #006080;">"Windows.Media.Protection.MediaProtectionSystemId"</span>, <span style="color: #006080;">"{F4637010-03C3-42CD-B932-B48ADF3A6A54}"</span>);<br />    <span style="color: #0000ff;">this</span>.Player.ProtectionManager = protectionManager;<br />    <span style="color: #008000;">// PlayReady Events registration</span><br />    Player.ProtectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed;<br />    Player.ProtectionManager.ServiceRequested += ProtectionManager_ServiceRequested;<br /><br /><br />    <span style="color: #008000;">// Init Smooth Streaming Handler</span><br />    Windows.Media.MediaExtensionManager extensions = <span style="color: #0000ff;">new</span> Windows.Media.MediaExtensionManager();<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".ism"</span>, <span style="color: #006080;">"text/xml"</span>);<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".isml"</span>, <span style="color: #006080;">"text/xml"</span>);<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".ism"</span>, <span style="color: #006080;">"application/vnd.ms-ss"</span>);<br />    extensions.RegisterByteStreamHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler"</span>, <span style="color: #006080;">".isml"</span>, <span style="color: #006080;">"application/vnd.ms-ss"</span>);<br />    extensions.RegisterSchemeHandler(<span style="color: #006080;">"Microsoft.Media.AdaptiveStreaming.SmoothSchemeHandler"</span>, <span style="color: #006080;">"ms-sstr:"</span>);<br />    Player.MediaExtensionManager = extensions;</pre>
</div>
<pre class="code">&nbsp;</pre>
<p>The method ProtectionManager_ServiceRequested is called each time a PlayReady license or a Individualization are requested. If it&rsquo;s an Individualisation request the method ReactiveIndivRequest is called. If it&rsquo;s a PlayReady License request the method LicenseAcquisitionRequest is called.&nbsp;&nbsp;&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">/// &lt;summary&gt;</span><br /><span style="color: #008000;">/// Invoked to send a PlayReady request (Individualization or License request)</span><br /><span style="color: #008000;">/// &lt;/summary&gt;</span><br />async <span style="color: #0000ff;">void</span> ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent)<br />{<br />    LogMessage(<span style="color: #006080;">"ProtectionManager ServiceRequested"</span>);<br />    <span style="color: #0000ff;">if</span> (srEvent.Request <span style="color: #0000ff;">is</span> PlayReadyIndividualizationServiceRequest)<br />    {<br />        PlayReadyIndividualizationServiceRequest IndivRequest = srEvent.Request <span style="color: #0000ff;">as</span> PlayReadyIndividualizationServiceRequest;<br />        <span style="color: #0000ff;">bool</span> bResultIndiv = await ReactiveIndivRequest(IndivRequest, srEvent.Completion);<br />    }<br />    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> (srEvent.Request <span style="color: #0000ff;">is</span> PlayReadyLicenseAcquisitionServiceRequest)<br />    {<br />        PlayReadyLicenseAcquisitionServiceRequest licenseRequest = srEvent.Request <span style="color: #0000ff;">as</span> PlayReadyLicenseAcquisitionServiceRequest;<br />        LicenseAcquisitionRequest(licenseRequest, srEvent.Completion, PlayReadyLicenseUrl, PlayReadyChallengeCustomData);<br />    }<br />}</pre>
</div>
If the URL used to acquire the PlayReady License is not forced and is the one defined in the PlayReady protection header, the method LicenseAcquisitionRequest calls licenseRequest.BeginServiceRequest. If the URL to acquire the PlayReady License is forced by the application, the method LicenseAcquisitionRequest creates a PlayReady challenge using the ChallengeCustomData and then call licenseAcquisition.AcquireLicense using the URL defined by the user. <br />
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">/// &lt;summary&gt;</span><br /><span style="color: #008000;">/// Invoked to acquire the PlayReady License</span><br /><span style="color: #008000;">/// &lt;/summary&gt;</span><br />async <span style="color: #0000ff;">void</span> LicenseAcquisitionRequest(PlayReadyLicenseAcquisitionServiceRequest licenseRequest, MediaProtectionServiceCompletion CompletionNotifier, <span style="color: #0000ff;">string</span> Url, <span style="color: #0000ff;">string</span> ChallengeCustomData)<br />{<br />    <span style="color: #0000ff;">bool</span> bResult = <span style="color: #0000ff;">false</span>;<br />    <span style="color: #0000ff;">string</span> ExceptionMessage = <span style="color: #0000ff;">string</span>.Empty;<br /><br />    <span style="color: #0000ff;">try</span><br />    {<br />        <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Url))<br />        {<br />            LogMessage(<span style="color: #006080;">"ProtectionManager PlayReady Manual License Acquisition Service Request in progress - URL: "</span> + Url);<br /><br />            <span style="color: #0000ff;">if</span> (!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(ChallengeCustomData))<br />            {<br />                System.Text.UTF8Encoding encoding = <span style="color: #0000ff;">new</span> System.Text.UTF8Encoding();<br />                <span style="color: #0000ff;">byte</span>[] b = encoding.GetBytes(ChallengeCustomData);<br />                licenseRequest.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length);<br />            }<br /><br />            PlayReadySoapMessage soapMessage = licenseRequest.GenerateManualEnablingChallenge(); <br />            <br />            <span style="color: #0000ff;">byte</span>[] messageBytes = soapMessage.GetMessageBody();<br />            HttpContent httpContent = <span style="color: #0000ff;">new</span> ByteArrayContent(messageBytes);<br /><br />            IPropertySet propertySetHeaders = soapMessage.MessageHeaders;<br />            <span style="color: #0000ff;">foreach</span> (<span style="color: #0000ff;">string</span> strHeaderName <span style="color: #0000ff;">in</span> propertySetHeaders.Keys)<br />            {<br />                <span style="color: #0000ff;">string</span> strHeaderValue = propertySetHeaders[strHeaderName].ToString();<br /><br />                <span style="color: #008000;">// The Add method throws an ArgumentException try to set protected headers like "Content-Type"</span><br />                <span style="color: #008000;">// so set it via "ContentType" property</span><br />                <span style="color: #0000ff;">if</span> (strHeaderName.Equals(<span style="color: #006080;">"Content-Type"</span>, StringComparison.OrdinalIgnoreCase))<br />                    httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse(strHeaderValue);<br />                <span style="color: #0000ff;">else</span><br />                    httpContent.Headers.Add(strHeaderName.ToString(), strHeaderValue);<br />            }<br />            CommonLicenseRequest licenseAcquision = <span style="color: #0000ff;">new</span> CommonLicenseRequest();<br />            HttpContent responseHttpContent = await licenseAcquision.AcquireLicense(<span style="color: #0000ff;">new</span> Uri(Url), httpContent);<br />            <span style="color: #0000ff;">if</span> (responseHttpContent != <span style="color: #0000ff;">null</span>)<br />            {<br />                Exception exResult = licenseRequest.ProcessManualEnablingResponse(await responseHttpContent.ReadAsByteArrayAsync());<br />                <span style="color: #0000ff;">if</span> (exResult != <span style="color: #0000ff;">null</span>)<br />                {<br />                    <span style="color: #0000ff;">throw</span> exResult;<br />                }<br />                bResult = <span style="color: #0000ff;">true</span>;<br />            }<br />            <span style="color: #0000ff;">else</span><br />                ExceptionMessage = licenseAcquision.GetLastErrorMessage();<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            LogMessage(<span style="color: #006080;">"ProtectionManager PlayReady License Acquisition Service Request in progress - URL: "</span> + licenseRequest.Uri.ToString());<br />            await licenseRequest.BeginServiceRequest();<br />            bResult = <span style="color: #0000ff;">true</span>;<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception e)<br />    {<br />        ExceptionMessage = e.Message;<br />    }<br />    <br />    <span style="color: #0000ff;">if</span> (bResult == <span style="color: #0000ff;">true</span>)<br />            LogMessage(!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Url) ? <span style="color: #006080;">"ProtectionManager Manual PlayReady License Acquisition Service Request successful"</span>:<br />                <span style="color: #006080;">"ProtectionManager PlayReady License Acquisition Service Request successful"</span>);<br />    <span style="color: #0000ff;">else</span><br />        LogMessage(!<span style="color: #0000ff;">string</span>.IsNullOrEmpty(Url) ? <span style="color: #006080;">"ProtectionManager Manual PlayReady License Acquisition Service Request failed: "</span>+ExceptionMessage :<br />            <span style="color: #006080;">"ProtectionManager PlayReady License Acquisition Service Request failed: "</span> + ExceptionMessage);<br />    CompletionNotifier.Complete(bResult);<br />}</pre>
</div>
The method AcquireLicense sends the PlayReady license Http Request to the PlayReady server. The request contains the PlayReady challenge and add http headers. The method PostAsync of class HttpClient is used to transmit this request. <br />
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 600px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">/// &lt;summary&gt;</span><br /><span style="color: #008000;">/// Invoked to acquire the PlayReady license.</span><br /><span style="color: #008000;">/// &lt;/summary&gt;</span><br /><span style="color: #008000;">/// &lt;param name="licenseServerUri"&gt;License Server URI to retrieve the PlayReady license.&lt;/param&gt;</span><br /><span style="color: #008000;">/// &lt;param name="httpRequestContent"&gt;HttpContent including the Challenge transmitted to the PlayReady server.&lt;/param&gt;</span><br /><span style="color: #0000ff;">public</span> async <span style="color: #0000ff;">virtual</span> Task&lt;HttpContent&gt; AcquireLicense(Uri licenseServerUri, HttpContent httpRequestContent)<br />{<br />    <span style="color: #0000ff;">try</span><br />    {<br />        HttpClient httpClient = <span style="color: #0000ff;">new</span> HttpClient();<br />        httpClient.DefaultRequestHeaders.Add(<span style="color: #006080;">"msprdrm_server_redirect_compat"</span>, <span style="color: #006080;">"false"</span>);<br />        httpClient.DefaultRequestHeaders.Add(<span style="color: #006080;">"msprdrm_server_exception_compat"</span>, <span style="color: #006080;">"false"</span>);<br /><br />        HttpResponseMessage response = await httpClient.PostAsync(licenseServerUri, httpRequestContent);<br />        response.EnsureSuccessStatusCode();<br /><br />        <span style="color: #0000ff;">if</span> (response.StatusCode == HttpStatusCode.OK)<br />        {<br />            _lastErrorMessage = <span style="color: #0000ff;">string</span>.Empty;<br />            <span style="color: #0000ff;">return</span> response.Content;<br />        }<br />        <span style="color: #0000ff;">else</span><br />        {<br />            _lastErrorMessage = <span style="color: #006080;">"AcquireLicense - Http Response Status Code: "</span> + response.StatusCode.ToString();<br />        }<br />    }<br />    <span style="color: #0000ff;">catch</span> (Exception exception)<br />    {<br />        _lastErrorMessage = exception.Message;<br />        <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;<br />    }<br />    <span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span>;<br />}</pre>
</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<h1><strong>Exploring the Windows Phone 8 Player Application project</strong></h1>
<p>The Windows Phone 8 Player Application project is a XAML based project.&nbsp; <br /> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3000.image_228E4FBB.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3000.image_5F00_228E4FBB.png"><img style="display: inline; background-image: none;" title="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/metablogapi/3036.image_thumb_044398C5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-metablogapi/3036.image_5F00_thumb_5F00_044398C5.png" alt="image" width="324" height="308" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;</p>
<ul>
<li><strong><em>MainPage.cs</em></strong> contains the main page source code.&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li><strong><em>CommonLicenseRequest.cs</em></strong> contains the source code to acquire the PlayReady license using HttpClient class.&nbsp;&nbsp;</li>
<li><strong><em>ApplicationConfiguration.cs</em></strong> contains the source code used to store and retrieve the application settings in the local app store.&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li><strong><em>WindowsPhoneLicenseAcquisition.cs</em></strong> contains the source code of the class WindowsPhoneLicenseAcquisition derived from PlayReady class LicenseAcquirer used to acquire the PlayReady license.</li>
</ul>
<p>In the main page constructor, the PlayReady events are registered using the class WindowsPhoneLicenseAcquisition.&nbsp;&nbsp;</p>
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 400px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #008000;">//Add Smooth Streaming and Caption plugins </span><br />Microsoft.PlayerFramework.Adaptive.AdaptivePlugin AP = <span style="color: #0000ff;">new</span> Microsoft.PlayerFramework.Adaptive.AdaptivePlugin();<br />Player.Plugins.Add(AP);<br />Player.Plugins.Add(<span style="color: #0000ff;">new</span> Microsoft.PlayerFramework.TimedText.CaptionsPlugin());<br />Microsoft.PlayerFramework.Adaptive.AdaptivePlugin ap = Player.Plugins.OfType&lt;Microsoft.PlayerFramework.Adaptive.AdaptivePlugin&gt;().FirstOrDefault();<br /><span style="color: #0000ff;">if</span> (ap != <span style="color: #0000ff;">null</span>)<br />{<br />    <span style="color: #008000;">// Register PlayReady LicenseAcquirer</span><br />    ap.MediaElement.LicenseAcquirer = <span style="color: #0000ff;">new</span> WindowsPhoneLicenseAcquisition(LogMessage);<br />    ap.MediaElement.MediaFailed += Player_MediaFailed;<br />}</pre>
</div>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />The method OnAcquireLicense is called to acquire a PlayReady license. If the LicenseServerUriOverride is defined it&rsquo;s a manual license acquisition. The method convert the Stream which contains the PlayReady Challenge into a HttpContent object before calling _licenseRequest.AcquireLicense which is the common method to acquire the PlayReady license for Windows Phone and Windows Store application. <br />
<div id="codeSnippetWrapper" style="margin: 20px 0px 10px; padding: 4px; border: 1px solid silver; width: 97.5%; text-align: left; line-height: 12pt; overflow: auto; font-family: 'Courier New', courier, monospace; font-size: 8pt; cursor: text; direction: ltr; max-height: 400px; background-color: #f4f4f4;">
<pre id="codeSnippet" style="margin: 0em; padding: 0px; width: 100%; text-align: left; color: black; line-height: 12pt; overflow: visible; font-family: 'Courier New', courier, monospace; font-size: 8pt; direction: ltr; background-color: #f4f4f4;"><span style="color: #0000ff;">protected</span> async <span style="color: #0000ff;">override</span> <span style="color: #0000ff;">void</span> OnAcquireLicense(System.IO.Stream licenseChallenge, Uri licenseServerUri)<br />{<br /><br />    <span style="color: #008000;">// Need to resolve the URI for the License Server -- make sure it is correct</span><br />    <span style="color: #008000;">// and store that correct URI as resolvedLicenseServerUri.</span><br />    Uri resolvedLicenseServerUri;<br />    <span style="color: #0000ff;">if</span> (LicenseServerUriOverride == <span style="color: #0000ff;">null</span>)<br />    {<br />        <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition Service Request in progress - URL: "</span> + licenseServerUri.ToString());<br />        resolvedLicenseServerUri = licenseServerUri;<br />    }<br />    <span style="color: #0000ff;">else</span><br />    {<br />        <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady Manual License Acquisition Service Request in progress - URL: "</span> + LicenseServerUriOverride.ToString());<br />        resolvedLicenseServerUri = LicenseServerUriOverride;<br />    }<br /><br />    <span style="color: #0000ff;">try</span><br />    {<br />        StreamReader sr = <span style="color: #0000ff;">new</span> StreamReader(licenseChallenge);<br />        <span style="color: #0000ff;">string</span> challengeString = sr.ReadToEnd();<br />        Byte[] Data = System.Text.Encoding.UTF8.GetBytes(challengeString);<br />        HttpContent httpRequestContent = <span style="color: #0000ff;">new</span> ByteArrayContent(Data);<br /><br />        httpRequestContent.Headers.ContentType = <span style="color: #0000ff;">new</span> MediaTypeHeaderValue(<span style="color: #006080;">"text/xml"</span>);<br />        httpRequestContent.Headers.ContentLength = Data.Length;<br /><br /><br />        HttpContent httpResponseContent = await _licenseRequest.AcquireLicense(resolvedLicenseServerUri, httpRequestContent);<br />        <span style="color: #0000ff;">if</span> (httpResponseContent != <span style="color: #0000ff;">null</span>)<br />        {<br />            Stream srep = await httpResponseContent.ReadAsStreamAsync();<br />            <span style="color: #0000ff;">if</span> (srep != <span style="color: #0000ff;">null</span>)<br />            {<br />                <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition successful."</span>);<br />                SetLicenseResponse(srep);<br />                <span style="color: #0000ff;">return</span>;<br />            }<br />        }<br />        <span style="color: #0000ff;">else</span><br />            <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition failed. Exception: "</span> + _licenseRequest.GetLastErrorMessage());<br />    }<br />    <span style="color: #0000ff;">catch</span>(Exception e)<br />    {<br />        <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition failed. Exception: "</span> + e.Message);<br />    }<br />    <br />    <span style="color: #0000ff;">if</span> (_LogMessage != <span style="color: #0000ff;">null</span>) _LogMessage(<span style="color: #006080;">"PlayReady License Acquisition failed."</span>);<br />    <span style="color: #008000;">// Call CancelAsync </span><br />    <span style="color: #008000;">// In that case the MediaElement transitions from the AcquiringLicense state to the error state and</span><br />    <span style="color: #008000;">// calling this method causes playback to fail with a "license acquisition failure" error.</span><br />    <span style="color: #0000ff;">try</span><br />    {<br />        CancelAsync();<br />    }<br />    <span style="color: #0000ff;">catch</span><br />    {<br />    }<br />}</pre>
</div>
<h1>&nbsp;</h1>
<h1><strong>Testing the Windows Store and Windows Phone PlayReady Player applications </strong></h1>
</blockquote>
<blockquote>
<p>By default the applications will try to play the following Smooth Streaming asset: <br /><a title="http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest" href="http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest">http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest</a> <br />using the following URL for the license acquisition: <br /><a title="http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1" href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1">http://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&amp;UseSimpleNonPersistentLicense=1</a>&nbsp; <br />This URL will return a non-persistent license. Each time the application will try to play the smooth streaming asset, a request to the PlayReady server will be transmitted. <br />By default, the challenge custom data is empty, you can change this field if the PlayReady server expect a specific challenge custom data. <br /><strong> Persistent license:</strong> <br />If you use the following URL, the license returned will be persistent: <br /><a href="http://playready.directtaps.net/pr/svc/rightsmanager.asmx">http://playready.directtaps.net/pr/svc/rightsmanager.asmx</a></p>
<h1>Downloading the projects</h1>
<p>Download:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/3162.PlayReadyPlayerforWin8WP8.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/3162.PlayReadyPlayerforWin8WP8.zip">C# (3.3 MB)</a> <br />Requires:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows 8, Visual Studio 2012, Windows Phone 8 SDK <br />Last updated:&nbsp;&nbsp;&nbsp; 10/18/2013 <br />License:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/61/39/Samples/7824.license.rtf" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-61-39-Samples/7824.license.rtf">MS-LPL</a> <br />Technologies:&nbsp;&nbsp;&nbsp; PlayReady, Smooth Streaming, PlayerFramework, C#, XAML <br />Topics:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PlayReady Smooth Streaming Player for Windows Phone and Windows Store</p>
</blockquote>]]></content:encoded>
    </item>
  </channel>
</rss>