【问题标题】:Using the YouTube v3 Api in Windows Phone 8 Development在 Windows Phone 8 开发中使用 YouTube v3 Api
【发布时间】:2014-01-14 15:31:01
【问题描述】:

我花了几个小时试图找到一些关于如何在 Windows Phone 8 开发中使用 YouTube V3 Api .NET 库的信息。甚至诺基亚自己也完全没有帮助,因为他们的 Wiki 页面只显示了如何使用 WebClient 做事(即使在那里也不是很清楚)。

我已经很难找到任何指南或与 YouTube v3 Api 的 .NET 库相关的任何内容,而且我一直在跟踪似乎不起作用的示例代码(尤其是这个 - @ 987654321@)

那么有人可以写或链接到一些使用 .NET 库的 Windows Phone 8 示例代码,例如,在 YouTube 上搜索某些内容吗?

【问题讨论】:

  • 你能使用 Youtube v3 API 吗?我也需要一些帮助。请回复..

标签: windows api windows-phone-8 youtube


【解决方案1】:

框架“MyToolkit”不包含任何搜索youtube api方法,但很容易搜索youtube视频见下文(示例代码)

    private void doYouTubeSearch()
    {
        if (YouTubeSearchText.Text.Length > 0)
        {
            this.LoadingProgressBar.IsIndeterminate = true;
            var wc = new WebClient();
            wc.DownloadStringCompleted += DownloadStringCompleted;
            var searchUri = string.Format("http://gdata.youtube.com/feeds/api/videos?q={0}&format=6", HttpUtility.UrlEncode(YouTubeSearchText.Text));
            wc.DownloadStringAsync(new Uri(searchUri));
        }
    }

    void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        var atomns = XNamespace.Get("http://www.w3.org/2005/Atom");
        var medians = XNamespace.Get("http://search.yahoo.com/mrss/");
        var xml = XElement.Parse(e.Result);
        var videos = (
          from entry in xml.Descendants(atomns.GetName("entry"))
          select new YouTubeViewModel
          {
              VideoId = entry.Element(atomns.GetName("id")).Value,
              VideoImageUrl = (
                from thumbnail in entry.Descendants(medians.GetName("thumbnail"))
                where thumbnail.Attribute("height").Value == "360"
                select thumbnail.Attribute("url").Value).FirstOrDefault(),
              Title = entry.Element(atomns.GetName("title")).Value,
              Description = entry.Element(atomns.GetName("content")).Value
          }).ToArray();  .... more code here :-)

...您可以在此过滤等...

【讨论】:

    【解决方案2】:

    我在开发者控制台中找不到任何与 windows phone 8 相关的 Api 访问密钥。也许这就是示例不起作用的原因(?)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 2016-04-15
      • 2013-02-23
      • 1970-01-01
      相关资源
      最近更新 更多