Пример #1
0
        internal static void Inicializar()
        {
            if(!Hardware.SonidoActivo)
                return;

            MusicaFondo = new Music ("Assets/Sonidos/choco1.ogg");
            MusicPlayer.Volume = 30;
            MusicPlayer.Load ( MusicaFondo );
            MusicPlayer.Play(true);
        }
Пример #2
0
 /// <summary>
 /// Private method to process the next queued music file.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Events_MusicFinished(object sender, MusicFinishedEventArgs e)
 {
     if (MusicPlayer.IsPlaying == false)
     {
         if (CurrentMusic.QueuedMusic != null)
         {
             m_CurrentMusic = CurrentMusic.QueuedMusic;
             m_CurrentMusic.Play();
         }
     }
 }
Пример #3
0
 public void PlayAudio()
 {
     try
     {
         Music bgMusic = new Music(musicString);
         MusicPlayer.Volume = 80;
         MusicPlayer.Load(bgMusic);
         MusicPlayer.Play();
     }
     catch
     {}
 }
Пример #4
0
 /// <summary>
 /// Plays the selected music. The music must be in the "music" folder.
 /// If a music is currently playing, it is stopped.
 /// </summary>
 /// <param name="filename">The name of the music (with extension).</param>
 public void StartMusic(string filename)
 {
     if (!ok) return;
     if (nowPlaying != null) {
         nowPlaying.Dispose();
     }
     nowPlaying = new Music(game.loader.LoadRaw("music/" + filename));
     // When trying to play music/sound without a sound card, a DivideByZeroException
     // is thrown. I couldn't find an easier way to test for the sound card.
     try {
         nowPlaying.Play(true);
     }
     catch (DivideByZeroException) {
         ok = false;
     }
 }
Пример #5
0
        public Manager()
        {
            try
            {
                 mVideo = Video.SetVideoMode(1300,600);
                 achtergrond = new Surface("Background.jpg");// achtergrond
                 muziek = new Music("Commander Keen 4.mp3");
            }
            catch (Exception error)
            {
                Console.WriteLine(error);
            }

            held = new Hero();

            //vijand = new Enemy(200, 500,true,false);
            //vijand2 = new Enemy(300, 500, false, true);
            //vijand3 = new Enemy(600, 500, false, true);
            //vijand4 = new Enemy(700, 500, true, false);

            level1 = new Level();
            AantalLevens = new NumberOfLives();
            Gameobjecten = new List<GameObject>();

            Gameobjecten.Add(held);
            //Gameobjecten.Add(vijand);
            //Gameobjecten.Add(vijand2);
            //Gameobjecten.Add(vijand3);
            //Gameobjecten.Add(vijand4);

            Vijanden = new List<Enemy>();
            //Vijanden.Add(vijand);
            //Vijanden.Add(vijand2);
            //Vijanden.Add(vijand3);
            //Vijanden.Add(vijand4);

            MusicPlayer.Volume = 30;
            MusicPlayer.Load(muziek);
            muziek.Play();

            Events.Tick += Events_Tick;
            //Events.Fps = 5;
            Events.KeyboardUp += Events_KeyboardUp;
            Events.Quit += Events_Quit;
            Events.Run();
        }
Пример #6
0
        private static void AudioPlaybackThread()
        {
            Music Muziek = new Music("Commander Keen 4.mp3");
             MusicPlayer.Volume = 30;
             MusicPlayer.Load(Muziek);
             MusicPlayer.Play();

             // Start playing sound Effects
            List<string> audioFiles = new List<string>(new string[] {
             });
             //int cnt = 0;
             //while ()
             //{
             //}
            //UserEventArgs userEvent = new
            //UserEventArgs(audioFiles[cnt++]);
            // if (cnt >= audioFiles.Count)
            // cnt = 0;
            // Events.PushUserEvent(userEvent);
            // SdlDotNet.Core.Timer.DelaySeconds(2);
        }
Пример #7
0
        void Events_Tick(object sender, TickEventArgs e)
        {
            muziek = new Music("Commander Keen 4.mp3");

            mVideo.Blit(achtergrond); //achtergrond

            //CheckCollisionsWithBackground();
            //CheckCollisionsWithEnemy();
            //EnemyMovement();
            //MoveLevel();
            CheckCollisions();
            //AantalLevens.Draw(mVideo, held);

            foreach (GameObject g in Gameobjecten)
            {
                g.Update();
                g.Draw(mVideo);
            }
            level1.Draw(mVideo);

            mVideo.Update();
        }
Пример #8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="music"></param>
 public static void Load(Music music)
 {
     if (music == null)
     {
         throw new ArgumentNullException("music");
     }
     music.Handle = Mixer.LoadMusic(music.FileName);
     CurrentMusic = music;
 }
Пример #9
0
        public void Go()
        {
            // Load the music and sounds.
            music["mason2"] = new Music(Path.Combine(Path.Combine(filePath, fileDirectory), "mason2.mid"));
            music["fard-two"] = new Music(Path.Combine(Path.Combine(filePath, fileDirectory), "fard-two.ogg"));
            boing = new Sound(Path.Combine(Path.Combine(filePath, fileDirectory), "boing.wav"));

            textDisplay = new TextSprite(" ", new SdlDotNet.Graphics.Font(Path.Combine(Path.Combine(filePath, fileDirectory), "FreeSans.ttf"), 20), Color.Red);

            // Start up SDL
            Video.WindowIcon();
            Video.WindowCaption = "SDL.NET - AudioExample";
            screen = Video.SetVideoMode(width, height);

            // Play the music and setup the queues.
            music["mason2"].Play();
            //music["fard-two"].Play();

            // Set up the music queue and start it
            music["mason2"].QueuedMusic = music["fard-two"];
            music["fard-two"].QueuedMusic = music["mason2"];
            MusicPlayer.EnableMusicFinishedCallback();

            // Begin the SDL ticker
            Events.Fps = 50;

            textDisplay.Text = SdlDotNetExamplesBrowser.StringManager.GetString(
                        "AudioExampleDirections", CultureInfo.CurrentUICulture);
            textDisplay.TextWidth = 200;
            Events.Run();
        }
