开发者

Silverlight 4 MediaElement Source Uri problems

开发者 https://www.devze.com 2023-01-07 05:16 出处:网络
I am having issues with setting the Silverlight 4 MediaElement Source property in my ASP.NET MVC 2 application. I have a Windows 7 development machine and a Windows Server 2008 staging server.

I am having issues with setting the Silverlight 4 MediaElement Source property in my ASP.NET MVC 2 application. I have a Windows 7 development machine and a Windows Server 2008 staging server.

Locally I have been using a MediaElement source like:

<MediaElement x:Name="VideoMediaElement" Source="Assets/126.mp4">
...
</MediaElement>

This source works on my development machine and my staging server, but I found that this was only working in Google Chrome. After a great deal of research and testing I converted my app to set the source to be:

<MediaElement x:Name="VideoMediaElement" Source="http://localhost:40000/ClientBin/Assets/126.mp4">
...
</MediaElement>

Using this type of Uri allows my video to play on my local server in Internet Explorer as well as Google Chrome. When I push this up to my staging server the path is calculated to be:

<MediaElement x:Name="VideoMediaElement" Source="http://myDomain/MyVirtualDir/ClientBin/Assets/126.mp4">
...
</MediaElement>

This looks fine to me, but the video will not play in any browser on the staging server.

The differences I see between my development environment and the staging server is the virtual directory. Are there known problems or tricks when setting a full Uri that includes a virtual directory?

What is the preferred method for loading a video file from a开发者_StackOverflow中文版 file structure into a Silverlight 4 MediaElement?


My first steps in diagnosing this would be:-

  • stop using chrome. Make it all work in IE then test other browsers.
  • stop using the full URL. Given that the XAP, the host page and the resource are all on the same server we know we shouldn't need it so lets not use it.
  • Don't use a browser running on the staging server, use another Client machine to test with.
  • Install Fiddler2 on the client machine as server info suggests and see what is actually being requested.

Have you tried "/assets/126.mp4" instead of "assets/126.mp4" ?

If you are getting a 404 from a URL that looks good check the server mime map, is there a mapping for .mp4?

Also check file access security.


Did check fiddler what the actual http request/response tells you? Maybe there are security infos (cross-domain access) or at least you get more details what's going on under the cover... you can find fiddler right here: http://www.fiddler2.com/fiddler2/

0

精彩评论

暂无评论...
验证码 换一张
取 消