¿Cómo se alimenta la carga APIES V3 de YouTube en Windows Store C #
-
21-12-2019 - |
Pregunta
para mostrar un feed de noticias, música, deportes.gracias.
private void loadfeedYoutube()
{
string feedUrl="https://gdata.youtube.com/feeds/api/standardfeeds/most_popular";
var request=new
Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));
printVideoFeed(videoFeed);
static void printVideoFeed(Feed<Video> feed)
{
foreach (Video entry in feed.Entries)
{
printVideoEntry(entry);
}
}
}
Estoy usando:
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
Error: No encontrar feed, Solicitar ...
Solución
Hay usando myToolkit
private void GetYoutubeChannel(string feedXML)
{
try
{
SyndicationFeed feed = new SyndicationFeed();
feed.Load(feedXML);
List<YoutubeVideo> videosList = new List<YoutubeVideo>();
YoutubeVideo video;
foreach (SyndicationItem item in feed.Items)
{
video = new YoutubeVideo();
video.YoutubeLink = item.Links[0].Uri;
string a = video.YoutubeLink.ToString().Remove(0, 31);
video.Id = a.Substring(0, 11);
video.Title = item.Title.Text;
video.PubDate = item.PublishedDate.DateTime;
video.Thumbnail = YouTube.GetThumbnailUri(video.Id, YouTubeThumbnailSize.Large);
videosList.Add(video);
}
MainListBox.ItemsSource = videosList;
}
catch { }
}
Otros consejos
lê thiên hoàng
Puede intentar usar la SyndicationFeed para ayudarlo,
Revise este ejemplo, que use el proyecto MyToolkit para implementar.
http://code.msdn.microsoft.com/WindowsApps / YouTube-Sample-Get-YouTube-E9A3E0BE
y usted utilizando el método Feedurl es una API antigua que es V2 no V3.
@ lê thiên hoàng
usando http://gdata.youtube.com/demo/index.html para generar que quieres obtener.
Si desea obtener música popular, entonces su enlace API RESTFULT es: http://gdata.youtube.com/feeds/api/standardfeeds/most_veled/-/ {http://gdata.youtube.com/schemas/2007/categories.cat} Music? Alt= RSS
Pero recomiendo si puede, usar YouTube API Version3, es mejor y más fácil obtener un video de diferentes categorías.
void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
{
try
{
DataModel.YoutubeVideo value = e.NavigationParameter as DataModel.YoutubeVideo;
if(!string.IsNullOrWhiteSpace(value.id))
{
txttitle.Text = value.title;
Mediaplayer.Source = value.youtubelink;
}
}
catch
{
throw new NotImplementedException();
}
}
Recibo esta fuente: Fuente: http://www.youtube.com/watch? v= _oblgsz8ssm & característica= youtube_gdata
pero no está jugando ...