问题
I am trying to play a Viddler video in my application but i cant get it to work. Here is my simple code:
XAML:
< MediaElement VerticalAlignment="Center" Visibility="Visible"
HorizontalAlignment="Center"
Name="myMediaElement" Height="350"
Width="640" />
And my c#:
myMediaElement = new MediaElement();
Uri url = new Uri("http://www.viddler.com/embed/5b17d44f/");
myMediaElement.Source = url;
myMediaElement.Play();
Any help would be great! When i arrive on the page, nothing happens, the application does not break it just does nothing....
Edit: In the end I have just decided to call the http://www.viddler.com/embed/5b17d44f/ url into a Webview, its not the best idea but it works.
回答1:
- Dont create a new MediaElemet. You already have one created (XAML).
- Set
AutoPlay="True"
in your XAML
Edit: Play works only if the media is already loaded.
来源:https://stackoverflow.com/questions/13181809/winrt-c-sharp-play-a-viddler-video-using-mediaelement