A C# application using the Youtube Data API v2, to get results search results from youtube, then fill a list of video models, including a streamable link. By clicking on the video title you can watch the video ad free..
The app can search asynchronusly so you can search while you watch. The app includes a settings page that allows you change how many search results you get back.
private async Task> Run(string query)
{
ObservableCollection<Videos> vidlist = new ObservableCollection<Videos>();
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "AIzaSyAEmP6-BFQbwDeVmYkA0fK2fpA_oTTJrv0",
ApplicationName = this.GetType().ToString()
});
var searchListRequest = youtubeService.Search.List("snippet");
searchListRequest.Q = query; // Replace with your search term.
searchListRequest.MaxResults = maxResults;
// Call the search.list method to retrieve results matching the specified query term.
var searchListResponse = await searchListRequest.ExecuteAsync();
// Add each result to the appropriate list, and then display the lists of
// matching videos, channels, and playlists.
foreach (var searchResult in searchListResponse.Items)
{
switch (searchResult.Id.Kind)
{
case "youtube#video":
vidlist.Add(new Videos(searchResult.Id.VideoId, searchResult.Id.ChannelId, searchResult.Snippet.Title,+
searchResult.Snippet.Description, "https://youtube.com/embed/" + searchResult.Id.VideoId,+
searchResult.Snippet.Thumbnails.Default__));
break;
}
}
return vidlist;
}
Async Chat
The Async chat was a three assignment long program. That started as a console application that allowed chatting over a network, using port numbers, and IP addressed. It allowed the two clients to comunicate via synchronus messaging.
By the second assignment it was built into a Windows form, and had logging capability. The third assignment added loosely coupled logging, and dependency injection, allowing us to plug any other classmates logging DLL into our project and it will work by just changing the 'using' statements.
This homemade media player can play .wav's or .mp4's. It is plays local file, and when you open the file dialog it open allows you to select limited file types.
The media buttons are all custom, and the slider bar using DispatcherTimer an NaturalDuration to calculate where the slider should be and move it each tick. It also processes where you drag it and updates in real time.
private void sliProgress_DragStarted(object sender, DragStartedEventArgs e)
{
//Set the dragging variable to true
userIsDraggingSlider = true;
MediaPlayer.Position = TimeSpan.FromSeconds(sliProgress.Value);
}
private void sliProgress_DragCompleted(object sender, DragCompletedEventArgs e)
{
//set dragging varialbe to false and change the location in video to where
//you stopped dragging
userIsDraggingSlider = false;
MediaPlayer.Position = TimeSpan.FromSeconds(sliProgress.Value);
}
private void sliProgress_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
//Change the label to the value of the slider in formatting for h/m/s
lblProgressStatus.Text = TimeSpan.FromSeconds(sliProgress.Value).ToString(@"hh\:mm\:ss");
}