/// <summary> /// Retrieves videos stored in Azure Video Indexer for a specific account. /// </summary> /// <param name="sender">The XAML control which raised the event.</param> /// <param name="e">Event parameters.</param> private async void BtnGetVideos_Click(object sender, RoutedEventArgs e) { string msg; try { VideoIndexerSearchResults searchResult = await this.client.GetVideosAsync().ConfigureAwait(false); if (searchResult != null && searchResult.Videos.Count > 0) { msg = $"Search results found: {searchResult.Videos.Count} video entries."; this.PostStatusMessage(msg); // Use the first video returned in the list and load it in the media player // Note that videos aren't sorted other than by the order in which they were uploaded this.DisplayVideoData(searchResult.Videos[0]); // Get insights from indexer for the first video in the list this.DisplayInsights(searchResult.Videos[0].Id); } } catch (WebException exc) { msg = $"Video Indexer API error retrieving videos for account {this.accountId}:" + Environment.NewLine + exc.Message; } catch (Exception exc) { msg = $"General error retrieving videos for account {this.accountId}:" + Environment.NewLine + exc.Message; this.PostStatusMessage(msg); } }
/// <summary> /// Retrieves videos currently stored in a specific Video Indexer account. /// </summary> /// <returns>Full object structure containing VideoIndexerSearchResults.</returns> public async Task <VideoIndexerSearchResults> GetVideosAsync() { Uri requestUri = new Uri($"{VideoIndexerApiUrl}/{this.accountLocation}/Accounts/{this.accountId}/Videos/Search?accessToken={this.accountAccessToken}"); var searchRequestResult = await client.GetAsync(requestUri).ConfigureAwait(false); if (searchRequestResult.IsSuccessStatusCode) { // Only the first page of results is returned // TODO: Add paging support to retrieve subsequent videos for a search query VideoIndexerSearchResults searchResult = JsonConvert.DeserializeObject <VideoIndexerSearchResults>(await searchRequestResult.Content.ReadAsStringAsync().ConfigureAwait(false)); return(searchResult); } else { Debug.WriteLine($"An error has occurred while retrieving the videos for account ID {this.accountId}."); throw new WebException(searchRequestResult.ReasonPhrase); } }