fixed first start for theme video
[livewp] / applet / src / livewp-scene.c
index 35bf499..adcfeb7 100644 (file)
@@ -1,4 +1,4 @@
-/*vim: set sw=4 ts=4 et: */
+/* vim: set sw=4 ts=4 et: */
 /*
  * This file is part of Live Wallpaper (livewp)
  * 
@@ -65,38 +65,50 @@ parsestring(char *line, char **argv)
                  *argv = '\0';                 /* mark the end of argument list  */
 }
 
+#if 0
+GstBusSyncReply 
+sync_handler(GstBus *bus, GstMessage *message, AWallpaperPlugin *desktop_plugin){
+
+    if (!desktop_plugin->priv->visible)
+        gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PAUSED);
+    if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT){
+               return (GST_BUS_PASS);
+       }
+    if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")){
+        return (GST_BUS_PASS);
+    }
+    return (GST_BUS_DROP);
 
+}
+#endif
 void
-init_scene_Mplayer(AWallpaperPlugin *desktop_plugin)
+init_scene_Video(AWallpaperPlugin *desktop_plugin)
 {
-    GstElement *pipeline;                                                                                                                    
     GstElement *bin;                                                                                                                                                           
     GstElement *videosink;                                                                                                
     GstFormat format; 
+    gchar *file_plus_uri;
 
 
-
-    fprintf(stderr,"dddddddddddddddddddd\n");
-    pipeline= gst_pipeline_new("gst-player");
+    desktop_plugin->priv->pipeline= gst_pipeline_new("gst-player");
     bin = gst_element_factory_make ("playbin2", "bin");
     videosink = gst_element_factory_make ("ximagesink", "videosink");
     g_object_set (G_OBJECT (bin), "video-sink", videosink, NULL);
-    gst_bin_add (GST_BIN (pipeline), bin);
+    gst_bin_add (GST_BIN (desktop_plugin->priv->pipeline), bin);
 
     {
        GstBus *bus;
-       bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+       bus = gst_pipeline_get_bus (GST_PIPELINE (desktop_plugin->priv->pipeline));
 //     gst_bus_add_watch(bus, bus_call, NULL);
-//     gst_bus_set_sync_handler(bus, (GstBusSyncHandler)SetVideoAreaXID, desktop_plugin);
        gst_object_unref (bus);
     }
-    g_object_set (G_OBJECT (bin), "uri", "file:///home/user/MyDocs/.videos/9.mp4", NULL );
+    file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
+    g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
     g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL  );
-    if (GST_IS_X_OVERLAY (videosink)){
-           printf("Is Overlay (Win ID: %i)!!\n",GPOINTER_TO_INT(GDK_WINDOW_XWINDOW(desktop_plugin->priv->window->window)));
+    if (GST_IS_X_OVERLAY (videosink))
            gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
-    }
-    gst_element_set_state (pipeline, GST_STATE_PLAYING);
+    if (desktop_plugin->priv->visible)
+        gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
 }
 
 void