使用Silverlight Stream 輕鬆託管部署你silverlight應用程序

使用Silverlight Stream 輕鬆託管部署你silverlight應用程序
當開發者或設計師完成Silverlight一個應用程序後,最關心的無疑是如何將個人Silverlight應用程序第一時間發佈在網絡上, http://silverlight.live.com爲開發者和設計師提供了一個Silverlight應用程序的託管部署平臺,它是微軟官方提供的免費Silverlight應用程序託管平臺,它具備如下特色:
Silverlight Streaming默認提供10G存儲空間
每一個文件上傳增大到了約100M,知足開發者上傳較大的多媒體文件
視頻流傳輸速度爲1400kbps,知足高清多媒體視頻流暢回放
簡單方便的Silverlight應用程序發佈流程
使用Silverlight Streaming平臺託管你的Silverlight應用程序以前,你須要將Silverlight編譯後的XAP文件和一個manifest.xml文件,打包成一個zip壓縮包,manifest.xml(清單)文件中包括Silverlight應用程序運行時的基本信息,例如:源文件名、版本、尺寸等,下面代碼是一個最簡單的清單文件。
<SilverlightApp>
  <version>2.0</version>
  <source>myapp.xap</source>
  <width>400</width>
  <height>300</height>
  <background>white</background>
  <isWindowless>false</isWindowless>
</SilverlightApp>
代碼中聲明瞭應用程序的版本爲2.0,源文件名稱爲myapp.xap,寬400高300,背景爲白色,不使用Windowless支持的Silverlight應用程序,Silverlight Streaming就是根據這些信息來生成應用程序的部署代碼,下面表中列中的就是清單文件支持所有的內容。
Element  Description 
source
 The filename of the main XAML file or the application's XAP file, relative to the directory structure of the ZIP file.
 
version
 The minimum version of the Silverlight runtime required to run your Silverlight application. For example, if you set the value of this element to 1.0, the user must have version 1.0 or greater of the Silverlight runtime to view it. If you leave this value blank, the user will be forced to download the latest Silverlight runtime to run your application.
 
width
 The width of the Silverlight application, expressed in browser units (pixels) or as a percentage value.
 
height
 The height of the Silverlight application, expressed in browser units (pixels) or as a percentage value.
 
background
 A string value specifying the background color for the application frame after the application has loaded and while it is initializing. It may be a named color value or an 8-bit or 16-bit color value, with or without alpha transparency.
 
backgroundImage
 A string value specifying a background p_w_picpath for the application frame after the application has loaded and while it is initializing.
 
isWindowless
 Specifies whether to display the Silverlight control in windowless mode. True or False.
 
framerate
 The maximum number of frames to render per second.
 
enableHtmlAccess
 Specifies whether the hosted content in the Silverlight control has access to the browser Document Object Model (DOM). True or False.
 
inPlaceInstallPrompt
 Determines whether to display an install prompt if the detected version of Silverlight is out of date.
 
onLoad
 The name of a JavaScript function to run when the application has finished loading and the content has rendered. Note that this functionality differs from that of the Silverlight onLoad event, which fires after the application has finished loading but before the content has rendered.
 
onError
 The name of a JavaScript error handling function.
 
jsOrder
 Specifies the order in which JavaScript files will be loaded. Each file should be listed with the relative path name as it appears in the ZIP file. File names and paths are case-sensitive. Any JavaScript files not mentioned will be loaded in an unspecified order after the listed files.
 

 
