System.OutOfMemoryException when using MediaElement in Silverlight 3
-
13-09-2019 - |
Question
I'm trying to build a simple Silverlight 3 MediaPlayer using the MediaElement tag:
<Border Margin="8,8,0,8" Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1" CornerRadius="7">+
<MediaElement x:Name="FighterPilot" Source="http://localhost/repository/FighterPilot.wmv" Stretch="Fill"/>
</Border>
This works very well for low resolution wmv files. But when a WMV File that has a 720p resolution, i get the build error
Xap packaging failed: System.OutOfMemoryException
Do anyone have any clue why I get this build error?
Thankful for any help on this one!
Update: The PC I'm developing on has loads of free RAM, so memory shouldn't be a problem.
Solution
No, I've never had that problem. The easy solution would be to not include the wmv file in the Silverlight project. You could add it somewhere in the ASP.NET project instead to avoid it being packaged in the xap all together.
OTHER TIPS
Assuming that you are using Visual Studio and the WMV file is in your Silverlight project, set the build action on the WMV file to "None" and set "Copy to output directory" to "Copy Always". That way it will not get bundled with the XAP file.
Or you could consider putting the WMV file in a "Video" directory under the ClientBin folder in the website which you can then access using the following:
FighterPilot.Source = new Uri("/Video/FighterPilot.wmv", UriKind.Relative);
This post has an answer: http://forums.silverlight.net/forums/p/138497/313054.aspx