views:

121

answers:

2

Hi guys, I need some help with the createobject function in Silverlight. My xap file accepts a video url and loads it for playing. When I write a tag as follows, it works fine.

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"   
width="100%" height="100%">
  <param name="source" value="ClientBin/VideoPlayer.xap"/>
  <param name="onerror" value="onSilverlightError" />
  <param name="background" value="white" />
  <param name="minRuntimeVersion" value="2.0.31005.0" />
  <param name="autoUpgrade" value="true" />
  <param name="MediaSource" value="video.wmv" />   
 </object>

Although when I try to create this object using Silverlight.createObject, it does not play any video.

Silverlight.createObject(
                "ClientBin/VideoPlayer.xap",
                document.getElementById('silverlightHost'),
                "slPlugin",
                {
                    width: "400", height: "300",
                    background: "Black",
                    isWindowless: "true",
                    version: "2.0.31005.0",
                    alt: "fg"
                },
                { onError: onSilverlightError },
                "MediaSource=video.wmv",
                "context"
            );

Am I missing something silly here.

A: 

MediaSource isn't a parameter for the tag so I'm surprised that is working and assuming that it is using a default value and not what you are passing in when using the , but I'm assuming your app has an initParam that you are wanting to set. It's hard to tell only by this post, but if your app has an initParam, make sure you are using the correct named parameter.

Tim Heuer
A: 

Is it possible that this:-

 <param name="MediaSource" value="video.wmv" />

ought to be this:-

 <param name="intiParams" value="MediaSource=video.wmv" />

?

AnthonyWJones