[banshee/gio-hardware] Support XSPF extensions



commit 55a00de41ac35186e28b834937b947040f24dd9b
Author: Aaron Bockover <abockover novell com>
Date:   Mon Aug 2 17:54:30 2010 -0400

    Support XSPF extensions

 .../Mono.Media/Media.Playlists.Xspf/Playlist.cs    |   31 ++++++++++++++++++--
 1 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/src/Libraries/Mono.Media/Media.Playlists.Xspf/Playlist.cs b/src/Libraries/Mono.Media/Media.Playlists.Xspf/Playlist.cs
index 48ff30e..610ab38 100644
--- a/src/Libraries/Mono.Media/Media.Playlists.Xspf/Playlist.cs
+++ b/src/Libraries/Mono.Media/Media.Playlists.Xspf/Playlist.cs
@@ -155,13 +155,38 @@ namespace Media.Playlists.Xspf
 
             date = XmlUtil.ReadDate(playlist_node, xmlns, "xspf:date");
 
-            foreach(XmlNode node in playlist_node.SelectNodes("xspf:trackList/xspf:track", xmlns)) {
+            foreach(XmlNode node in playlist_node.ChildNodes) {
+                if(IsTrackListNode(node)) {
+                    LoadTrackListFromNode(node, xmlns);
+                } else if(IsExtensionNode(node)) {
+                    LoadExtensionNode(node, xmlns);
+                }
+            }
+
+            loaded = true;
+        }
+
+        protected bool IsExtensionNode(XmlNode node)
+        {
+            return node.Name == "extension" && node.NamespaceURI == XspfNamespace;
+        }
+
+        protected bool IsTrackListNode(XmlNode node)
+        {
+            return node.Name == "trackList" && node.NamespaceURI == XspfNamespace;
+        }
+
+        protected virtual void LoadExtensionNode(XmlNode extensionNode, XmlNamespaceManager xmlns)
+        {
+        }
+
+        protected void LoadTrackListFromNode(XmlNode parent, XmlNamespaceManager xmlns)
+        {
+            foreach(XmlNode node in parent.SelectNodes("xspf:track", xmlns)) {
                 Track track = new Track();
                 track.Load(this, node, xmlns);
                 AddTrack(track);
             }
-
-            loaded = true;
         }
 
         public void Load(string path)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]