首先您從XML文件獲取鏈接:
// 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);
}
}
然後你繼續進行下載和播放文件在本博客文章中描述:「Download, Store and Play Media files from Isolated Storage」。你的出發點是你從XML文件獲得的URL。然後來自博客的人和你想要的幾乎一樣。
謝謝;)作品非常好;)一個簡單的例子和簡單易懂;)作品像一個魅力;) – jpmd
感謝您的反饋,並樂意幫助! :) –
在圖像我有多個鏈接的情況下..我想存儲所有的鏈接,以便以後在其他地方使用它..現在的XML只有4個圖像,但未來可能有10個或更多。所以我想保存鏈接以便將內容保存到內存中。你可以幫我嗎?我不知道我是否將這些項存儲在數組中或者類似的東西中。或者可以創建一個圖像類,另一個視頻和其他音頻,並將該分類存儲到該類中。希望您不理解我的英語;) – jpmd