Showing posts with label gnash. Show all posts
Showing posts with label gnash. Show all posts

Monday, June 15, 2009

Progress on Sugar activities with SWF content

Following the work I did some months ago, Rob Savoye has been kind enough to update the rpm spec of Gnash to also produce rpms for the SDK and for the python bindings for embedding the player.

This will allow us to run activities that use Flash content in the next release of Sugar, 0.86. Rob has also updated the .deb control files so this work is well under its way to be in the next releases of all the major distros.

If you want to try it today, you can install some rpms in the Fedora 11-based Sugar on a Stick and run EatBoom, a sample activity that contains a flash game developed by Innovations for Learning. It is a simple game for practising additions that is part of their TeacherMate product. IFL has released this activity as GPL and I hope they will find value in releasing more of their work so it can be used by children in Sugar or in other platforms.

Step 1: download the last SoaS snapshot from here.

Step 2: install it to a USB stick following this instructions and boot it in your computer.

Step 3: start the terminal activity and run the commands below:

su -
curl -O http://shell.sugarlabs.org/~tomeu/gnash/gnash-0.8.5-4.20090615bzr11113.fc11.i586.rpm
curl -O http://shell.sugarlabs.org/~tomeu/gnash/gnash-plugin-0.8.5-4.20090615bzr11113.fc11.i586.rpm
curl -O http://shell.sugarlabs.org/~tomeu/gnash/gnash-widget-0.8.5-4.20090615bzr11113.fc11.i586.rpm
rpm -U *.rpm

Step 4: start Browse and type the following URL: http://shell.sugarlabs.org/~tomeu/EatBoom-1.xo The EatBoom activity will be downloaded and installed.

Step 5: Run EatBoom!




Here you have the source for the activity, which can be changed to load a different SWF movie by changing just a single line of code: http://git.sugarlabs.org/projects/eatboom

Monday, April 20, 2009

Embed flash movies with gnash in your gtk apps

Has been a week full of hacking fun since I started to work on a Gnash gtk widget. Some frustration as well because it's the first time I deal with C++ code using boost and modern stuff like std_ptr and, of course, libtool and friends. This bit of work comes in line with my earlier posts about embedding Evince, Abiword and Mozilla.

But the effort has born its fruits, and now we can run all of Gnash as a gtk widget inside a Sugar activity:


And this is the code:

import os

import gtk
import gnash

from sugar.activity import activity

class EatBoomActivity(activity.Activity):
def __init__(self, handle, browser=None):
activity.Activity.__init__(self, handle)

toolbox = activity.ActivityToolbox(self)
self.set_toolbox(toolbox)
toolbox.show()

view = gnash.View()
view.load_movie(os.path.join(activity.get_bundle_path(), 'EatBoom.swf'))
view.start()
self.set_canvas(view)
view.show()


For non-Sugar-enabled gtk people, you will be able to embed gnash doing something like this:

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

view = gnash_view_new ();

gtk_container_add (GTK_CONTAINER (window), view);
gtk_widget_show (view);

gtk_widget_show (window);

gnash_view_load_movie(GNASH_VIEW(view), argv[1]);
gnash_view_start(GNASH_VIEW(view));

This is without using GtkPlug and, of course, running inside the same process. So by adding methods to the C widget we can control all of the Gnash engine and expose it trivially to python with pygtk. And through the use of Gnash extensions, we can extend the ActionScript class library with Sugar specifics so it integrates well with the rest of the environment.

This is still a proof of concept, but plan to start working right now in finding a way to integrate it in upstream Gnash.