示例#1
0
        public static void Tick(Form1 form)
        {
            if (State == VoicePlayerState.Available)
            {
                VoicePlayerItem item = null;

                lock (padlock)
                    if (PlaybackQueue.Count > 0)
                    {
                        item = PlaybackQueue[0];
                        PlaybackQueue.RemoveAt(0);
                    }

                if (item != null)
                {
                    String path    = Path.Combine(Settings.VoicePath, item.FileName + ".wav");
                    int    success = 0;
                    mciSendString("open \"" + path + "\" type mpegvideo alias " + PLAYBACK_DEVICE_NAME, null, 0, IntPtr.Zero);
                    success = mciSendString("set " + PLAYBACK_DEVICE_NAME + " output " + AudioHelpers.GetPlaybackIdent(), null, 0, IntPtr.Zero);
                    success = mciSendString("play " + PLAYBACK_DEVICE_NAME + " notify", null, 0, form.Handle);

                    if (success == 0)
                    {
                        State = VoicePlayerState.Busy;

                        if (item.Auto)
                        {
                            Room room = RoomPool.Rooms.Find(x => x.EndPoint.Equals(item.EndPoint));

                            if (room != null)
                            {
                                room.Panel.ShowVoice(item.Sender, item.ShortCut);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
 public static void RecordStart()
 {
     mciSendString("open new type waveaudio alias " + RECORD_DEVICE_NAME, null, 0, IntPtr.Zero);
     mciSendString("set " + RECORD_DEVICE_NAME + " time format ms format tag pcm channels 1 samplespersec 16000 bytespersec 32000 alignment 2 bitspersample 16 input " + AudioHelpers.GetRecordIdent(), null, 0, IntPtr.Zero);
     mciSendString("record " + RECORD_DEVICE_NAME, null, 0, IntPtr.Zero);
     Recording = true;
 }