I try to set video source in XAML code, video doesn't play:
<MediaElement x:Name="bgvideo" Width="800" Height="600"Source="/Videos/BG_LOOP_BIG.wmv" />
So I try to set video source in codebehind, that doesn't play too. :
bgvideo.Source = new Uri(@"pack://application:,,,/Videos/BG_LOOP_BIG.wmv", UriKind.Absolute);
or
bgvideo.Source = new Uri(@"/Videos/BG_LOOP_BIG.wmv");
It just play when video source is absoulte:
bgvideo.Source = new Uri(@"C:\SomeFolder\Videos\BG_LOOP_BIG.wmv");
How can I set video source with relative source?
This works for me. Add LoadedBehavior="Manual"
<MediaElement LoadedBehavior="Manual" x:Name="bgvideo" Width="800" Height="600" Source="Videos/BG_LOOP_BIG.wmv" />
Then in the code behind you need to play the media
bgvideo.Play()
You also need to lose the first '/' in the uri.
hth