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.
Creates a new Stream. If a filename is given, it is loaded. Examples :
stream = Joyau::Stream.new stream = Joyau::Stream.new("music.ogg")
/* 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; }
Loads a stream. Raises a RuntimeError when something wrong occurs.
/* 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; }
Plays a stream. Call it as often as possible (i.e. one time per loop).
/* 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).
/* 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.
/* Stops a stream. */ VALUE Stream_stop(VALUE self) { Stream &ref = getRef<Stream>(self); ref.stop(); return Qnil; }