source
主XAML的文件名或者是XAP文件名.相對ZIP包的根目錄.
version
運行這個Silverlight程序所需的最低Silverlight插件版本.好比,當你設置這個值爲1.0,用戶須要擁有1.0或者更高版本的Silverlight插件才能查看.若是這個值爲空白,用戶會被強制下載最新的Silverilght插件.
width
Silverlight程序的寬度,在瀏覽器中單位爲象素(pixels)或者是百分比.
height
Silverlight程序的高度, 在瀏覽器中單位爲象素(pixels)或者是百分比.
background
程序框架載入初始化時指定的背景色.能夠直接命名色彩值或者是8位16位值,不能設置alpha透明值.
backgroundImage
程序框架載入初始化時指定的背景圖片.
isWindowless
指定是否在無窗模式中顯示Silverlight控件.可設置True或False.
framerate
每秒鐘最大幀數.
enableHtmlAccess
指定是否在Silverlight控件中的內容能夠訪問DOM.可設置True或False.
inPlaceInstallPrompt
決定在偵測到Silverlight版本過時後是否顯示安裝提示.
onLoad
JavaScript一個事件處理函數.當程序載入完畢內容並已經呈現時運行.它與Silverlight的onLoad事件不一樣,
onLoad是當程序載入完畢可是在內容徹底呈現以前生效.
onError
JavaScript一個事件處理函數
jsOrder
指定須要的運行Silverlight文件.每個文件都須要列出幷包括完整的路徑(相對於ZIP包根目錄).文件名與路徑區分大小寫.不包括在列表中的JavaScript文件不會被執行.
 
而後你須要在官網上獲取你的Silverlight Streaming的Account ID和Account Key,如圖所示,點擊GetFree會提示你建立一個Windows Live賬號,若是你已經註冊過Windows Live ID的話,你就能夠直接使用你的Live賬號進行綁定,若是你沒有ID,能夠根據提示註冊一個Windows Live ID便可,輸入用戶ID和密碼,點擊Sign in即完成了Silverlight Streaming賬號的綁定,並顯示出你的Silverlight Streaming我的賬號信息。
 
接下來就能夠上傳你的Silverlight應用程序了,點擊左側的Manage Applications(管理應用程序),會列出你已經上傳過的Silverlight應用程序,點擊Upload an application(上傳一個Silverlight應用程序),輸入Silverlight應用程序名稱,再選擇你的Silverlight應用程序包並提交上傳(就是你壓縮後的XAP和清單文件的zip包),這樣你的Silverlight應用程序就被託管到Silverlight Streaming服務器上了,值得注意的是,若是你的壓縮包中沒有包含清單文件,上傳後會提示在網頁上手工來建立。
 
完成Silverlight應用程序的託管,最後就是如何將你的應用程序在你須要的位置呈現出來,Silverlight Streaming爲開發者提供了兩種表現方式,分別是使用內嵌的方式和使用Live控件的方式。
 
內嵌方式:內嵌方式與稱爲iframe方式,這種方式部署起來十分簡單,你只須要把整個iframe內的代碼連同iframe標籤一塊兒複製並插入到你網頁內容的任意位置,你的Silverlight應用程序便會在頁面加載後完整呈現出來,代碼以下。
<iframe src=" http://silverlight.services.live.com/invoke/78099/myapp/iframe.html" scrolling="no" frameborder="0" style="width:400px; height:300px"></iframe>
 
Live控件:使用Live控件方式部署分爲三個步驟,首先要爲頁面的<html>標籤加入xmlns特性,而後在<Header>標籤中引用live.js和controls.js,最後在須要的位置加入一個devlive控件,代碼以下。
<html xmlns:devlive=" http://dev.live.com">
<head>
    <title>My Silverlight Application</title>
<script type="text/javascript" src=" https://controls.services.live.com/scripts/base/v0.3/live.js"></script>
<script type="text/javascript" src=" https://controls.services.live.com/scripts/base/v0.3/controls.js"></script>
</head>
<body>
<devlive:slscontrol silverlightVersion="2.0" src="/78099/myapp/">
</devlive:slscontrol>
</body>
</html>
 
p_w_picpath
 
使用Live控件方式部署全部良好的安裝體驗,如圖所示,可是你必須對Silverlight所在的整個頁面有修改的權限,很顯然,第一種內嵌方式方式部署起來更爲靈活方便,因此推薦使用內嵌方式在頁面插入Silverlight應用程序的。
相關文章
相關標籤/搜索