Module: SDL2::Mixer::MusicChannel
- Defined in:
- ext/sdl2_ext/mixer.c,
ext/sdl2_ext/mixer.c
Overview
This module provides the functions to play Music.
Class Method Summary collapse
-
.fade_in(music, loops, ms, pos = 0) ⇒ nil
Play music loops times with fade-in effect.
-
.fade_out(ms) ⇒ nil
Halt the music playback with fade-out effect.
-
.fading ⇒ Integer
Get the fading state of the music playback.
-
.halt ⇒ nil
Halt the music playback.
-
.pause ⇒ nil
Pause the playback of the music channel.
-
.pause? ⇒ Boolean
Return true if a music playback is paused.
-
.play(music, loops) ⇒ nil
Play music loops times.
-
.play? ⇒ Boolean
Return true if a music is playing.
-
.playing_music ⇒ SDL2::Mixer::Music?
Get the Music object that most recently played.
-
.resume ⇒ nil
Resume the playback of the music channel.
-
.rewind ⇒ nil
Rewind the music to the start.
-
.set_position(position) ⇒ nil
Set the position of the currently playing music.
-
.volume ⇒ Integer
Get the volume of the music channel.
-
.volume=(vol) ⇒ vol
Set the volume of the music channel.
Class Method Details
.fade_in(music, loops, ms, pos = 0) ⇒ nil
723 724 725 726 727 728 729 730 731 732 |
# File 'ext/sdl2_ext/mixer.c', line 723
static VALUE MusicChannel_s_fade_in(int argc, VALUE* argv, VALUE self)
{
VALUE music, loops, fade_in_ms, pos;
rb_scan_args(argc, argv, "31", &music, &loops, &fade_in_ms, &pos);
HANDLE_MIX_ERROR(Mix_FadeInMusicPos(Get_Mix_Music(music), NUM2INT(loops),
NUM2INT(fade_in_ms),
pos == Qnil ? 0 : NUM2DBL(pos)));
playing_music = music;
return Qnil;
}
|
.fade_out(ms) ⇒ nil
827 828 829 830 |
# File 'ext/sdl2_ext/mixer.c', line 827
static VALUE MusicChannel_s_fade_out(VALUE self, VALUE fade_out_ms)
{
Mix_FadeOutMusic(NUM2INT(fade_out_ms)); return Qnil;
}
|
.fading ⇒ Integer
Get the fading state of the music playback.
The return value is one of the following:
-
NO_FADING - not fading in, and fading out
-
FADING_IN - fading in
-
FADING_OUT - fading out
863 864 865 866 |
# File 'ext/sdl2_ext/mixer.c', line 863
static VALUE MusicChannel_s_fading(VALUE self)
{
return INT2NUM(Mix_FadingMusic());
}
|
.halt ⇒ nil
Halt the music playback.
816 817 818 819 |
# File 'ext/sdl2_ext/mixer.c', line 816
static VALUE MusicChannel_s_halt(VALUE self)
{
Mix_HaltMusic(); return Qnil;
}
|
.pause ⇒ nil
Pause the playback of the music channel.
770 771 772 773 |
# File 'ext/sdl2_ext/mixer.c', line 770
static VALUE MusicChannel_s_pause(VALUE self)
{
Mix_PauseMusic(); return Qnil;
}
|
.pause? ⇒ Boolean
Return true if a music playback is paused.
843 844 845 846 |
# File 'ext/sdl2_ext/mixer.c', line 843
static VALUE MusicChannel_s_pause_p(VALUE self)
{
return INT2BOOL(Mix_PausedMusic());
}
|
.play(music, loops) ⇒ nil
698 699 700 701 702 703 |
# File 'ext/sdl2_ext/mixer.c', line 698
static VALUE MusicChannel_s_play(VALUE self, VALUE music, VALUE loops)
{
HANDLE_MIX_ERROR(Mix_PlayMusic(Get_Mix_Music(music), NUM2INT(loops)));
playing_music = music;
return Qnil;
}
|
.play? ⇒ Boolean
Return true if a music is playing.
835 836 837 838 |
# File 'ext/sdl2_ext/mixer.c', line 835
static VALUE MusicChannel_s_play_p(VALUE self)
{
return INT2BOOL(Mix_PlayingMusic());
}
|
.playing_music ⇒ SDL2::Mixer::Music?
Get the SDL2::Mixer::Music object that most recently played.
Return nil if no music object is played yet.
875 876 877 878 |
# File 'ext/sdl2_ext/mixer.c', line 875
static VALUE MusicChannel_s_playing_music(VALUE self)
{
return playing_music;
}
|
.resume ⇒ nil
Resume the playback of the music channel.
783 784 785 786 |
# File 'ext/sdl2_ext/mixer.c', line 783
static VALUE MusicChannel_s_resume(VALUE self)
{
Mix_ResumeMusic(); return Qnil;
}
|
.rewind ⇒ nil
Rewind the music to the start.
793 794 795 796 |
# File 'ext/sdl2_ext/mixer.c', line 793
static VALUE MusicChannel_s_rewind(VALUE self)
{
Mix_RewindMusic(); return Qnil;
}
|
.set_position(position) ⇒ nil
805 806 807 808 809 |
# File 'ext/sdl2_ext/mixer.c', line 805
static VALUE MusicChannel_s_set_position(VALUE self, VALUE position)
{
HANDLE_MIX_ERROR(Mix_SetMusicPosition(NUM2DBL(position)));
return Qnil;
}
|
.volume ⇒ Integer
Get the volume of the music channel.
741 742 743 744 |
# File 'ext/sdl2_ext/mixer.c', line 741
static VALUE MusicChannel_s_volume(VALUE self)
{
return INT2FIX(Mix_VolumeMusic(-1));
}
|
.volume=(vol) ⇒ vol
756 757 758 759 760 |
# File 'ext/sdl2_ext/mixer.c', line 756
static VALUE MusicChannel_s_set_volume(VALUE self, VALUE volume)
{
Mix_VolumeMusic(NUM2INT(volume));
return volume;
}
|