Exemplo n.º 1
0
        //播放完了的情况没有解决

        public WaveOutStream loadWaveOutStream()
        {
            WaveOutStream stream = new WaveOutStream();

            for (int i = 0; i < STREAM_COUNT; i++)
            {
                WaveOutBuffer a = loadWaveOutBuffer();
                stream.addBuffer(a);
            }
            count_stream++;
            return(stream);
        }
Exemplo n.º 2
0
        public WaveOutBuffer loadWaveOutBuffer()
        {
            WaveOutBuffer buf = new WaveOutBuffer(waveOut, BUF_SIZE);
            int           pos = 0;

            byte[] b = new byte[BUF_SIZE];
            while (pos < BUF_SIZE)
            {
                int toget = BUF_SIZE - pos;
                int got   = audioStream.Read(b, pos, toget);
                pos += got;
            }
            System.Runtime.InteropServices.Marshal.Copy(b, 0, buf.Data, BUF_SIZE);
            return(buf);
        }
Exemplo n.º 3
0
 public static void WaveOutProc(IntPtr hdrvr, Messages uMsg, int dwUser, ref WaveHdr wavhdr, int dwParam2)
 {
     if (uMsg == Messages.MM_WOM_DONE)
     {
         try
         {
             GCHandle      h   = (GCHandle)wavhdr.dwUser;
             WaveOutBuffer buf = (WaveOutBuffer)h.Target;
             buf.OnCompleted();
         }
         catch
         {
         }
     }
 }
        public WaveOutStream(SerializationInfo info, StreamingContext ctxt)
        {
            List <byte[]> stream_byte = (List <byte[]>)info.GetValue("stream", typeof(List <byte[]>));

            position = (int)info.GetValue("position", typeof(int));

            stream = new List <WaveOutBuffer>();

            empty = false;

            for (int i = 0; i < stream_byte.Count; i++)
            {
                empty = true;
                MemoryStream mstream = new MemoryStream(stream_byte[i]);
                mstream.Position = 0;
                BinaryFormatter bformatter = new BinaryFormatter();
                WaveOutBuffer   buffer     = (WaveOutBuffer)bformatter.Deserialize(mstream);
                stream.Add(buffer);
            }
        }
Exemplo n.º 5
0
 public void loadAudio()
 {
     while (true)
     {
         while (isPaused == 1)
         {
             Thread.Sleep(200);
         }
         try
         {
             currentBuffer = stream[countWaveOut].read();
             while (BitmapPlayer.countFrame - 1 < countWaveOut * BitmapPlayer.bitmapPerSec)
             {
             }
             if (currentBuffer != null)
             {
                 //视频滞后等视频
                 //双方都是等待滞后的那个所以不用管超前的
                 currentBuffer.waveOut = reader.waveOut;
                 currentBuffer.Play();
             }
             else
             {
                 //播放完了
                 while (stream.Count == 0)
                 {
                     if (finish == 1)
                     {
                         return;
                     }
                 }
                 countWaveOut++;
             }
         }
         catch { }
     }
 }
 public void addBuffer(WaveOutBuffer input)
 {
     stream.Add(input);
     empty = false;
 }