Skip to main content
Home Forums General Silverlight Hosting and Streaming Media Element does not play .wmv files dynamically
5 replies. Latest Post by joji777 on October 29, 2009.
(0)
vegar9962
Member
0 points
1 Posts
09-21-2009 3:32 PM |
I have a webserver that I use to stram video using a simple web page as:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head><meta content="en-us" http-equiv="Content-Language" /><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>Untitled 1</title></head>
<body>
<p><html><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><br /><title>Stream Video</title><br /><object id="media1" height="200" type="video/x-ms-wmv" width="200"> <param name="filename" value="http://127.0.0.1:8001/GunCONTROL.wmv" /></object><br /></head><br /><body><br /></p>
</body>
</html>The page plays the video nicely. However, when I used the Silverlight MediaElement on a page as:
public partial class Page : UserControl { public Page() { InitializeComponent();
VideoMediaElement.DownloadProgressChanged += new RoutedEventHandler(Video_DownloadProgressChanged); VideoMediaElement.BufferingProgressChanged += Video_BufferingProgressChanged; VideoMediaElement.MediaOpened += VideoMediaElement_MediaOpened; }
private void VideoMediaElement_MediaOpened(object sender, RoutedEventArgs e) { //VideoMediaElement.Position = TimeSpan.FromDays(1); //VideoMediaElement.Position = TimeSpan.FromSeconds(0); }
private void Video_BufferingProgressChanged(object sender, RoutedEventArgs e) { BufferProgress.Value = VideoMediaElement.BufferingProgress * 100; DownloadProgress.Value = VideoMediaElement.DownloadProgress * 100; OffsetValue.Value = VideoMediaElement.DownloadProgressOffset * 100; }
private void Video_DownloadProgressChanged(object sender, RoutedEventArgs e) { DownloadProgress.Value = VideoMediaElement.DownloadProgress * 100; OffsetValue.Value = VideoMediaElement.DownloadProgressOffset * 100; }
private void Pause_Click(object sender, RoutedEventArgs e) { VideoMediaElement.Pause(); }
private void Play_Click(object sender, RoutedEventArgs e) { if (!Uri.IsWellFormedUriString(URI.Text, UriKind.Absolute)) { MessageBox.Show("Invalid URI"); return; } VideoMediaElement.AutoPlay = true; VideoMediaElement.Source = new Uri(URI.Text); VideoMediaElement.Play(); }
private void Stop_Click(object sender, RoutedEventArgs e) { VideoMediaElement.Stop(); }
}
and place the http://127.0.0.1:8001/GunCONTROL.wmv in the Uri.Text field, the file does not make a request to the http webserver after the VideoMediaElement.Play(); is called.
What am I doing wrong here?
Kindly
Rich
kelps
399 points
66 Posts
09-22-2009 7:11 AM |
Here is a few things that you could check:
1 - Is your wmv file encoded for use with Silverlight? It might've been encoded in a way not supported by Silverlight. Try placing your wmv file on the same folder as your xap file (this is usualy a folder called ClientBin)and change the source of your MediaElement to simply the file name. If this works, your file is supported by Silverlight. 2 - Is the page that is hosting your Silverlight app running on the same site (127.0.0.1 and localhost are considered different sites)? If not, this is probably a crossdomain problem. To solve this you'll have to either host your silverlight app on the streaming site or add a crossdomain policy file on the streaming site. Look at this thread for more info on crossdomain files : http://forums.silverlight.net/forums/p/128502/287682.aspx
Hope this helps. If not, let me know.
Best regards,Kelps Leite de SousaBlog | TwitterDont forget to click "Mark as Answer" on the post that helped you.
Mog Lian...
All-Star
15898 points
1,544 Posts
09-24-2009 12:16 AM |
Hi,
Cross-domain is permitted in MediaElement.Source, policy file is not needed.
I guess you opened the silverlight application page from local drive, then the attempting access "http" address is not allowed.
You may open the page from websever.
Thanks,
09-24-2009 8:18 PM |
I didn't know that the MediaElement had no restrictions regarding crossdomain. Good to know. Thanks Mog Liang.
ashish.c...
2 points
10-06-2009 7:54 AM |
Solution found.
joji777
84 points
218 Posts
10-29-2009 10:35 AM |
i am getting 4001 error when i try to play wmv file in silverlight 2 on HTTPS, if I play it using HTTP, it works fine, can you please guide me what I am doing wrong here?
Regards