Ejemplo n.º 1
0
 /// <summary>Plays a .wav sound file.</summary>
 /// <param name="playMode">AudioPlayMode Enumeration mode for playing the sound. By default, AudioPlayMode.Background.</param>
 /// <param name="location">A String containing the name of the sound file </param>
 /// <PermissionSet><IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlThread" /><IPermission class="System.Net.WebPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /></PermissionSet>
 public static void Play(string location, AudioPlayMode playMode)
 {
     ValidateAudioPlayModeEnum(playMode, "playMode");
     string text1 = ValidateFilename(location);
     SoundPlayer player1 = new SoundPlayer(text1);
     Play(player1, playMode);
 }
Ejemplo n.º 2
0
 private static void smethod_2(AudioPlayMode audioPlayMode_0, string string_0)
 {
     if ((audioPlayMode_0 < AudioPlayMode.WaitToComplete) || (audioPlayMode_0 > AudioPlayMode.BackgroundLoop))
     {
         throw new InvalidEnumArgumentException(string_0, (int)audioPlayMode_0, typeof(AudioPlayMode));
     }
 }
Ejemplo n.º 3
0
        public static void Play(string location, AudioPlayMode playMode)
        {
            smethod_2(playMode, "playMode");
            SoundPlayer player = new SoundPlayer(smethod_3(location));

            smethod_1(player, playMode);
        }
