From 188e756bc29d0a4ef4f3d7a654160b197c98ee51 Mon Sep 17 00:00:00 2001 From: Koos Vriezen Date: Sat, 10 May 2008 14:09:01 +0200 Subject: [PATCH] Also rudiment video support --- src/laugh-media.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/laugh-media.c b/src/laugh-media.c index c8dcb5b..209f5fc 100644 --- a/src/laugh-media.c +++ b/src/laugh-media.c @@ -137,6 +137,8 @@ void _lauch_media_mime_type (LaughIO *io, const gchar *mime, gpointer d) media->priv->type = LaughMediaTypeImage; } else if (!strncmp (mime, "audio/", 6)) { media->priv->type = LaughMediaTypeAudio; + } else if (!strncmp (mime, "video/", 6)) { + media->priv->type = LaughMediaTypeVideo; } else if (!strcmp (mime, "application/octet-stream")) { if (LaughTagIdAudio) media->priv->type = LaughMediaTypeAudio; @@ -261,11 +263,18 @@ static void _laugh_media_eos (ClutterMedia *media, LaughNode *node) } } +static +void _laugh_media_size_change (ClutterTexture *tex, gint w, gint h, LaughMedia *self) +{ + g_printf ("size_change %d %d\n", w, h); +} + static void _laugh_media_start (LaughNode *node) { LaughMedia *self = (LaughMedia *)node; LaughMediaPrivate *priv = self->priv; LaughNode *region; + ClutterMedia *media = NULL; const gchar *region_id = laugh_node_get_attribute(node, LaughAttrIdRegion); if (!region_id) { @@ -295,28 +304,33 @@ static void _laugh_media_start (LaughNode *node) priv->media_actor = clutter_texture_new_from_pixbuf ( (GdkPixbuf *)priv->data); break; - case LaughMediaTypeAudio: { - ClutterGstAudio *gst = clutter_gst_audio_new (); - ClutterMedia *m = CLUTTER_MEDIA (gst); - - priv->data = gst; - - if (!self->timing_segment->dur) { - self->timing_segment->dur = laugh_timing_new (); - self->timing_segment->dur->type = LaughTimingMedia; - } - self->timing_segment->dur->handler_id = g_signal_connect (G_OBJECT (m), - "eos", (GCallback) _laugh_media_eos, self); - - g_printf ("playing gst %s\n", priv->uri); - clutter_media_set_uri (m, priv->uri); - clutter_media_set_playing (m, TRUE); - + case LaughMediaTypeAudio: + media = (ClutterMedia *) clutter_gst_audio_new (); + priv->data = (gpointer) media; + break; + case LaughMediaTypeVideo: + priv->media_actor = clutter_gst_video_texture_new (); + media = (ClutterMedia *) priv->media_actor; + g_object_set (G_OBJECT(priv->media_actor), "sync-size", FALSE, NULL); + g_signal_connect (CLUTTER_TEXTURE(priv->media_actor), + "size-change", + G_CALLBACK (_laugh_media_size_change), self); break; - } default: break; } + if (LaughMediaTypeAudio == priv->type || LaughMediaTypeVideo == priv->type) { + if (!self->timing_segment->dur) { + self->timing_segment->dur = laugh_timing_new (); + self->timing_segment->dur->type = LaughTimingMedia; + } + self->timing_segment->dur->handler_id = g_signal_connect (G_OBJECT (media), + "eos", (GCallback) _laugh_media_eos, self); + + g_printf ("playing gst %s\n", priv->uri); + clutter_media_set_uri (media, priv->uri); + clutter_media_set_playing (media, TRUE); + } if (priv->media_actor) { gint px, py, pw, ph; float sx, sy, sw, sh; -- 2.11.4.GIT