C#的windows media player 怎么实现边下载边播放,有例子最好...
程序代码:
private void DownLoad() { var request = WebRequest.Create("http://112.91.92.82/down_group226/M00/10/F9/d5NjWU9sgi8AAAAAAI1JBCBiFuQ1908112/%E6%9A%97%E5%8F%B7.avi?k=o3k9tkPyCjxURbqvBPTpJw&t=1332512185&u=114.240.35.97@29851728@dpdw3zsk&file=%E6%9A%97%E5%8F%B7.avi&speed=153600"); var response = request.GetResponse(); var strm = response.GetResponseStream(); Thread thread = null; thread = new Thread ( () => { long totalLength = response.ContentLength; byte[] buffer = new byte[1024 * 1024]; long count = 0; int length = strm.Read(buffer, 0, buffer.Length); FileStream fsWrite = new FileStream(@"E:\aa.avi",FileMode.Create); while (length != 0) { fsWrite.Write(buffer,0,length); count += length; int percentage = (int)(count * 100 / totalLength); //this.progressBar1.Value = percentage; //percentage.ToString()+"%" length = strm.Read(buffer, 0, buffer.Length); } thread.Abort(); strm.Close(); fsWrite.Close(); } ); thread.Start(); }