Ejemplo n.º 4
0
 private static void ValidateAudioPlayModeEnum(AudioPlayMode value, string paramName)
 {
     if ((value < AudioPlayMode.WaitToComplete) || (value > AudioPlayMode.BackgroundLoop))
     {
         throw new InvalidEnumArgumentException(paramName, (int)value, typeof(AudioPlayMode));
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 播放。wav声音文件.
        /// </summary>
        /// <param name="location">AudioPlayMode枚举模式播放声音。默认情况下,AudioPlayMode.Background。</param>
        /// <param name="playMode">String,包含声音文件的名称</param>
        public static void Play(string location, AudioPlayMode playMode)
        {
            ValidateAudioPlayModeEnum(playMode, "playMode");
            string      text1   = ValidateFilename(location);
            SoundPlayer player1 = new SoundPlayer(text1);

            Play(player1, playMode);
        }
Ejemplo n.º 6
0
 /// <summary>Plays a .wav sound file.</summary>
 /// <param name="playMode">AudioPlayMode Enumeration mode for playing the sound. By default, AudioPlayMode.Background.</param>
 /// <param name="stream"><see cref="T:System.IO.Stream"></see> that represents the sound file.</param>
 /// <PermissionSet><IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlThread" /><IPermission class="System.Net.WebPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /></PermissionSet>
 public static void Play(Stream stream, AudioPlayMode playMode)
 {
     ValidateAudioPlayModeEnum(playMode, "playMode");
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     Play(new SoundPlayer(stream), playMode);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 播放 .wav 格式的声音文件
 /// </summary>
 /// <param name="stream"><see cref="T:System.IO.Stream"></see>声音文件的流对象</param>
 /// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>
 public static void Play(Stream stream, AudioPlayMode playMode)
 {
     ValidateAudioPlayModeEnum(playMode, "playMode");
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     Play(new SoundPlayer(stream), playMode);
 }
Ejemplo n.º 8
0
 public static void Play(Stream stream, AudioPlayMode playMode)
 {
     smethod_2(playMode, "playMode");
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     smethod_1(new SoundPlayer(stream), playMode);
 }
Ejemplo n.º 9
0
 public void Play(Stream stream, AudioPlayMode playMode)
 {
     this.ValidateAudioPlayModeEnum(playMode, "playMode");
     if (stream == null)
     {
         throw ExceptionUtils.GetArgumentNullException("stream");
     }
     this.Play(new SoundPlayer(stream), playMode);
 }
 public void Play(Stream stream, AudioPlayMode playMode)
 {
     this.ValidateAudioPlayModeEnum(playMode, "playMode");
     if (stream == null)
     {
         throw ExceptionUtils.GetArgumentNullException("stream");
     }
     this.Play(new SoundPlayer(stream), playMode);
 }
Ejemplo n.º 11
0
 /// <summary>Plays a .wav sound file.</summary>
 /// <param name="data">Byte array that represents the sound file.</param>
 /// <param name="playMode">AudioPlayMode Enumeration mode for playing the sound. By default, AudioPlayMode.Background.</param>
 /// <PermissionSet><IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlThread" /><IPermission class="System.Net.WebPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" /></PermissionSet>
 public static void Play(byte[] data, AudioPlayMode playMode)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     ValidateAudioPlayModeEnum(playMode, "playMode");
     MemoryStream stream1 = new MemoryStream(data);
     Play(stream1, playMode);
     stream1.Close();
 }
 public void Play(byte[] data, AudioPlayMode playMode)
 {
     if (data == null)
     {
         throw ExceptionUtils.GetArgumentNullException("data");
     }
     this.ValidateAudioPlayModeEnum(playMode, "playMode");
     MemoryStream stream = new MemoryStream(data);
     this.Play(stream, playMode);
     stream.Close();
 }
Ejemplo n.º 13
0
        public void Play(byte[] data, AudioPlayMode playMode)
        {
            if (data == null)
            {
                throw ExceptionUtils.GetArgumentNullException("data");
            }
            this.ValidateAudioPlayModeEnum(playMode, "playMode");
            MemoryStream stream = new MemoryStream(data);

            this.Play(stream, playMode);
            stream.Close();
        }
Ejemplo n.º 14
0
        public static void Play(byte[] data, AudioPlayMode playMode)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            smethod_2(playMode, "playMode");
            MemoryStream stream = new MemoryStream(data);

            Play(stream, playMode);
            stream.Close();
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 播放 .wav 格式的声音文件
        /// </summary>
        /// <param name="data">声音文件的字节数组</param>
        /// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>
        public static void Play(byte[] data, AudioPlayMode playMode)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            ValidateAudioPlayModeEnum(playMode, "playMode");
            MemoryStream stream1 = new MemoryStream(data);

            Play(stream1, playMode);
            stream1.Close();
        }
Ejemplo n.º 16
0
        private void Play(SoundPlayer sound, AudioPlayMode mode)
        {
            if (this.m_Sound != null)
            {
                InternalStop(this.m_Sound);
            }
            this.m_Sound = sound;
            switch (mode)
            {
            case AudioPlayMode.WaitToComplete:
                this.m_Sound.PlaySync();
                break;

            case AudioPlayMode.Background:
                this.m_Sound.Play();
                break;

            case AudioPlayMode.BackgroundLoop:
                this.m_Sound.PlayLooping();
                break;
            }
        }
        private void Play(SoundPlayer sound, AudioPlayMode mode)
        {
            if (this.m_Sound != null)
            {
                InternalStop(this.m_Sound);
            }
            this.m_Sound = sound;
            switch (mode)
            {
                case AudioPlayMode.WaitToComplete:
                    this.m_Sound.PlaySync();
                    break;

                case AudioPlayMode.Background:
                    this.m_Sound.Play();
                    break;

                case AudioPlayMode.BackgroundLoop:
                    this.m_Sound.PlayLooping();
                    break;
            }
        }
Ejemplo n.º 18
0
        private static void smethod_1(SoundPlayer soundPlayer_1, AudioPlayMode audioPlayMode_0)
        {
            if (soundPlayer_0 != null)
            {
                smethod_0(soundPlayer_0);
            }
            soundPlayer_0 = soundPlayer_1;
            switch (audioPlayMode_0)
            {
            case AudioPlayMode.WaitToComplete:
                soundPlayer_0.PlaySync();
                break;

            case AudioPlayMode.Background:
                soundPlayer_0.Play();
                break;

            case AudioPlayMode.BackgroundLoop:
                soundPlayer_0.PlayLooping();
                break;
            }
        }
Ejemplo n.º 19
0
        private static void Play(SoundPlayer sound, AudioPlayMode mode)
        {
            if (_SoundPlayer != null)
            {
                InternalStop(_SoundPlayer);
            }
            _SoundPlayer = sound;
            switch (mode)
            {
            case AudioPlayMode.WaitToComplete:
                _SoundPlayer.PlaySync();
                return;

            case AudioPlayMode.Background:
                _SoundPlayer.Play();
                return;

            case AudioPlayMode.BackgroundLoop:
                _SoundPlayer.PlayLooping();
                return;
            }
        }
Ejemplo n.º 20
0
        private static void Play(SoundPlayer sound, AudioPlayMode mode)
        {
            if (_SoundPlayer != null)
            {
                InternalStop(_SoundPlayer);
            }
            _SoundPlayer = sound;
            switch (mode)
            {
                case AudioPlayMode.WaitToComplete:
                    _SoundPlayer.PlaySync();
                    return;

                case AudioPlayMode.Background:
                    _SoundPlayer.Play();
                    return;

                case AudioPlayMode.BackgroundLoop:
                    _SoundPlayer.PlayLooping();
                    return;
            }
        }
Ejemplo n.º 21
0
 /// <summary>    
 /// 播放 .wav 格式的声音文件    
 /// </summary>    
 /// <param name="stream"><see cref="T:System.IO.Stream"></see>声音文件的流对象</param>    
 /// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>    
 public static void Play(Stream stream, AudioPlayMode playMode);
        private void button1_Click(object sender, EventArgs e)
        {
            int[] myans = new int[4];

            Random r = new Random();

            int A = 0;
            int B = 0;



            // MessageBox.Show("debug "+d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
            try
            {
                myans[0] = int.Parse(textBox1.Text.Substring(0, 1));
                myans[1] = int.Parse(textBox1.Text.Substring(1, 1));
                myans[2] = int.Parse(textBox1.Text.Substring(2, 1));
                myans[3] = int.Parse(textBox1.Text.Substring(3, 1));
            }

            catch
            {
                MessageBox.Show("請輸入4個數字");
                return;
            }
            // myans[0] = int.Parse(textBox1.Text);
            // myans[1] = int.Parse(textBox2.Text);
            //myans[2] = int.Parse(textBox3.Text);
            //myans[3] = int.Parse(textBox4.Text);



            for (int i = 0; i < 4; i++)
            {
                //do {
                // if_copy = false;


                for (int j = 0; j < i; j++)
                {
                    if (myans[j] == myans[i])
                    {
                        MessageBox.Show("請輸入四個不同的數字");

                        return;
                    }
                }
            } // END FOR I
            ///------------------------------------------------------------------以下為比較輸入與答案

            for (int x = 0; x < 4; x++)
            {
                for (int y = 0; y < 4; y++)
                {
                    if (d[x] == myans[y])
                    {
                        if (x == y)
                        {
                            A++;
                        }
                        else
                        {
                            B++;
                        }
                    }
                } // END FOR Y
            }     //END FOR x

            Secondary++;

            //richBox顯示你的輸入與答案的幾A幾B
            richTextBox1.Text += "死亡計數" + Secondary + "輸入:" + myans[0].ToString() + myans[1].ToString() + myans[2].ToString() + myans[3].ToString() + "    臨界:" + A + "A" + B + "B\n";



            //MessageBox.Show(A + "A" + B + "B");

            if (A == 4)
            {
                System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
                sp.SoundLocation = "music/尖叫聲.wav";
                sp.Play();                                            // 撥放
                MessageBox.Show("你已經死了");
                AudioPlayMode intMode = AudioPlayMode.BackgroundLoop; // AudioPlayMode 背景播放模式
                new Computer().Audio.Play("music/恐怖.wav", intMode);   // 背景播放
                textBox1.ReadOnly = true;
                button1.Visible   = false;
                textBox1.Text     = "轉生在死一次吧...";
            }
            //textBox1.Text = "";

            textBox1.Focus();


            ///--- textBox1.Select(0, 0);
            // textBox1.SelectionStart=lock;
        }
        private void Form1_Load(object sender, EventArgs e)//123
        {
            int  choice;
            bool if_exist;

            int[] ans = new int[10];
            label1.ForeColor  = Color.White;
            label2.ForeColor  = Color.White;
            button1.ForeColor = Color.White;
            button2.ForeColor = Color.White;
            button3.ForeColor = Color.White;
            button1.Text      = "死一遍看看?";
            button2.Text      = "轉生";
            button3.Text      = "離開地域";
            label1.Text       = "迷樣的數字.....";
            label1.Font       = new Font("標楷體", 20, FontStyle.Regular);
            label2.Text       = "請在以下欄位輸入數字";
            label2.Font       = new Font("標楷體", 18, FontStyle.Regular); Random r = new Random();

            #region 撥放音樂
            #region 直接使用 System.Media.SoundPlayer 類別
            // System.Media.SoundPlayer sp = new System.Media.SoundPlayer();
            //sp.SoundLocation = @"F:\2012-8月\xAyB猜數字(完成作業)\xAyB猜數字(氣死人完成)\xAyB猜數字\bin\Debug\music\Windows XP 啟動.wav";
            //sp.Play(); // 撥放
            #endregion


            #region 呼叫 VB.Net 的 My.Computer.Audio.Play 類別  注意 :  請先加入參考 "Microsoft.VisualBasic"

            AudioPlayMode intMode = AudioPlayMode.BackgroundLoop; // AudioPlayMode 背景播放模式
            new Computer().Audio.Play("music./鬼來電.wav", intMode); // 背景播放
            #endregion
            #endregion

            for (int i = 0; i < 4; i++)
            {
                if (i == 0)
                {
                    d[i] = r.Next(0, 9);
                }
                else
                {
                    do
                    {
                        if_exist = false;
                        choice   = r.Next(0, 9);

                        for (int j = 0; j < i; j++)
                        {
                            if (d[j] == choice)
                            {
                                if_exist = true;
                            }
                        } //end for j
                    } while (if_exist);
                    d[i] = choice;
                    MessageBox.Show("debug " + d[0] + " " + d[1] + " " + d[2] + " " + d[3]);
                }
            } //end for i
              //this.button1.Attributes.Add("onkeypress", "if( event.keyCode == 13 ) { document.getElementById('" & this.TextBox1.ClientID & "').focus(); }");

            #region 使用鍵盤控制程式
            {
                this.KeyPreview = true;
            }
        }
/// <summary>
/// 播放 .wav 格式的声音文件
/// </summary>
/// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>
/// <param name="location">声音文件路径</param>
        public static void Play(string location, AudioPlayMode playMode)
/// <summary>
/// 播放 .wav 格式的声音文件
/// </summary>
/// <param name="data">声音文件的字节数组</param>
/// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>
        public static void Play(byte[] data, AudioPlayMode playMode)
Ejemplo n.º 26
0
 private static void ValidateAudioPlayModeEnum(AudioPlayMode value, string paramName)
 {
     if ((value < AudioPlayMode.WaitToComplete) || (value > AudioPlayMode.BackgroundLoop))
     {
         throw new InvalidEnumArgumentException(paramName, (int)value, typeof(AudioPlayMode));
     }
 }
 public void Play(string location, AudioPlayMode playMode)
 {
     this.ValidateAudioPlayModeEnum(playMode, "playMode");
     SoundPlayer sound = new SoundPlayer(this.ValidateFilename(location));
     this.Play(sound, playMode);
 }
/// <summary>
/// 播放 .wav 格式的声音文件
/// </summary>
/// <param name="stream"><see cref="T:System.IO.Stream"></see>声音文件的流对象</param>
/// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>
        public static void Play(Stream stream, AudioPlayMode playMode)
Ejemplo n.º 29
0
 /// <summary>    
 /// 播放 .wav 格式的声音文件    
 /// </summary>    
 /// <param name="data">声音文件的字节数组</param>    
 /// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>    
 public static void Play(byte[] data, AudioPlayMode playMode);
Ejemplo n.º 30
0
 /// <summary>    
 /// 播放 .wav 格式的声音文件    
 /// </summary>    
 /// <param name="playMode">播放声音的枚举模式。默认为AudioPlayMode.Background。</param>    
 /// <param name="location">声音文件路径</param>    
 public static void Play(string location, AudioPlayMode playMode);
Ejemplo n.º 31
0
        private void PlayNextSong()
        {
            if (nextOutputMode != OutputMode.audio)
            {
                return;
            }

            var currentPlaylist  = MainForm.currentPreference.AudioPlaylists.First(x => x.PlaylistName == audioPlaylist).Playlist;
            var currentSongIndex = Array.FindIndex(currentPlaylist, x => x == currentSong);

            // todo: remove this hack once the app is set up!
            audioPlayMode = AudioPlayMode.random;

            if (audioPlayMode == AudioPlayMode.repeat)
            {
                if (File.Exists(currentSong.FilePath))
                {
                    audioFileReader = new AudioFileReader(currentSong.FilePath);

                    nextOutputMode = OutputMode.audio;

                    FadeOutSound();

                    return;
                }
            }

            if (audioPlayMode == AudioPlayMode.random)
            {
                if (!string.IsNullOrEmpty(currentSong.FilePath) && MainForm.currentPreference.AudioPlaylists.First(x => x.PlaylistName == audioPlaylist).Playlist.Length > 1)
                {
                    Random rand = new Random();

                    var songIndex = rand.Next(0, currentPlaylist.Length - 1);

                    if (currentSongIndex == songIndex)
                    {
                        songIndex = rand.Next(0, currentPlaylist.Length - 1);
                    }

                    var song = currentPlaylist[songIndex];

                    if (File.Exists(song.FilePath))
                    {
                        currentSong = song;

                        audioFileReader = new AudioFileReader(song.FilePath);

                        nextOutputMode = OutputMode.audio;

                        FadeOutSound();
                    }
                }
            }

            if (!string.IsNullOrEmpty(currentSong.FilePath) && currentPlaylist.Length > 1)
            {
                var songIndex = Array.FindIndex(currentPlaylist, x => x == currentSong);

                songIndex++;

                if (songIndex >= currentPlaylist.Length)
                {
                    songIndex = 0;
                }

                var song = currentPlaylist[songIndex];

                if (File.Exists(song.FilePath))
                {
                    currentSong = song;

                    audioFileReader = new AudioFileReader(song.FilePath);

                    nextOutputMode = OutputMode.audio;

                    FadeOutSound();
                }
            }
        }