Search code examples
xmlwindows-phone-7multimedia

Xml multimedia content download


I iwant to know the best way to read an xml file and save the content in a windows phone memory.

The xml is available in this link:

http://dl.dropbox.com/u/32613258/xml_example.xml

The xml file have links to multimedia files like videos, images and sound. I already make the download of the xml file to the memory phone and i know how to read the file, but i don't know how to read the content and save it into the memory phone.

I want to read the xml from the memory and pick all the links in the xml and then download the images, videos and sound into memory. What is the best way to do that? I save the files in isolated storage it's possible save in a card memory?


Solution

  • First you get the links from your XML file:

        // using local XML file for demonstration
        StreamResourceInfo info = Application.GetResourceStream(new Uri("xml_example.xml", UriKind.Relative));
    
        XElement xml = XElement.Load(info.Stream);
        // iterate media files
        foreach (XElement element in xml.Element("graphics").Elements("file"))
        {   
            // pick a video
            if (element.Attribute("type").Value == "video")
            {
                // demoing that we found something
                MessageBox.Show(element.Element("fileurl").Value);
    
                // here goes the real action
                DoSomethingUsefulWithURL(element.Element("fileurl").Value); 
            }
    
        }
    

    And then you proceed with downloading and playing the file as described in this blog post: "Download, Store and Play Media files from Isolated Storage". Your starting point is the URL you got from the XML file. And then the guy from the blog does pretty much the same as you want.