WinRT C# Play a viddler video using MediaElement

梦想与她 提交于 2020-01-17 02:50:30

问题


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:


  1. Dont create a new MediaElemet. You already have one created (XAML).
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!