views:

226

answers:

2

I've been developing a game using Silverlight 4 and silversprite (http://silversprite.codeplex.com/)

This game is HEAVILY content dependent, using a lot of audio and images. My content folder is around 90 mbs worth of stuff. And because of that, my XAP file is around 60 MB, and takes 5 minutes to download from the website before any user can start playing.

I am using Visual Web Developer 2010 to create my site and load the XAP. Is there a way where I can take content out of my XAP and put it in my ASP.net site project? Or perhaps upload my content files to the site's storage? This would make my XAP file much quicker to download.

Anyone have suggestions? Thanks!

+3  A: 

Absolutley its called Application Library Caching. Ive used it very successfully its now a standard operating procedure, particularly nice is its application with resource assemblies.

straight from msdn ...

Resource files are typically any non-executable data file used by your application, such as image, audio, and video files. A resource file can also have specific meanings in certain contexts. For example, in the context of application localization, resource files refer to .resx files, which you can deploy in localized satellite assemblies.

it continues with some really useful info

With Silverlight, you can deploy resource files in the following ways:

•As individual files in the application package.

•As individual files that you retrieve on demand.

•As files embedded in an assembly in the application package.

•As files embedded in an assembly in an external library package.

•As files embedded in an assembly that you retrieve on demand.

which is what is suggested in the other answer(s)

almog.ori
This doesn't really help much in this scenario. It is useful when your xap changes since the existing library zips remain static and often do not need downloading again. However if they are bumped out of the browsers cache or on first time a client visits all the libraries are downloaded before the application loads. It would be nice if Silverlight were able to determine which libraries are needed and those that aren't at start up but it doesn't.
AnthonyWJones
actually you can create you own libraries (which can contain anything you want) and have the framework handle the caching (not bad :) ), there is no other way around that unless you you go out of browser or request more space from the user both are jaring (and ment to be so)
almog.ori
also syntax wise its alot friendlier as you would be using a resource wrapper generated for you.
almog.ori
@almog: I was responding to your first version of your answer where you offer application library caching as a solution. I'm pointing out that this specificaly does not help the scenario outlined in the question. There are other techniques that, as you later posted, the documentation mentions. One of these approaches is what I've outlined in my answer.
AnthonyWJones
sorry about that my first version was a bit vague, i do admit that your answer does fit better for this question, i simply ment theres more than one way to skin a cat, so i felt my answer has merit.
almog.ori
+4  A: 

Yes, include in your XAP only content you need for the initial screen. Place other content you need in other XAPs (if you need to and understand the manifest xml) or just plain zip files would do. Perhaps a Zip for each "Level" or whatever.

You can download the Zip with WebClient and then use StreamResourceInfo and Application.GetResourceStream to access content in the zip file.

This blog although aging a little now still carries the basic idea and is still fundementally the current technique to use.

AnthonyWJones
I have looked into this method AND it seems great! Although I have a particular situation: I am programming in Silversprite, not pure Silverlight: this means, I am not coding my game within xaml files. My XAP consists of a pure C# .cs files. So this is making it very hard. I have a website project and my Silverlight (silversprite) project within the same solution. So this is what I'm wondering:Option #1: WITHIN my silersprite project, I use Texture2D.FromFile, and load a texture from my external website.Option #2: I reference and load a texture from my WEBSITE project.Any advice?
theoneawaited
@thwoneawaited: Whether you are using Xaml or mainly C# the bulk of your XAP will be resources such as images, audio etc. What I'm suggesting is that you place these resources in separate zip files. You can use methods such as Texture2D.FromFile to load from a stream. The stream in turn is acquired using `Application.GetResoureStream`.
AnthonyWJones