Using Bonobo-Media

Using the Control

To display a multimedia playback widget in your application, just load the data you want to play into a Bonobo::Moniker and resolve it for the Bonobo::Control interface (you can do this automatically via the BonoboWidget API)

GtkWidget *playback = bonobo_widget_new_control ("welcome.mp3", 0);

Screenshot of the player control This will create a Bonobo_Media_PlayerControl, and create a Bonobo::Media::Stream from the supplied stream via the Moniker system.

Using streams directly

If you want to play back multimedia streams from your application (for example, in a snazzy About dialog, as a cut scene in a game, or just to play a notification sound), you should use the Stream interface directly. The following example shows you how you can play a single audio stream from your application.

void create_stream ()
    CORBA_Environment    ev;
    Bonobo_Media_Stream  stream;
    Bonobo_EventSource   event_source;


First, you load your stream into a Bonobo::Media::Stream with the help of a moniker (in this example, the file moniker). Of course, you can also use OAF directly to get a Stream component, then load it via a Persist interface. In the above example, the stream is only needed for a single playback, so you attach a Listener to its EventSource (when available) to get notified when the stream finished. After all is set, start the playback of the stream. Don't forget to free (unref) the stream after you're done with it.

Back to main page