No Links were listed yet. Go ahead and share!
Hi, I’m Jaime Rodriguez and this is using the Microsoft Silverlight Downloader Object. When writing rich internet applications using Silverlight sometimes you want to download for rich content like video or maybe a sequence of images or something like that and you know the process is going to take a little bit of time so you want to first of all not downloaded at ahead of time and when you download it you want to show a little bit of a progress bar or status report so that the user knows what is going on and this is exactly what the downloader object will let you do.
In this next couple of minutes we’ll cover very quickly how to download our object works and how simple it is to use. So let’s type some code. Here I have you just a very simple sample page that has a couple of controls and nothing but mostly visual stuff and in the JavaScript I actually have all the code needed to actually used my downloader object. It begins here where I’m just instantiating by saying Ctrl.create object downloader. That’s the name of the class and then you can see here that there are three events that I’m interested when using the downloader object.
The first one is completed which obviously self explanatory. Download progress change will get which will be caught as a call back and your last progress goes when you’re downloaded and download fail which obviously you used to report an error.
In order to make a downloader call, you use this very xml http like api where you just call a downloader open and you give it to get protocol which is the one supported right now. And then you give it the name of the file or video or whatever you’re downloaded and then the third primary is whether you want to be synchronize in it or asynchronize. In this case true, we’re going to be asynchronize for a call and then after that you just call send and then the downloader object will do all the work and obviously if this call succeeds then we will actually come here to download completed and then we will have that file available. And in this demos, where in the first demo where I actually going to download a video. So if I download a video then I can go into my media element and then just set source and then in this case because it’s just a video the parameter to set source is empty. If I was downloading a zip file that contains multiple videos then I will be passing the name of the video into the second parameter.
In my second example, I actually download one zip file that contains a lot of images to create kind of an image animation. So here you see that I have a little bit of code to actually have a call back that is going to display the images. And if you see the call back, which will be this one you see that here I’m setting the set source for the image and I’m passing a name of the image that I want to use. So it’s very, very straightforward. Again if I was to lock it to this just call in the downloader object, first I subscribe to the events, completed download progress change and download fail. You don’t necessarily need to subscribe to all and then you just say open and send and then you get your data back.
So let’s go see this in action. What I have here is the image and I have just cleared my cache. So first let just you know click here home video which is going to download a video. And you can see that it was growing, reporting the progress, right? And then if I click package right here, this is actually going to download a zip file with a sequence of images that will actually play as part of that animation, so I go ahead click package and you can see it’s playing this new control like animation as you would see it if you where seeing some HD video on TV. So that’s how simple it is to use the downloader object.
If you want to see the zip file, it is a straight zip file. You can go here right here where you control that zip file. It’s the file that I was downloading and it’s just a zip file with a sequence of images and I was just passing the name to fetch the image back. Here in the zip file I could actually include sample file, java script anything as I want I could actually include fonts for example. It could be included to and the downloader object knows how to download this zip file and how to query into it to extract the files. So go ahead and have fun with downloader object. Thanks.
Transcription by:
Scribe4you Transcription Services