Пример #1
0
        public void listen_audio_header()
        {
            while (true)
            {
                Package pack = conn.recv();
                if (pack.type == "request_audio")
                {
                    /*
                     * header
                     * [0] count
                     *
                     */
                    audio_resp = audio_reader.loadWaveOutStream(Int32.Parse(pack.header[0]));
                    MemoryStream    stream    = new MemoryStream();
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(stream, audio_resp);
                    byte[] data = stream.ToArray();

                    Package pack_resp = new Package("audio_resp");
                    pack_resp.data = data;
                    Connector conn_resp = Client.find_conn(Client.conn_audio_data, pack.from);
                    if (conn_resp != null)
                    {
                        conn_resp.send(pack_resp);
                    }
                }
                else if (pack.type == "ask_audio")
                {
                    /*
                     * header
                     * [0] count
                     *
                     * data
                     * format
                     *
                     */
                    /*audio_reader.loadFile(Local.ref_addr + @"audio\" + pack.header[0]);
                     * MemoryStream stream = new MemoryStream();
                     * BinaryFormatter formatter = new BinaryFormatter();
                     * formatter.Serialize(stream, audio_reader.format);
                     * byte[] data = stream.ToArray();
                     */
                    byte[]   data = new byte[0];
                    String[] tmp  = pack.header[0].Split('\\');
                    try
                    {
                        data = File.ReadAllBytes(Local.ref_addr + "audio\\" + tmp[tmp.Length - 1]);
                    }
                    catch
                    {
                    }

                    Package pack_resp = new Package("audio_format");
                    pack_resp.data = data;
                    pack_resp.header.Add(tmp[tmp.Length - 1]);
                    Connector conn_resp = Client.find_conn(Client.conn_audio_data, pack.from);
                    conn_resp.send(pack_resp);
                }
            }
        }
Пример #2
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);
        }
Пример #3
0
 public void loadWaveOutStream()
 {
     finish = 0;
     while (true)
     {
         WaveOutStream s = reader.loadWaveOutStream();
         if (s == null)
         {
             finish = 1;
             return;
         }
         stream.Add(s);
     }
 }
Пример #4
0
        public ThreadWithPort(String ip, int num1, int num2, String str, int num)
        {
            reader      = new BitmapReader();
            bitmap_resp = new BitmapStream();

            num_frac = num;

            audio_reader = new WaveOutReader();
            audio_resp   = new WaveOutStream();

            port_send   = num1;
            port_listen = num2;
            ip_send     = ip;
            conn        = new Connector(ip_send, port_send, port_listen);

            type = str;
        }