Class: Ray::Music
- Inherits:
-
Object
- Object
- Ray::Music
- Extended by:
- ResourceSet
- Defined in:
- ext/audio.c,
lib/ray/audio.rb,
ext/audio.c
Overview
Class used to play music. Notice only one music can be played at the same time.
Constant Summary collapse
- TYPE_NONE =
INT2FIX(MUS_NONE)
- TYPE_CMD =
INT2FIX(MUS_CMD)
- TYPE_WAV =
INT2FIX(MUS_WAV)
- TYPE_MOD =
INT2FIX(MUS_MOD)
- TYPE_MID =
INT2FIX(MUS_MID)
- TYPE_OGG =
INT2FIX(MUS_OGG)
- TYPE_MP3 =
INT2FIX(MUS_MP3)
- TYPE_MP3_MAD =
INT2FIX(MUS_MP3_MAD)
- TYPE_FLAC =
INT2FIX(MUS_FLAC)
Instance Method Summary collapse
-
#initialize(arg) ⇒ Object
constructor
Creates a new music from an IO object or a filename.
-
#play(times = 1) ⇒ Object
Plays the music a given number of times.
-
#type ⇒ Integer
The type of the music.
Methods included from ResourceSet
[], add_set, missing_pattern, need_argument_count, reject!, required_argument_count, select!, set_hash
Constructor Details
#initialize(arg) ⇒ Object
Creates a new music from an IO object or a filename.
358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'ext/audio.c', line 358
VALUE ray_init_music(VALUE self, VALUE arg) {
if (rb_respond_to(arg, RAY_METH("to_str")))
ray_init_music_with_filename(self, rb_String(arg));
else if (rb_respond_to(arg, RAY_METH("read")))
ray_init_music_with_io(self, arg);
else {
rb_raise(rb_eTypeError, "Can't convert %s into String",
RAY_OBJ_CLASSNAME(arg));
}
return Qnil;
}
|
Instance Method Details
#play(times = 1) ⇒ Object
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'ext/audio.c', line 385
VALUE ray_music_play(int argc, VALUE *argv, VALUE self) {
VALUE times;
rb_scan_args(argc, argv, "01", ×);
if (NIL_P(times)) times = INT2FIX(1);
int c_times = 0;
if (times == RAY_SYM("forever"))
c_times = 0;
else
c_times = NUM2INT(times);
Mix_Music *music = ray_rb2music(self);
Mix_PlayMusic(music, c_times);
return self;
}
|
#type ⇒ Integer
Returns The type of the music.
372 373 374 375 376 377 |
# File 'ext/audio.c', line 372 VALUE ray_music_type(VALUE self) { Mix_Music *music = ray_rb2music(self); Mix_MusicType ret = Mix_GetMusicType(music); return INT2FIX(ret); } |