Author: jbevain
Date: 2007-10-11 13:56:20 -0400 (Thu, 11 Oct 2007)
New Revision: 87351
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/dependencyobject.cpp
trunk/moon/src/dependencyobject.h
trunk/moon/src/media.cpp
trunk/moon/src/media.h
trunk/moon/src/playlist.cpp
trunk/moon/src/playlist.h
Log:
2007-10-11 Jb Evain <[EMAIL PROTECTED]>
* dependencyobject.cpp|h: add dependency_object_set_name.
* media.cpp|h: add media_attribute_get_value and
media_attribute_set_value
* playlist.cpp|h: populate MediaAttributeCollection when
a playlist entry is opened.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/ChangeLog 2007-10-11 17:56:20 UTC (rev 87351)
@@ -1,3 +1,13 @@
+2007-10-11 Jb Evain <[EMAIL PROTECTED]>
+
+ * dependencyobject.cpp|h: add dependency_object_set_name.
+
+ * media.cpp|h: add media_attribute_get_value and
+ media_attribute_set_value
+
+ * playlist.cpp|h: populate MediaAttributeCollection when
+ a playlist entry is opened.
+
2007-10-11 Sebastien Pouliot <[EMAIL PROTECTED]>
* xaml.cpp: Let InkPresenter handle childs like a Canvas (from
Modified: trunk/moon/src/dependencyobject.cpp
===================================================================
--- trunk/moon/src/dependencyobject.cpp 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/dependencyobject.cpp 2007-10-11 17:56:20 UTC (rev 87351)
@@ -512,6 +512,13 @@
return obj->GetTypeName ();
}
+// Used by routines which need to create DO from code
+void
+dependency_object_set_name (DependencyObject *obj, const char *name)
+{
+ obj->SetValue (DependencyObject::NameProperty, Value (name));
+}
+
//
// Use this for values that can be null
//
Modified: trunk/moon/src/dependencyobject.h
===================================================================
--- trunk/moon/src/dependencyobject.h 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/dependencyobject.h 2007-10-11 17:56:20 UTC (rev 87351)
@@ -240,6 +240,7 @@
DependencyObject *dependency_object_find_name (DependencyObject *obj, const
char *name, Type::Kind *element_type);
const char *dependency_object_get_name (DependencyObject *obj);
+void dependency_object_set_name (DependencyObject *obj, const char *name);
Type::Kind dependency_object_get_object_type (DependencyObject *obj);
const char *dependency_object_get_type_name (DependencyObject *obj);
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/media.cpp 2007-10-11 17:56:20 UTC (rev 87351)
@@ -1435,12 +1435,24 @@
return new MediaAttribute ();
}
+const char *
+media_attribute_get_value (MediaAttribute *attribute)
+{
+ Value * value = attribute->GetValue (MediaAttribute::ValueProperty);
+ return value ? value->AsString () : NULL;
+}
void
+media_attribute_set_value (MediaAttribute *attribute, const char *value)
+{
+ attribute->SetValue (MediaAttribute::ValueProperty, Value (value));
+}
+
+void
media_init (void)
{
/* MediaAttribute */
- MediaAttribute::ValueProperty = DependencyObject::Register
(Type::MEDIAATTRIBUTE, "Value", new Value (""));
+ MediaAttribute::ValueProperty = DependencyObject::Register
(Type::MEDIAATTRIBUTE, "Value", Type::STRING);
/* MediaBase */
MediaBase::SourceProperty = DependencyObject::Register
(Type::MEDIABASE, "Source", Type::STRING);
Modified: trunk/moon/src/media.h
===================================================================
--- trunk/moon/src/media.h 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/media.h 2007-10-11 17:56:20 UTC (rev 87351)
@@ -33,8 +33,9 @@
};
MediaAttribute *media_attribute_new ();
+const char *media_attribute_get_value (MediaAttribute *attribute);
+void media_attribute_set_value (MediaAttribute *attribute, const char *value);
-
class MediaBase : public FrameworkElement {
public:
static DependencyProperty *SourceProperty;
Modified: trunk/moon/src/playlist.cpp
===================================================================
--- trunk/moon/src/playlist.cpp 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/playlist.cpp 2007-10-11 17:56:20 UTC (rev 87351)
@@ -91,6 +91,8 @@
if (!source->Open ())
return;
+ PopulateMediaAttributes ();
+
if (current_entry->PlayWhenAvailable ())
source->Play ();
}
@@ -142,6 +144,42 @@
{
}
+static void
+add_attribute (MediaAttributeCollection *attributes, const char *name, const
char *attr)
+{
+ if (!attr)
+ return;
+
+ MediaAttribute *attribute = new MediaAttribute ();
+ dependency_object_set_name (attribute, name);
+ media_attribute_set_value (attribute, g_strdup (attr));
+
+ attributes->Add (attribute);
+}
+
+void
+Playlist::PopulateMediaAttributes ()
+{
+ if (!current_entry)
+ return;
+
+ MediaAttributeCollection *attributes;
+
+ Value *value = element->GetValue (MediaElement::AttributesProperty);
+ if (!value) {
+ attributes = new MediaAttributeCollection ();
+ element->SetValue (MediaElement::AttributesProperty, Value
(attributes));
+ } else {
+ attributes = value->AsMediaAttributeCollection ();
+ attributes->Clear ();
+ }
+
+ add_attribute (attributes, "Title", current_entry->GetTitle ());
+ add_attribute (attributes, "Author", current_entry->GetAuthor ());
+ add_attribute (attributes, "Abstract", current_entry->GetAbstract ());
+ add_attribute (attributes, "Copyright", current_entry->GetCopyright ());
+}
+
static bool
check_base (GString *uri, PlaylistContent *content)
{
@@ -201,8 +239,10 @@
return false;
success = source->Open ();
- if (success)
+ if (success) {
+ PopulateMediaAttributes ();
element->mplayer->Seek (current_entry->GetStartTime ());
+ }
return success;
}
Modified: trunk/moon/src/playlist.h
===================================================================
--- trunk/moon/src/playlist.h 2007-10-11 17:36:23 UTC (rev 87350)
+++ trunk/moon/src/playlist.h 2007-10-11 17:56:20 UTC (rev 87351)
@@ -169,6 +169,8 @@
void OnMediaEnded ();
void OnMediaDownloaded ();
+ void PopulateMediaAttributes ();
+
static void on_media_ended (EventObject *sender, gpointer calldata,
gpointer userdata);
static void on_downloader_complete (EventObject *sender, gpointer
calldata, gpointer userdata);
static void on_downloader_data_write (guchar *buf, gsize offset, gsize
count, gpointer data);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches