/Multimedia/Tests/Program.cs
C# | 230 lines | 53 code | 13 blank | 164 comment | 3 complexity | d4d2865c97fab9df1589b5e5fca817db MD5 | raw file
Possible License(s): Apache-2.0
- using Delta.Engine;
- using Delta.InputSystem;
- using Delta.Rendering.Basics.Fonts;
- using Delta.Utilities;
- using Delta.Utilities.Datatypes;
- using Delta.Utilities.Helpers;
-
- namespace Delta.Multimedia.Tests
- {
- /// <summary>
- /// Multimedia tests, use the Settings.xml to specific which module you want
- /// to use (Xna, OpenTK, Vlc, etc.)
- /// </summary>
- public class Program
- {
- #region Main (Static)
- /// <summary>
- /// Main entry point, will just call one of the tests, uncomment the rest
- /// </summary>
- public static void Main()
- {
- //TestLoadSound();
- //TestLoadSoundWithExtraChunks();
- //TestShortSoundPlayback();
- //TestManySoundPlaybacks();
- //TestManySoundLoads();
- //TestDisposeMusicPlayback();
- //TestDisposeSoundPlayback();
-
- Tutorials.TestSoundPlayback();
- //Tutorials.TestMusicPlayback();
- //Tutorials.TestVideoPlayback();
- }
- #endregion
-
- #region TestLoadSound (Static)
- /// <summary>
- /// Load a sound file (not playing it)
- /// </summary>
- public static void TestLoadSound()
- {
- Sound testSound = new Sound("DefaultSound");
- Assert.NotNull(testSound);
- Assert.NotNull(testSound);
- }
- #endregion
-
- /*TODO: content missing! TestDataChunkSound.wav needs to be uploaded (from Marcels folder)
- /// <summary>
- /// Load a sound file (not playing it) with extra chunks before
- /// the actual data chunk. Note: This file is broken on purpose.
- /// </summary>
- public static void TestLoadSoundWithExtraChunks()
- {
- Sound testSound = new Sound("TestDataChunkSound");
- Assert.NotNull(testSound);
- Assert.NotNull(testSound as Sound);
- }
- */
-
- #region TestShortSoundPlayback (Static)
- /// <summary>
- /// Short sound playback as an introduction
- /// </summary>
- public static void TestShortSoundPlayback()
- {
- int currentVolume = 10;
-
- Sound sound = new Sound("DefaultSound");
- Application.Start(delegate
- {
- Font.Default.Draw("Volume: " + (currentVolume * 10) + "%",
- ScreenSpace.DrawArea);
-
- if (Input.Touch.TouchReleased ||
- Input.Keyboard.SpaceReleased)
- {
- sound.Play();
- }
-
- // Volume Up
- if (Input.Keyboard.CursorUpReleased)
- {
- currentVolume = MathHelper.Min(currentVolume + 1, 10);
- sound.Volume = currentVolume / 10.0f;
- }
-
- // Volume Down
- if (Input.Keyboard.CursorDownReleased)
- {
- currentVolume = MathHelper.Max(currentVolume - 1, 0);
- sound.Volume = currentVolume / 10.0f;
- }
- });
- }
- #endregion
-
- /*TODO: The following tests needs extra content!
- /// <summary>
- /// Load multiple sound files
- /// </summary>
- public static void TestManySoundLoads()
- {
- string[] sounds = new string[]
- {
- "AirHockeyWallVariant3",
- "MenuContinueButtonPressed",
- "MenuBackButtonPressed",
- };
-
- bool loopPlays = false;
-
- Application.Start(delegate
- {
- Font.DrawTopLeftInformation("Fps: " + Time.Fps);
-
- if (Input.Touch.TouchReleased ||
- Input.Keyboard.SpaceReleased)
- {
- loopPlays = !loopPlays;
- }
-
- if (loopPlays)
- {
- foreach (string soundName in sounds)
- {
- new Sound(soundName).Play();
- }
- }
- });
- }
- */
-
- /*TODO: The following tests needs extra content!
- /// <summary>
- /// Multiple sound playback
- /// </summary>
- public static void TestManySoundPlaybacks()
- {
- Sound[] sounds = new Sound[]
- {
- new Sound("DefaultSound"),
- new Sound("TimeOver"),
- new Sound("ResultScreenFirework"),
- new Sound("TimeLast30SecondsStart"),
- };
-
- bool loopPlays = false;
-
- Delta.Engine.Application.Start(delegate
- {
- Application.Window.Title = "ActiveChannels=" +
- Sound.ActiveChannels;
-
- if (Input.Touch.TouchReleased ||
- Input.Keyboard.SpaceReleased)
- {
- loopPlays = !loopPlays;
- }
-
- if (loopPlays)
- {
- foreach (Sound sound in sounds)
- {
- sound.Play();
- System.Threading.Thread.Sleep(20);
- }
- }
-
- if (Sound.ActiveChannels == Application.Information.MaxSoundChannels)
- {
- loopPlays = false;
- }
- });
- }
- */
-
- /*TODO: Need to import the Menu music
- /// <summary>
- /// Dispose sound file
- /// </summary>
- public static void TestDisposeMusicPlayback()
- {
- Music music = new Music("Menu");
-
- Application.Start(delegate
- {
- Font.DrawTopLeftInformation("Fps: " + Time.Fps);
-
- if (Input.Touch.TouchReleased ||
- Input.Keyboard.SpaceReleased)
- {
- //Music is disposed by Media Manager, on load of new one
- //music.Stop();
- //music.Dispose();
- music = new Music("Menu");
-
- music.Play();
- }
- });
- }
- */
-
- /*TODO: needs AirHockeyWallVariant3 sound content
- /// <summary>
- /// Test dispose music playback. Should do nothing for 5 seconds (well,
- /// except loading and disposing the sound like crazy), then play it!
- /// </summary>
- public static void TestDisposeSoundPlayback()
- {
- Application.Start(delegate
- {
- Font.DrawTopLeftInformation("Fps: " + Time.Fps);
-
- if (Time.Seconds < 5)
- {
- Sound sound = new Sound("AirHockeyWallVariant3");
- sound.Play();
- sound.Dispose();
- }
- else
- {
- Sound sound = new Sound("AirHockeyWallVariant3");
- sound.Play();
- }
- });
- }
- */
- }
- }