我构建了一个youtube应用程序,我使用了google、v3和mytoolkit,代码如下:
<Grid x:Name="LayoutRoot" Background="Transparent">
<player:MediaPlayer x:Name="player" AutoPlay="True" />
</Grid>代码背后:
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
try
{
if (NetworkInterface.GetIsNetworkAvailable())
{
string videoId = string.Empty;
if (NavigationContext.QueryString.TryGetValue("videoId", out videoId))
{
//Get The Video Uri and set it as a player source
var url = await MyToolkit.Multimedia.YouTube.GetVideoUriAsync(videoId, MyToolkit.Multimedia.YouTubeQuality.Quality480P);
if (url != null)
player.Source = url.Uri;
// MessageBox.Show(url.Uri.ToString());
player.Play();
}
}
else
{
MessageBox.Show("You're not connected to Internet!");
NavigationService.GoBack();
}
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
base.OnNavigatedTo(e);
}但是,当应用程序运行时,我无法播放选定的视频,我如何修复这个错误?
发布于 2015-10-20 20:56:14
您是否使用了正确的videoId,您可以这样做:
public Youtube()
{
InitializeComponent();
Loaded += Youtube_Loaded;
}
async void Youtube_Loaded(object sender, RoutedEventArgs e)
{
try
{
string videoId = "iqjMRdev0FI";
var url = await YouTube.GetVideoUriAsync(videoId, YouTubeQuality.Quality480P);
player.Source = url.Uri;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}希望这能有所帮助。
https://stackoverflow.com/questions/32174217
复制相似问题