Skip to main content

Microsoft Silverlight

Answered Question Media Element does not play .wmv files dynamicallyRSS Feed

(0)

vegar9962
vegar9962

Member

Member

0 points

1 Posts

Media Element does not play .wmv files dynamically

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">

<!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>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;<br />
&lt;title&gt;Stream Video&lt;/title&gt;<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 />
&lt;/head&gt;<br />
&lt;body&gt;<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
kelps

Member

Member

399 points

66 Posts

Re: Media Element does not play .wmv files dynamically

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 Sousa
Blog | Twitter
Dont forget to click "Mark as Answer" on the post that helped you.

Mog Liang - MSFT
Mog Lian...

All-Star

All-Star

15898 points

1,544 Posts

Answered Question

Re: Media Element does not play .wmv files dynamically

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,

Mog Liang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

kelps
kelps

Member

Member

399 points

66 Posts

Re: Media Element does not play .wmv files dynamically

I didn't know that the MediaElement had no restrictions regarding crossdomain. Good to know. Thanks Mog Liang.

Best regards,
Kelps Leite de Sousa
Blog | Twitter
Dont forget to click "Mark as Answer" on the post that helped you.

ashish.chotalia
ashish.c...

Member

Member

2 points

1 Posts

Re: Media Element does not play .wmv files dynamically

Thanks,

 Solution found.

joji777
joji777

Member

Member

84 points

218 Posts

Re: Re: Media Element does not play .wmv files dynamically

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

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities