[ease/video: 1/2] [video] Restore video element/actor files.



commit 41f7d826ecd1eac129888af111c076d1dac104c0
Author: Nate Stedman <natesm gmail com>
Date:   Wed Jul 28 20:11:37 2010 -0400

    [video] Restore video element/actor files.

 configure.ac                      |    6 +-
 ease-core/Makefile.am             |    2 +
 ease-core/ease-video-actor.vala   |  153 +++++++++++++++++++++++++++++++++++++
 ease-core/ease-video-element.vala |   69 +++++++++++++++++
 4 files changed, 229 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a7ba550..9be07bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ pkg_modules=" \
 	clutter-gtk-0.10 >= 0.10 \
 	libarchive \
 	json-glib-1.0 >= 0.7.6\
+	clutter-gst-1.0 \
 	gmodule-2.0"
 
 EASE_PACKAGES=" \
@@ -49,6 +50,7 @@ EASE_PACKAGES=" \
 	--pkg clutter-gtk-0.10 \
 	--pkg libarchive \
 	--pkg json-glib-1.0 \
+    --pkg clutter-gst-1.0 \
 	--pkg gmodule-2.0"
 
 EASE_CFLAGS="\`pkg-config --cflags \
@@ -56,13 +58,15 @@ EASE_CFLAGS="\`pkg-config --cflags \
 	clutter-gtk-0.10 \
 	json-glib-1.0 \
 	libarchive \
+	clutter-gst-1.0 \
 	gmodule-2.0 \`"
 
 EASE_LDFLAGS="\`pkg-config --libs \
 	gee-1.0 \
 	clutter-gtk-0.10 \
 	json-glib-1.0 \
-	libarchive
+	libarchive \
+	clutter-gst-1.0 \
 	gmodule-2.0 \`"
 
 PKG_CHECK_MODULES(EASE, [$pkg_modules])
diff --git a/ease-core/Makefile.am b/ease-core/Makefile.am
index 85bbba9..9aef3eb 100644
--- a/ease-core/Makefile.am
+++ b/ease-core/Makefile.am
@@ -45,6 +45,8 @@ libease_core_0_3_la_SOURCES = \
 	ease-undo-item.vala \
 	ease-undo-source.vala \
 	ease-utilities.vala \
+	ease-video-actor.vala \
+	ease-video-element.vala \
 	ease-zoom-slider.vala \
 	$(NULL)
 
diff --git a/ease-core/ease-video-actor.vala b/ease-core/ease-video-actor.vala
new file mode 100644
index 0000000..b63b688
--- /dev/null
+++ b/ease-core/ease-video-actor.vala
@@ -0,0 +1,153 @@
+/*  Ease, a GTK presentation application
+    Copyright (C) 2010 Nate Stedman
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * { link Actor} for videos
+ *
+ * VideoActor uses Clutter-GStreamer, and therefore supports any video
+ * format supported by the GStreamer plugins on the user's system.
+ *
+ * VideoActor "implements" Clutter.Media by passing through all function calls
+ * to its VideoTexture.
+ */
+public class Ease.VideoActor : Actor, Clutter.Media
+{
+	/**
+	 * The VideoTexture displayed by this VideoActor.
+	 */
+	private ClutterGst.VideoTexture video;
+
+	/**
+	 * Instantiates a new VideoActor from an Element.
+	 * 
+	 * The VideoActor's context is particularly important due to playback.
+	 * Playing back automatically in the editor would, of course, not be
+	 * desired.
+	 *
+	 * @param e The represented element.
+	 * @param c The context of this Actor (Presentation, Sidebar, Editor)
+	 */
+	public VideoActor(VideoElement e, ActorContext c)
+	{
+		base(e, c);
+
+		video = new ClutterGst.VideoTexture();
+		video.set_filename(Path.build_filename(e.parent.parent.path,
+		                                       e.filename));
+
+		// play the video if it's in the presentation
+		if (c == ActorContext.PRESENTATION)
+		{
+			video.set_playing(true);
+		}
+		else
+		{
+			// FIXME: toggle playback to get a frame
+			video.set_playing(true);
+			video.set_playing(false);
+		}
+		
+		contents = video;
+
+		add_actor(contents);
+		contents.width = e.width;
+		contents.height = e.height;
+		x = e.x;
+		y = e.y;
+	}
+	
+	public double get_audio_volume()
+	{
+		return video.get_audio_volume();
+	}
+	
+	public double get_buffer_fill()
+	{
+		return video.get_buffer_fill();
+	}
+	
+	public bool get_can_seek()
+	{
+		return video.get_can_seek();
+	}
+	
+	public double get_duration()
+	{
+		return video.get_duration();
+	}
+	
+	public bool get_playing()
+	{
+		return video.get_playing();
+	}
+	
+	public double get_progress()
+	{
+		return video.get_progress();
+	}
+	
+	public unowned string get_subtitle_font_name()
+	{
+		return video.get_subtitle_font_name();
+	}
+	
+	public unowned string get_subtitle_uri()
+	{
+		return video.get_subtitle_uri();
+	}
+	
+	public unowned string get_uri()
+	{
+		return video.get_uri();
+	}
+	
+	public void set_audio_volume(double volume)
+	{
+		video.set_audio_volume(volume);
+	}
+	
+	public void set_filename(string filename)
+	{
+		video.set_filename(filename);
+	}
+	
+	public void set_playing(bool playing)
+	{
+		video.set_playing(playing);
+	}
+	
+	public void set_progress(double progress)
+	{
+		video.set_progress(progress);
+	}
+	
+	public void set_subtitle_font_name(string font_name)
+	{
+		video.set_subtitle_font_name(font_name);
+	}
+	
+	public void set_subtitle_uri(string uri)
+	{
+		video.set_subtitle_uri(uri);
+	}
+	
+	public void set_uri(string uri)
+	{
+		video.set_uri(uri);
+	}
+}
+
diff --git a/ease-core/ease-video-element.vala b/ease-core/ease-video-element.vala
new file mode 100644
index 0000000..6867bd4
--- /dev/null
+++ b/ease-core/ease-video-element.vala
@@ -0,0 +1,69 @@
+/*  Ease, a GTK presentation application
+    Copyright (C) 2010 Nate Stedman
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * A { link MediaElement} subclass for playing a vide. Linked with
+ * { link VideoActor}.
+ */
+public class Ease.VideoElement : MediaElement
+{
+	public override Actor actor(ActorContext c)
+	{
+		return new VideoActor(this, c);
+	}
+	
+	public override string html_render(HTMLExporter exporter)
+	{
+		// open the tag
+		var html = "<video class=\"video element\" ";
+		
+		// set the video's style
+		html += "style=\"";
+		html += "left:" + x.to_string() + "px;";
+		html += " top:" + y.to_string() + "px;";
+		html += " position: absolute;\" ";
+		
+		// set the video's size
+		html += " width=\"" + width.to_string() + "\" ";
+		html += " height=\"" + width.to_string() + "\" ";
+		
+		// set the video's source and controls
+		html += "src=\"" + exporter.path + " " +
+		        filename + "\" " +
+		        "controls=\"yes\">" +
+		        _("Your browser does not support the video tag") + 
+		        "</video>";
+		        
+		// copy the video file
+		exporter.copy_file(filename, parent.parent.path);
+		
+		return html;
+	}
+	
+	public override Gtk.Widget inspector_widget()
+	{
+		var label = new Gtk.Label("No inspector for videos right now...");
+		label.show();
+		return label;
+	}
+
+	public override void cairo_render(Cairo.Context context) throws Error
+	{
+		warning("Video elements don't support Cairo right now...");
+	}
+}
+



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