コード例 #1
0
ファイル: Movie.cs プロジェクト: erin100280/Zelda.NET
 /// <summary>
 /// Closes Music handle
 /// </summary>
 protected override void CloseHandle()
 {
     try
     {
         if (this.Handle != IntPtr.Zero)
         {
             Smpeg.SMPEG_delete(this.Handle);
             this.Handle = IntPtr.Zero;
         }
     }
     catch (NullReferenceException)
     {
     }
     catch (AccessViolationException)
     {
     }
     finally
     {
         this.Handle = IntPtr.Zero;
     }
 }
コード例 #2
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);
        }