예제 #1
0
        private void Quit(object sender, QuitEventArgs e)
        {
            SdlMixer.Mix_CloseAudio();

            timer.Stop();
            Events.QuitApplication();
        }
예제 #2
0
 /// <summary>
 /// Stops the music processing.
 /// </summary>
 public void Stop()
 {
     // Kill all music
     SdlMixer.Mix_HaltMusic();
     SdlMixer.Mix_HaltChannel(-1);
     SdlMixer.Mix_CloseAudio();
 }
예제 #3
0
        private bool SdlInstalled()
        {
            try
            {
                Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO);
                SdlMixer.Mix_CloseAudio();

                return(true);
            }
            catch (DllNotFoundException e)
            {
                AgateLib.Core.ErrorReporting.Report(AgateLib.ErrorLevel.Warning,
                                                    "A DllNotFoundException was thrown when attempting to load SDL binaries." + Environment.NewLine +
                                                    "This indicates that SDL.dll or SDL_mixer.dll was not found.", e);

                return(false);
            }
            catch (BadImageFormatException e)
            {
                AgateLib.Core.ErrorReporting.Report(AgateLib.ErrorLevel.Warning,
                                                    "A BadImageFormatException was thrown when attempting to load SDL binaries." + Environment.NewLine +
                                                    "This is likely due to running a 64-bit executable with 32-bit SDL binaries.", e);

                return(false);
            }
        }
예제 #4
0
 /// <summary>
 /// Closes and destroys this object
 /// </summary>
 public static void CloseMixer()
 {
     try
     {
         SdlMixer.Mix_CloseAudio();
         if (Sdl.SDL_WasInit(Sdl.SDL_INIT_AUDIO) != 0)
         {
             Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO);
         }
     }
     catch (AccessViolationException)
     { }
 }
예제 #5
0
        private bool SdlInstalled()
        {
            try
            {
                Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO);
                SdlMixer.Mix_CloseAudio();

                return(true);
            }
            catch (DllNotFoundException)
            {
                return(false);
            }
        }
예제 #6
0
        private void Dispose(bool disposing)
        {
            SdlMixer.Mix_CloseAudio();
            Sdl.SDL_QuitSubSystem(Sdl.SDL_INIT_AUDIO);

            foreach (string file in tempfiles)
            {
                try
                {
                    File.Delete(file);
                }
                catch (Exception)
                {
                    System.Diagnostics.Trace.WriteLine(string.Format(
                                                           "Failed to delete the temp file {0}.", file));
                }
            }

            tempfiles.Clear();
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        public void Run()
        {
            Sdl.SDL_Event evt;
            bool          quitFlag = false;
            int           flags    = (Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT);
            int           bpp      = 16;
            int           width    = 352;
            int           height   = 240;

            Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
            Sdl.SDL_WM_SetCaption("Tao.Sdl Example - SmpegPlayer", "");
            surfacePtr = Sdl.SDL_SetVideoMode(
                width,
                height,
                bpp,
                flags);
            SdlMixer.Mix_OpenAudio(SdlMixer.MIX_DEFAULT_FREQUENCY, unchecked (Sdl.AUDIO_S16LSB), 2, 1024);
            Smpeg.SMPEG_Info info = new Smpeg.SMPEG_Info();

            string filepath = @"../../";

            if (File.Exists("Data/SdlExamples.SmpegPlayer.mpg"))
            {
                filepath = "";
            }

            //SdlMixer.MixFunctionDelegate audioMixer = new SdlMixer.MixFunctionDelegate(this.player);
            //int freq;
            //short format;
            //int channels;
            SdlMixer.Mix_CloseAudio();
            IntPtr intPtr = Smpeg.SMPEG_new(filepath + "Data/SdlExamples.SmpegPlayer.mpg", out info, 1);

            //Smpeg.SMPEG_enableaudio(intPtr, 0);
            //SdlMixer.Mix_QuerySpec(out freq, out unchecked(format), out channels);
            //Sdl.SDL_AudioSpec audiofmt = new Tao.Sdl.Sdl.SDL_AudioSpec();
            //audiofmt.freq = freq;
            //audiofmt.format = unchecked(format);
            //audiofmt.channels = (byte) channels;
            //Console.WriteLine("Freq: " + audiofmt.freq);
            //Console.WriteLine("Format: " + audiofmt.format);
            //Console.WriteLine("Channels: " + audiofmt.channels);

            Smpeg.SMPEG_getinfo(intPtr, out info);
            Console.WriteLine("Time: " + info.total_time.ToString());
            Console.WriteLine("Width: " + info.width.ToString());
            Console.WriteLine("Height: " + info.height.ToString());
            Console.WriteLine("Size: " + info.total_size.ToString());
            Console.WriteLine("Smpeg_error: " + Smpeg.SMPEG_error(intPtr));

            //Smpeg.SMPEG_actualSpec(intPtr, ref audiofmt);
            //SdlMixer.Mix_HookMusic(audioMixer, intPtr);
            Smpeg.SMPEG_setdisplay(intPtr, surfacePtr, IntPtr.Zero, null);

            Smpeg.SMPEG_play(intPtr);
            //Smpeg.SMPEG_loop(intPtr, 1);
            //Smpeg.SMPEG_enableaudio(intPtr, 1);

            while ((Smpeg.SMPEG_status(intPtr) == Smpeg.SMPEG_PLAYING) &&
                   (quitFlag == false))
            {
                Sdl.SDL_PollEvent(out evt);

                if (evt.type == Sdl.SDL_QUIT)
                {
                    quitFlag = true;
                }
                else if (evt.type == Sdl.SDL_KEYDOWN)
                {
                    if ((evt.key.keysym.sym == (int)Sdl.SDLK_ESCAPE) ||
                        (evt.key.keysym.sym == (int)Sdl.SDLK_q))
                    {
                        quitFlag = true;
                    }
                }
            }
            Smpeg.SMPEG_stop(intPtr);
            Smpeg.SMPEG_delete(intPtr);
        }
예제 #8
0
 /// <summary>
 ///
 /// </summary>
 private void QuitAudio()
 {
     SdlMixer.Mix_CloseAudio();
     Sdl.SDL_Quit();
 }
예제 #9
0
 public void CloseAudio()
 {
     InitAudio();
     SdlMixer.Mix_CloseAudio();
     Sdl.SDL_Quit();
 }
예제 #10
0
 /// <summary>
 /// Destroy the audio manager and free used resoueces.
 /// </summary>
 public void Destroy()
 {
     SdlMixer.Mix_CloseAudio();
     Sdl.SDL_Quit();
 }