Once a Silverlight application has been uploaded to Silverlight Streaming, you can put a reference to it on any web page.
To invoke a hosted Silverlight Streaming application on a web page, you use the same general markup and JavaScript file structure that you would use for invoking a non-hosted Silverlight application, with the following exceptions:
-
Instead of hosting Silverlight.js on your own web site, use http://agappdom.net/h/silverlight.js.
-
In your CreateSilverlight.js or equivalent file, call Silverlight.createHostedObjectEx() instead of Silverlight.createObject() or createObjectEx(). Because the application specifies most of the startup parameters in its manifest.xml files, the only two meaningful parameters are source and parentElement.
-
For the source parameter, instead of naming a XAML file, provide the service name for the hosted application. These always have the form streaming:/accountId/applicationName, where accountId is your Silverlight Streaming account id and applicationName is the name you gave your application when you uploaded it.
If you go the "Manage Applications" section of the Silverlight Streaming administration web site and click on one of your applications, you'll see a copy of these instructions customized for that application.
When your web page invokes Silverlight.createHostedObjectEx(), that function queries the service to construct and deliver a specialized web page containing just the application named in the call. This web page is hosted in an <iFrame> on the calling web page.
Caution: |
|---|
|
Although the hosted application is running in its own <iFrame>, your web page might still be vulnerable to cross-site scripting issues. You should only invoke applications from trusted authors on your web pages.
|
Imagine that the owner of account 2 has uploaded the grand piano sample as "piano". Then a sample web page to host it could look like:
<html>
<head>
<script type="text/javascript"
src="http://agappdom.net/h/silverlight.js"></script>
<script type="text/javascript" src="CreateSilverlight.js"></script>
</head>
<body>
<div class="aghost" id="myApp">
<script type="text/javascript">
var pe = document.getElementById("myApp");
CreateSilverlight();
</script>
</div>
</body>
</html>
In CreateSilverlight.js, you would write:
Silverlight.createHostedObjectEx({
source: "streaming:/2/piano",
parentElement: pe
});
Concepts
Silverlight Streaming QuickStarts