Class Joyau::Stream
In: Drawable.cpp
Parent: Joyau::AudioObject

Joyau’s class used for rather long music. It loads an OGG file, and plays it as a stream.

Its play method has to be called as often as possible, just like update. These methods return true while the stream is playing, so:

  while stream.update and stream.play

Will loop while there is something to play.

Methods

loadOgg   load_ogg   new   pause   play   stop   update  

Public Class methods

Creates a new Stream. If a filename is given, it is loaded. Examples :

  stream = Joyau::Stream.new
  stream = Joyau::Stream.new("music.ogg")

[Source]

/*
  call-seq: Joyau::Stream.new
            Joyau::Stream.new(filename)

    Creates a new Stream. If a filename is given, it is loaded.
    Examples :
      stream = Joyau::Stream.new
      stream = Joyau::Stream.new("music.ogg")
*/
VALUE wrap<Stream>(int argc, VALUE *argv, VALUE info)
{
   Stream *ptr = new Stream;

   VALUE filename;
   rb_scan_args(argc, argv, "01", &filename);

   if (!NIL_P(filename)) {
      try {
         ptr->loadOgg(StringValuePtr(filename));
      }
      catch (const RubyException &e) {
         e.rbRaise();
      }
   }

   VALUE tdata = Data_Wrap_Struct(info, 0, wrapped_free<Stream>, ptr);
   return tdata;
}

Public Instance methods

Loads a stream. Raises a RuntimeError when something wrong occurs.

[Source]

/*
  call-seq: stream.loadOgg(filename)

  Loads a stream.
  Raises a +RuntimeError+ when something wrong occurs.
*/
VALUE Stream_loadOgg(VALUE self, VALUE filename)
{
   Stream &ref = getRef<Stream>(self);
   char *str = StringValuePtr(filename);

   try  {
      ref.loadOgg(str);
   }
   catch (const RubyException &e) {
      e.rbRaise();
      return Qfalse;
   }
   return Qtrue;
}
load_ogg(p1)

Alias for loadOgg

Plays a stream. Call it as often as possible (i.e. one time per loop).

[Source]

/*
  call-seq: stream.play -> true or false

  Plays a stream. Call it as often as possible (i.e. one time per loop).
*/
VALUE Stream_play(VALUE self)
{
   Stream &ref = getRef<Stream>(self);
   if (ref.play())
      return Qtrue;
   return Qfalse;
}

Plays a stream. Call it as often as possible (i.e. one time per loop).

[Source]

/*
  call-seq: stream.play -> true or false

  Plays a stream. Call it as often as possible (i.e. one time per loop).
*/
VALUE Stream_play(VALUE self)
{
   Stream &ref = getRef<Stream>(self);
   if (ref.play())
      return Qtrue;
   return Qfalse;
}

Stops a stream.

[Source]

/*
  Stops a stream.
*/
VALUE Stream_stop(VALUE self)
{
   Stream &ref = getRef<Stream>(self);
   ref.stop();

   return Qnil;
}

Call it one time per stream.play, just before it.

[Source]

/*
  call-seq: update -> true or false

  Call it one time per stream.play, just before it.
*/
VALUE Stream_update(VALUE self)
{
   Stream &ref = getRef<Stream>(self);
   if (ref.update())
      return Qtrue;
   return Qfalse;
}

[Validate]