windows - 在 Windows Phone 8 开发中使用 YouTube v3 Api

标签 windows api windows-phone-8 youtube

我花了几个小时试图找到一些关于如何在 Windows Phone 8 开发中使用 YouTube V3 Api .NET 库的信息。甚至 Nokia 本身也无济于事,因为他们的 Wiki 页面只是展示了如何使用 WebClient 做事(甚至在那里也不是那么清楚)。

我已经很难找到任何指南或与 YouTube v3 Api 的 .NET 库相关的任何内容,并且我一直在关注似乎不起作用的示例代码(尤其是这个 - https://github.com/youtube/api-samples/blob/master/dotnet/Search.cs )

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

最佳答案

框架“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 :-)

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

关于windows - 在 Windows Phone 8 开发中使用 YouTube v3 Api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21117346/

相关文章:

c - 如何不在文件系统设备驱动程序中进入死锁?

php - 子域上 Slim PHP REST API 的 .htaccess 配置?

windows-phone-7 - Windows Phone 中的 SSL 证书验证

ssl - Windows 8 Phone 客户端证书 HTTPS 身份验证

c# - 如何选择照片选择器?

windows - 从 MINGW 启动时运行 System32 程序而不是 SysWOW64

windows - NTFS 文件系统的 USN Journal 是否可以大于其声明的大小?

c# - 将项目添加到 ListView 时,MultiDataTrigger 的 EnterActions 中的 ColorAnimation 不触发

api - Flutter:Futurebuilder从类中获取空值

java - 获取艺术家的唱片目录,就像 musicbrainz 上的概览页面一样