WinRT C# 使用 MediaElement 播放视频 [英] WinRT C# Play a viddler video using MediaElement
本文介绍了WinRT C# 使用 MediaElement 播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在我的应用程序中播放 Viddler 视频,但我无法让它工作.这是我的简单代码:
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" />
还有我的 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....
最后我决定调用http://www.viddler.com/embed/5b17d44f/ url 到 Webview,这不是最好的主意,但它有效.
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.
推荐答案
- 不要创建新的 MediaElemet.您已经创建了一个 (XAML).
- 在 XAML 中设置
AutoPlay="True"
编辑:仅当媒体已加载时播放才有效.
Edit: Play works only if the media is already loaded.
这篇关于WinRT C# 使用 MediaElement 播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文