Exemplo n.º 1
0
        /*
         *      FpsTimer timer = new FpsTimer();
         *      timer.Fps = 30;
         *
         *      KeyBoardInput key = new KeyBoardInput();
         *
         *      SDLWindow2DGl window = new SDLWindow2DGl();
         *      window.SetVideoMode(800, 600, 0);
         *
         *      GlTexture tx = new GlTexture();
         *      Movie movie = new Movie();
         *      movie.Load("test.mpg");
         *      tx.SetSurface(movie.Surface);
         *      movie.IsLoop = true;
         *      movie.Play();
         *
         *      while (SDLFrame.PollEvent() == Yanesdk.Ytl.YanesdkResult.NoError) {
         *              key.Update();
         *
         *              if (key.IsPush(KeyCode.b)) {
         *                      break;
         *              } else if (key.IsPush(KeyCode.p)) {
         *                      movie.Play();
         *              } else if (key.IsPush(KeyCode.s)) {
         *                      movie.Stop();
         *              } else if (key.IsPush(KeyCode.q)) {
         *                      movie.Pause();
         *              } else if (key.IsPush(KeyCode.r)) {
         *                      movie.Resume();
         *              }
         *
         *              window.Screen.Select();
         *              if (movie.IsReadyToDraw) {
         *                      movie.Draw(tx);
         *                      //window.Screen.Blt(tx, 0, 0);
         *                      window.Screen.Blt(tx, 0, 0,
         *                              new Yanesdk.Draw.Rect(0, 0, tx.Width, tx.Height),
         *                              new Yanesdk.Draw.Size(window.Width, window.Height));
         *              }
         *              window.Screen.Update();
         *
         *              timer.WaitFrame();
         *      }
         */
        #endregion

        #region Win32Windowに描画するサンプルソース

        /*
         * public partial class Form7 : Form
         * {
         * public Form7()
         * {
         *      InitializeComponent();
         *
         *      init();
         * }
         *
         * Movie movie = new Movie();
         *
         * // ボタンハンドラ×4↓ Formデザイナで適当にボタンを配置して使ってちょうだい。
         * private void button1_Click(object sender, EventArgs e)
         * {
         *      movie.Play();
         * }
         *
         * private void button2_Click(object sender, EventArgs e)
         * {
         *      movie.Pause();
         * }
         *
         * private void button3_Click(object sender, EventArgs e)
         * {
         *      movie.Resume();
         * }
         *
         * private void button4_Click(object sender, EventArgs e)
         * {
         *      movie.Stop();
         * }
         *
         * public void init()
         * {
         *      timer.Fps = 30;
         *
         *      window = new Win32Window(this.Handle);
         *      window.Screen.Select();
         *
         *      tx = new GlTexture();
         *      movie.Load("test.mpg");
         *      tx.SetSurface(movie.Surface);
         *      movie.IsLoop = true;
         *
         *      window.Screen.Unselect();
         * //	movie.Play();
         * }
         *
         * FpsTimer timer = new FpsTimer();
         * Win32Window window;
         * GlTexture tx;
         *
         * private void timer1_Tick(object sender, EventArgs e)
         * {
         *      if (timer.ToBeRendered)
         *      {
         *              window.Screen.Select();
         *              if (movie.IsReadyToDraw)
         *              {
         *                      movie.Draw(tx);
         *                      if (rot == 0)
         *                      {
         *                              window.Screen.Blt(tx, 0, 0 , null,null);
         *                      //	window.Screen.Blt(tx, 0, 0,
         *                      //		new Yanesdk.Draw.Rect(0, 0, tx.Width, tx.Height),
         *                      //		new Yanesdk.Draw.Size(this.Width, this.Height));
         *                      }
         *                      else
         *                      {
         *                              // 試しにムービーをまわしてみる。
         *                              window.Screen.BltRotate(tx, 0, 0, rot, 1.0f, 200, 200);
         *                      }
         *              }
         *              window.Screen.Update();
         *
         *              rot += rotateStep;
         *
         *              timer.WaitFrame();
         *      }
         * }
         *
         * int rot = 0;
         * int rotateStep = 0;
         * private void button5_Click(object sender, EventArgs e)
         * {
         *      rotateStep++;
         * }
         * }
         */
        #endregion

        #region ctor and Dispose
        /// <summary>
        /// オーディオの再生周波数等は、Yanesdk.Sound.Sound.SoundConfigで設定された値で初期化される。
        /// </summary>
        public Movie()
        {
            callback = new SMPEG.SMPEG_DisplayCallback(smpeg_DisplayCallback);
            //mix_hook = new SDL.mix_func_t(SMPEG.SMPEG_playAudioSDL);
            mix_hook = new SDL.mix_func_t(mix_HookMusic);

            // 排他処理オブジェクトの作成
            mutex = SDL.SDL_CreateMutex();

            // MasterVolumeが変更されたときにそれに追随して再生Volumeが変更されるように。
            Yanesdk.Sound.Sound.ChunkManager.OnMasterVolumeChanged
                += OnMasterVolumeChanged;
        }
