why the relactive uri can't work in MediaElement?
Last post 05-09-2008 1:08 AM by ahlcm. 3 replies.
Sort Posts:
05-07-2008 12:39 PM
why the relactive uri can't work in MediaElement?

I created a uri by the relactive path:

            (MediaElement)Player.Source =  new Uri("Bear.wmv",UriKind.RelativeOrAbsolute);
               

but the MediaElement can't work. if I modify the uri string to a absolute ("http://localhost:8888/Bear.wmv "), it's ok! so where is wrong? 

thanks for any suggestion. 

 

ahlcm

Joined on 05-05-2008
Posts 4
05-07-2008 2:21 PM
Marked as Answer
Re: why the relactive uri can't work in MediaElement?

You might have to say "/Bear.wmv",UriKind.Relative (notice the leading slash "/") depending on whether you have defined built type of the video as a resource, content or none. For a discussion on the differences between these build types, check this post. For a discussion on how to define URI paths, see this MSDN article.

Hope this helps,
Jim (http://jimmangaly.blogspot.com/)

Please MARK the replies as answers if they answered your question

 

http://www.identitymine.com/

Jim Mangaly

Joined on 04-21-2008
Kochi, India
Posts 108
05-08-2008 10:49 PM
Marked as Answer
Re: why the relactive uri can't work in MediaElement?

Dear ahlcm

To resolve your doubts, please follow the steps I provided below:

1.Modify the Xaml code of MediaElement control.

Please focus on the value of Source property of MediaElement control.
Do'nt forget the forward slash.You can refer to the Xaml code I listed below.

<MediaElement AutoPlay="False" MediaOpened="PlayMedia_MediaOpened"
  CurrentStateChanged="PlayMedia_CurrentStateChanged"
  x:Name="PlayMedia" Width="400" Source="/Bear.wmv" Margin="0,0,0,94"/>

The hierarchical of the files in my demo project The hierarchical of the files in my demo project is like the image left.

2.Change the attributes of the media file

Please change the setting value of "Building Actions" property of Bear.wmv to "Content".

3.Rebuild the project.

4.Rerun the test apsx or html.

SmallWhiteBear

Joined on 06-27-2006
Taipei, Taiwan
Posts 18
05-09-2008 1:08 AM
Re: why the relactive uri can't work in MediaElement?

Very good!

 

thanks ~

ahlcm

Joined on 05-05-2008
Posts 4