Class: Ray::Music
- Inherits:
-
AudioSource
- Object
- AudioSource
- Ray::Music
- Defined in:
- lib/ray/music.rb,
ext/music.c
Instance Method Summary collapse
-
#duration ⇒ Float
Duration of the music.
-
#initialize(filename = nil) ⇒ Music
constructor
A new instance of Music.
- #looping=(val) ⇒ Object
-
#looping? ⇒ true, false
True if the music is looping.
- #open(filename) ⇒ Object
-
#pause ⇒ Object
Pauses the music.
-
#play ⇒ Object
Plays the music (or resume from a pause).
- #pretty_print(q) ⇒ Object
-
#seek(time) ⇒ Object
(also: #time=)
Seeks to a specific time in the music.
-
#stop ⇒ Object
Stops the music.
-
#time ⇒ Float
Current playing offset, in seconds.
Constructor Details
#initialize(filename = nil) ⇒ Music
Returns a new instance of Music.
3 4 5 |
# File 'lib/ray/music.rb', line 3 def initialize(filename = nil) open(filename) if filename end |
Instance Method Details
#duration ⇒ Float
Returns Duration of the music. 0 when no buffer is attached to the music.
71 72 73 74 |
# File 'ext/music.c', line 71 static VALUE ray_music_duration(VALUE self) { return rb_float_new(say_music_get_duration(ray_rb2music(self))); } |
#looping=(val) ⇒ Object
44 45 46 47 48 |
# File 'ext/music.c', line 44
static
VALUE ray_music_set_looping(VALUE self, VALUE val) {
say_music_set_looping(ray_rb2music(self), RTEST(val));
return val;
}
|
#looping? ⇒ true, false
Returns True if the music is looping.
38 39 40 41 |
# File 'ext/music.c', line 38 static VALUE ray_music_is_looping(VALUE self) { return say_music_is_looping(ray_rb2music(self)) ? Qtrue : Qfalse; } |
#open(filename) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'ext/music.c', line 27
static
VALUE ray_music_open(VALUE self, VALUE arg) {
say_music *music = ray_rb2music(self);
if (!say_music_open(music, StringValuePtr(arg))) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
return self;
}
|
#pause ⇒ Object
Pauses the music. Can be resumed using play.
84 85 86 87 88 |
# File 'ext/music.c', line 84 static VALUE ray_music_pause(VALUE self) { say_music_pause(ray_rb2music(self)); return self; } |
#play ⇒ Object
Plays the music (or resume from a pause)
77 78 79 80 81 |
# File 'ext/music.c', line 77 static VALUE ray_music_play(VALUE self) { say_music_play(ray_rb2music(self)); return self; } |
#pretty_print(q) ⇒ Object
7 8 9 |
# File 'lib/ray/music.rb', line 7 def pretty_print(q) super q, ["time", "duration", "looping?"] end |
#seek(time) ⇒ Object Also known as: time=
55 56 57 58 59 |
# File 'ext/music.c', line 55
static
VALUE ray_music_seek(VALUE self, VALUE time) {
say_music_seek(ray_rb2music(self), NUM2DBL(time));
return time;
}
|
#stop ⇒ Object
Stops the music
91 92 93 94 95 |
# File 'ext/music.c', line 91 static VALUE ray_music_stop(VALUE self) { say_music_stop(ray_rb2music(self)); return self; } |
#time ⇒ Float
Returns current playing offset, in seconds.
62 63 64 65 |
# File 'ext/music.c', line 62 static VALUE ray_music_time(VALUE self) { return rb_float_new(say_music_get_time(ray_rb2music(self))); } |