Exemple #1
0
        void DoMusicThread()
        {
            if (musicFiles.Length == 0)
            {
                return;
            }
            Random rnd = new Random();

            while (!disposingMusic)
            {
                string file = musicFiles[rnd.Next(0, musicFiles.Length)];
                string path = Path.Combine(Program.AppDirectory, file);
                Utils.LogDebug("playing music file: " + file);

                using (FileStream fs = File.OpenRead(path)) {
                    OggContainer container = new OggContainer(fs);
                    try {
                        musicOut.PlayStreaming(container);
                    } catch (InvalidOperationException ex) {
                        HandleMusicError(ex);
                        return;
                    } catch (Exception ex) {
                        ErrorHandler.LogError("AudioPlayer.DoMusicThread()", ex);
                        game.Chat.Add("&cError while trying to play music file " + Path.GetFileName(file));
                    }
                }
                if (disposingMusic)
                {
                    break;
                }

                int delay = 2000 * 60 + rnd.Next(0, 5000 * 60);
                musicHandle.WaitOne(delay, false);
            }
        }
Exemple #2
0
        void DoMusicThread()
        {
            Random rnd = new Random();

            while (!disposingMusic)
            {
                string file = musicFiles[rnd.Next(0, musicFiles.Length)];
                string path = Path.Combine(Program.AppDirectory, file);
                Utils.LogDebug("playing music file: " + file);

                using (FileStream fs = File.OpenRead(path)) {
                    OggContainer container = new OggContainer(fs);
                    try {
                        musicOut.PlayStreaming(container);
                    } catch (InvalidOperationException ex) {
                        HandleMusicError(ex);
                        return;
                    }
                }
                if (disposingMusic)
                {
                    break;
                }

                int delay = 2000 * 60 + rnd.Next(0, 5000 * 60);
                musicHandle.WaitOne(delay);
            }
        }
Exemple #3
0
        void DecodeSound(string name, byte[] rawData)
        {
            long start = outData.Position;

            using (MemoryStream ms = new MemoryStream(rawData)) {
                OggContainer container = new OggContainer(ms);
                outDecoder.PlayStreaming(container);
            }

            long len = outData.Position - start;

            outText.WriteLine(format, name, outDecoder.Frequency,
                              outDecoder.BitsPerSample, outDecoder.Channels,
                              start, len);
        }
        void DecodeSound(string name, byte[] rawData)
        {
            string path = Path.Combine(Program.AppDirectory, "audio");

            path = Path.Combine(path, prefix + name + ".wav");

            using (FileStream dst = File.Create(path))
                using (MemoryStream src = new MemoryStream(rawData))
                {
                    dst.SetLength(44);
                    RawOut       output    = new RawOut(dst, true);
                    OggContainer container = new OggContainer(src);
                    output.PlayStreaming(container);

                    dst.Position = 0;
                    BinaryWriter w = new BinaryWriter(dst);
                    WriteWaveHeader(w, dst, output);
                }
        }
        void DecodeSound( string name, byte[] rawData )
        {
            string path = Path.Combine( Program.AppDirectory, "audio" );
            path = Path.Combine( path, prefix + name + ".wav" );

            using( FileStream dst = File.Create( path ) )
                using ( MemoryStream src = new MemoryStream( rawData ) )
            {
                dst.SetLength( 44 );
                RawOut output = new RawOut( dst, true );
                OggContainer container = new OggContainer( src );
                output.PlayStreaming( container );

                dst.Position = 0;
                BinaryWriter w = new BinaryWriter( dst );
                WriteWaveHeader( w, dst, output );
            }
        }
        void DoMusicThread()
        {
            Random rnd = new Random();
            while( !disposingMusic ) {
                string file = musicFiles[rnd.Next( 0, musicFiles.Length )];
                string path = Path.Combine( Program.AppDirectory, file );
                Utils.LogDebug( "playing music file: " + file );

                using( FileStream fs = File.OpenRead( path ) ) {
                    OggContainer container = new OggContainer( fs );
                    try {
                        musicOut.PlayStreaming( container );
                    } catch( InvalidOperationException ex) {
                        HandleMusicError( ex );
                        return;
                    }
                }
                if( disposingMusic ) break;

                int delay = 2000 * 60 + rnd.Next( 0, 5000 * 60 );
                musicHandle.WaitOne( delay );
            }
        }