Exemplo n.º 2
0
		/*
			FpsTimer timer = new FpsTimer();
			timer.Fps = 30;

			KeyBoardInput key = new KeyBoardInput();

			SDLWindow2DGl window = new SDLWindow2DGl();
			window.SetVideoMode(800, 600, 0);

			GlTexture tx = new GlTexture();
			Movie movie = new Movie();
			movie.Load("test.mpg");
			tx.SetSurface(movie.Surface);
			movie.IsLoop = true;
			movie.Play();

			while (SDLFrame.PollEvent() == Yanesdk.Ytl.YanesdkResult.NoError) {
				key.Update();

				if (key.IsPush(KeyCode.b)) {
					break;
				} else if (key.IsPush(KeyCode.p)) {
					movie.Play();
				} else if (key.IsPush(KeyCode.s)) {
					movie.Stop();
				} else if (key.IsPush(KeyCode.q)) {
					movie.Pause();
				} else if (key.IsPush(KeyCode.r)) {
					movie.Resume();
				}

				window.Screen.Select();
				if (movie.IsReadyToDraw) {
					movie.Draw(tx);
					//window.Screen.Blt(tx, 0, 0);
					window.Screen.Blt(tx, 0, 0,
						new Yanesdk.Draw.Rect(0, 0, tx.Width, tx.Height),
						new Yanesdk.Draw.Size(window.Width, window.Height));
				}
				window.Screen.Update();

				timer.WaitFrame();
			}
		 */
		#endregion

		#region Win32Windowに描画するサンプルソース
		/*
	public partial class Form7 : Form
	{
		public Form7()
		{
			InitializeComponent();

			init();
		}

		Movie movie = new Movie();

		// ボタンハンドラ×4↓ Formデザイナで適当にボタンを配置して使ってちょうだい。
		private void button1_Click(object sender, EventArgs e)
		{
			movie.Play();
		}

		private void button2_Click(object sender, EventArgs e)
		{
			movie.Pause();
		}

		private void button3_Click(object sender, EventArgs e)
		{
			movie.Resume();
		}

		private void button4_Click(object sender, EventArgs e)
		{
			movie.Stop();
		}

		public void init()
		{
			timer.Fps = 30;

			window = new Win32Window(this.Handle);
			window.Screen.Select();

			tx = new GlTexture();
			movie.Load("test.mpg");
			tx.SetSurface(movie.Surface);
			movie.IsLoop = true;

			window.Screen.Unselect();
		//	movie.Play();
		}

		FpsTimer timer = new FpsTimer();
		Win32Window window;
		GlTexture tx;

		private void timer1_Tick(object sender, EventArgs e)
		{
			if (timer.ToBeRendered)
			{
				window.Screen.Select();
				if (movie.IsReadyToDraw)
				{
					movie.Draw(tx);
					if (rot == 0)
					{
						window.Screen.Blt(tx, 0, 0 , null,null);
					//	window.Screen.Blt(tx, 0, 0,
					//		new Yanesdk.Draw.Rect(0, 0, tx.Width, tx.Height),
					//		new Yanesdk.Draw.Size(this.Width, this.Height));
					}
					else
					{
						// 試しにムービーをまわしてみる。
						window.Screen.BltRotate(tx, 0, 0, rot, 1.0f, 200, 200);
					}
				}
				window.Screen.Update();

				rot += rotateStep;

				timer.WaitFrame();
			}
		}

		int rot = 0;
		int rotateStep = 0;
		private void button5_Click(object sender, EventArgs e)
		{
			rotateStep++;
		}
	}
		 */
		#endregion

		#region ctor and Dispose
		/// <summary>
		/// オーディオの再生周波数等は、Yanesdk.Sound.Sound.SoundConfigで設定された値で初期化される。
		/// </summary>
		public Movie()
		{
			callback = new SMPEG.SMPEG_DisplayCallback(smpeg_DisplayCallback);
			//mix_hook = new SDL.mix_func_t(SMPEG.SMPEG_playAudioSDL);
			mix_hook = new SDL.mix_func_t(mix_HookMusic);

			// 排他処理オブジェクトの作成
			mutex = SDL.SDL_CreateMutex();

			// MasterVolumeが変更されたときにそれに追随して再生Volumeが変更されるように。
			Yanesdk.Sound.Sound.ChunkManager.OnMasterVolumeChanged
				+= OnMasterVolumeChanged;
		}