Exemplo n.º 1
0
        private void Playbtn_Click(object sender, EventArgs e)
        {
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            s.Connect(IPAddress.Parse("127.0.0.1"), 5000);
            NetworkStream mp3Stream   = new NetworkStream(s);
            List <byte>   listOfBytes = new List <byte>();
            MemoryStream  memStream   = new MemoryStream();

            byte[] buf     = new byte[8192];
            int    numRead = 0;

            while ((numRead = mp3Stream.Read(buf, 0, buf.Length)) > 0)
            {
                memStream.Write(buf, 0, numRead);
            }
            memStream.Position = 0;
            song = new Tune()
            {
                stream = memStream
            };
            song.PlayStream();
        }