Silverlight streaming learning notes for Windows Live

Source: Internet
Author: User

Windows Live framework includes a lot of content, one of which is Silverlight streaming, this article is through the http://dev.live.com/silverlight/and Silverlight streaming SDK (http://msdn.microsoft.com/en-us/library/bb851621.aspx) learning after finishing the notes, superficial!

The architecture of Silverlight streaming isProgramAnd media (mainly video) servers, and then we can reference the Silverlight application and media assets on the Silverlight streaming server on our site page at will. Of course, it is not a simple server that only stores files. It also provides some services for us. For example, it encapsulates how Silverlight is displayed on the page.Code.

To use Silverlight streaming, you must first register a Silverlight streaming account. To register a Silverlight streaming account, you must first log on with a Windows Live ID. Sign in with Windows lieve ID on the http://silverlight.live.com/account/create.aspx page to register a Silverlight streaming account. The Silverlight streaming account is a Windows Live ID associated and unchanged (note that they are two things rather than one thing), and an account key is also generated, this key is useful when you call an API later. It is a bit similar to a password and can be regenerated.

With the Silverlight streaming account, you can simply understand that you have your own space on the Silverlight streaming server, and then you can upload your own files to the Silverlight streaming server. The Silverlight program can be uploaded in "manage applications" (https://silverlight.live.com/files.aspx) or in "manage Videos" (http://silverlight.live.com/Videos.aspx.

To upload a Silverlight application, you must first prepare the Silverlight application and package it into a zip file, and create a mainfest. put XML in the ZIP file, the mainfest. XML tells Silverlight streaming information in the following format:

< Silverlightapp >
< Source > XAML or xap File </ Source >
< Version > 1.0 | 2.0 </ Version >
< Width > [Value in browser units or percentage] </ Width >
< Height > [Value in browser units or percentage] </ Height >
< Jsorder >
< JS > [JS file to load first] </ JS >
< JS > [JS file to load second] </ JS >
< JS > </ JS >
</ Jsorder >
</ Silverlightapp >

This information is required when Silverlight streaming encapsulates and presents the code of Silverlight.

In addition, after compilation in Silverlight 2, it has been packaged into an xap file. In fact, you only need to upload this xap file. Silverlight streaming will automatically generate mainfest. xml configuration information.Configure this application"Node.

After Silverlight is uploaded, Silverlight will provide you with instructions on how to reference the code of the Silverlight program. To reference the Silverlight program on Silverlight streaming on another page, you can use either of the following methods:Ifame, The other is to useSilverlight streaming Control.

IFRAME:

< IFRAME SRC = "Http://silverlight.services.live.com/invoke/32/SlLogo/iframe.html" Frameborder = "0" Width = "258" Height = "100" Scrolling = "No" > </ IFRAME >

 

To use Silverlight streaming control, you must complete the following steps (from SDK replication, it is easy to understand ):

  1. Modify<HTML>Tag to referenceDevliveNamespace:

    <HTML xmlns: devlive = "http://dev.live.com">

  2. Add the following references to the page header:

     
  3. Add the Silverlight streaming control to your web page, as shown in the following example. ReplaceAccountidWith your account identifier, andAppnameWith the application name:<Devlive: slscontrol silverlightversion = "1.0" src = "/accountid/appname/" installationmode = "popup" initparams = "mykey = thevalue"> </devlive: slscontrol>

From this we can see that the <Object> label is not required for the Silverlight program on the page, because Silverlight streaming is ready for us. However, on the other hand, because the Silverlight program referenced on the page is placed on the Silverlight streaming server, if we need to pass parameters to Silverlight on our page, it will involve cross-origin issues. To solve this problem, we only need to use the Silverlight streaming control method. You can set The initparams attribute is used to pass parameters. For example:

< Devlive: slscontrol
Silverlightversion = "1.0"
SRC = "/Accountid/appname /"  
Installationmode = "Popup"
Initparams = "Mykey = thevalue" >
</ Devlive: slscontrol > Silverlight streaming control also defines onload, oninit, and other events for the called Web page to handle. For details, refer to http://msdn.microsoft.com/en-us/library/cc304460.aspx. For more information about video uploading, see http://msdn.microsoft.com/en-us/library/cc645017.aspx. However, this video is generally required to be supported by Silverlight. All the above mentioned operations are done through the page operations provided by silverlight.live.com, and Silverlight streaming also provides us with many APIs, so that we can use the code in the program to complete all the operations mentioned above. Silverlight streaming API is based on WebDAV (for knowledge about WebDAV, refer to http://www.webdav.org/), we can use httpwebrequest to interact with the Silverlight streaming server, this completes authentication, application/file information retrieval, modification of application/file information, and deletion of applications/files. The so-called authentication is to determine whether the account is a legal Silverlight streaming account by using the Silverlight streaming account and key. The SDK provides us with an authentication code. I will make some modifications:

UsingSystem;
UsingSystem. net;
UsingSystem. IO;

Namespace Silverlightservicesapi
{
  Class Program
{
Static   Void Main ( String [] ARGs)
{
String Accountid = "78012"; // account
String accountsecret ="6cb0458d482d7348b4a50ddda4bf4352"; // Account key
Httpwebrequest req =
(Httpwebrequest) httpwebrequest. Create
(" Https://silverlight.services.live.com/& quot; + accountid );
Byte [] Userpass = Encoding. Default. getbytes (accountid +   " : "   + Accountsecret );
String Basic =   " Basic "   + Convert. tobase64string (userpass );
Req. headers [ " Authorization " ] = Basic;

httpwebresponse resP = (httpwebresponse) req. getresponse ();
stream STRM = resp. getresponsestream ();
streamreader RDR = New streamreader (STRM );
string xmlresponse = RDR. readtoend ();
}< BR >}

If the authentication succeeds, response will receive all Silverlight applications list information under this account, which is returned in XML format. The Post, put, get, and delete methods of HTTP are used to upload, modify, obtain, and delete files. Go to http://msdn.microsoft.com/en-us/library/cc304456.aspx. At the same time, the SDK provides us with a very good Silverlight streaming API sample, which can be downloaded at http://dev.live.com/silverlight/downloads/webdav_clientdemo_cs.zip.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.