hahacjh
既然选择了远方 便只顾风雨兼程

Video.wmv在ClientBin目录下:

代码
void Page_Loaded(object sender, RoutedEventArgs e)
{
WebClient client
= new WebClient();
client.DownloadProgressChanged
+= new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.OpenReadCompleted
+= new OpenReadCompletedEventHandler(client_OpenReadCompleted);
client.OpenReadAsync(
new Uri("Video.wmv", UriKind.Relative));
}

void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
try
{
myMedia.SetSource(e.Result);
myMedia.Play();
}
catch
{
myStatus.Text
= "Terribly Error!";
}

}

void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
myStatus.Text
= string.Format("Progress of {0}%", e.ProgressPercentage);
System.Threading.Thread.Sleep(
100);
}

 

posted on 2010-03-01 14:07  hahacjh  阅读(324)  评论(0编辑  收藏  举报