Ejemplo n.º 1
0
        // Sound methods (for general sounds)
        public void PlaySound(IMixerSound sound, int channel = -1, bool propagateErrors = false)
        {
            int ret = -1;

            if (sound is MixerSound)
            {
                ret = SDL_mixer.Mix_PlayChannel(channel, sound.GetPointer(), 0);
            }
            else if (sound is MixerMusic)
            {
                ret = SDL_mixer.Mix_PlayMusic(sound.GetPointer(), 1);
            }
            else
            {
                throw new MixerException("Cannot play unknown object");
            }
            if (propagateErrors && ret == -1)
            {
                throw new MixerException();
            }
        }
Ejemplo n.º 2
0
        public int LoopSound(IMixerSound sound, int channel = -1)
        {
            int ret = -1;

            if (sound is MixerSound)
            {
                ret = SDL_mixer.Mix_PlayChannel(channel, sound.GetPointer(), -1);
            }
            else if (sound is MixerMusic)
            {
                ret = SDL_mixer.Mix_PlayMusic(sound.GetPointer(), -1);
            }
            else
            {
                throw new MixerException("Cannot play unknown object");
            }
            if (ret == -1)
            {
                throw new MixerException();
            }
            return(ret);
        }