Пример #10
0
        ///////////////////////////////////
        //Custom Constructor
        ///////////////////////////////////
        // allow Reloading of an AudioObject
        public AudioManagerPanel(AudioObject AudioInformation, AssetManagerForm mainForm)
        {
            InitializeComponent();
            this.MainForm = mainForm;

            AudioFile = AudioInformation;

            nameTb.Enabled = false;
            this.nameTb.Text=AudioFile.name;
            this.CompteurVolumeTb.Text =  AudioFile.volume.ToString();
            this.repeatNUD.Value =  AudioFile.loops;
            this.preloadCB.Checked = AudioFile.isPreloaded;

            if (this.AudioFile.type.Equals("STREAM"))
            {
                this.typeSoundRb.Checked = false;
                this.typeStreamRb.Checked = true;
            }
            else
            {
                this.typeSoundRb.Checked = true;
                this.typeStreamRb.Checked = false;
            }

            if (File.Exists(AudioFile.path))
            {
                if (!AudioFile.path.Equals(""))
                {
                    string[] ext = nameTb.Text.Split('.');

                    try
                    {
                        if (ext[1].ToString().ToLower() == "wav")
                        {
                            SoundPlayer = new Sound(AudioFile.path);

                        }
                        else if (ext[1].ToString().ToLower() == "ogg")
                        {
                            MusicFile = new Music(AudioFile.path);

                        }
                        else
                        {
                            SoundPlayer = null;
                            MusicFile = null;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Audio file loading failed !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Пример #11
0
        // Import an sound file
        //
        private void importBt_Click(object sender, EventArgs e)
        {
            // We clean previous Audio file
            //
            if (channelSound != null)
            {
                channelSound.Dispose();
                channelSound = null;
            }
            if (SoundPlayer != null) SoundPlayer.Dispose();
            if (MusicPlayer.IsPlaying) MusicPlayer.Stop();
            if (MusicFile != null) MusicFile.Dispose();

            //Open dialogue to get the file
            //
            OpenFileDialog openFileD = new OpenFileDialog();
            openFileD.Multiselect = false;
            openFileD.DefaultExt = ".wav";
            openFileD.AddExtension = false;

            //Configure allowed extensions
            //
            openFileD.Filter = "Audio files (*.wav)|*.wav|MP3 (*.mp3)|*.mp3|OGG (*.ogg)|*.ogg|M4a (*.m4a)|*.m4a";

            if (openFileD.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if (File.Exists(openFileD.FileName))
                    {
                        string directoryDest = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software\\Asset Manager";
                        if (!Directory.Exists(directoryDest))
                            Directory.CreateDirectory(directoryDest);

                        string fileNameDest = directoryDest+"\\"+this.MainForm.CurrentAssetProject.ProjectName+"\\"+openFileD.SafeFileName;
                        File.Copy(openFileD.FileName, fileNameDest,true);
                        //Get File Name and Path
                        AudioFile.name = openFileD.SafeFileName;
                        AudioFile.path = fileNameDest;
                        this.nameTb.Text = AudioFile.name;

                        //Load a sound or a music regarding the format
                        // (only wav and ogg are supported by SDL_mixer library :(
                        // TODO : Found an other Audio Library
                        //
                        string[] ext = nameTb.Text.Split('.');

                        if (ext[1].ToString().ToLower() == "wav")
                        {
                            SoundPlayer = new Sound(fileNameDest);

                        }
                        else if (ext[1].ToString().ToLower() == "ogg")
                        {
                            MusicFile = new Music(fileNameDest);

                        }
                        else
                        {
                            //If the format is not supported, we make sure that no Audio file is loaded
                            //
                            SoundPlayer = null;
                            MusicFile = null;
                        }

                        this.nameTb.Text = AudioFile.name;
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error during image loading ! \n\n " + ex.Message);
                }
            }
        }
Пример #12
0
        /// <summary>
        /// 
        /// </summary>
        public void Start()
        {
            GameView gameView = new GameView(eventManager);
            gameView.CreateView();
            map.Build();

            if (File.Exists(Path.Combine(dataDirectory, "fard-two.ogg")))
            {
                filePath = "";
            }

            Music music = new Music(Path.Combine(filePath, Path.Combine(dataDirectory, "fard-two.ogg")));

            try
            {
                music.Play(-1);
            }
            catch (DivideByZeroException)
            {
                // Linux audio problem
            }
           
            this.gameStatus = GameStatus.Started;
            eventManager.Publish(new GameStatusEventArgs(this, GameStatus.Started));
        }
Пример #13
0
 internal void StopMusic()
 {
     if (nowPlaying != null) nowPlaying.Dispose();
     nowPlaying = null;
 }
Пример #14
0
 private static void AudioPlaybackThread()
 {
     //background music
     Music bgMusic = new Music("background.wav");
     MusicPlayer.Volume = 20;
     MusicPlayer.Load(bgMusic);
     MusicPlayer.Play(true); //true --> loop    
 }