/// <summary> /// Load movie button, fetches link through get external html,and get src /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Click(object sender, RoutedEventArgs e) { if (listbox.SelectedItem != null) { String valueOfItem = listbox.SelectedItem.ToString(); Console.WriteLine(valueOfItem); //references c# file and methods inside GetTheVideos theVids = new GetTheVideos(); theVids.getGoogleSearch(valueOfItem); DirectURL = GetTheVideos.directURL; //Starts player mePlayer.Source = new Uri("http://" + DirectURL); image.Source = new BitmapImage(new Uri("http://rigor.com/wp-content/uploads/2015/06/loading.jpeg", UriKind.RelativeOrAbsolute)); mePlayer.Play(); PlayingMovie.IsReadOnly = false; PlayingMovie.Text = ""; PlayingMovie.Text = listbox.SelectedItem.ToString(); PlayingMovie.IsReadOnly = true; Console.WriteLine(DirectURL); image.Visibility = Visibility.Hidden; label = valueOfItem; PlayingMovie.IsReadOnly = false; PlayingMovie.Text = "LOADING MOVIE! Please Wait.."; PlayingMovie.Text = listbox.SelectedItem.ToString(); PlayingMovie.IsReadOnly = true; } }
/// <summary> /// Downloads the Movie =)) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DownloadMovie(object sender, RoutedEventArgs e) { String valueOfItem = listbox.SelectedItem.ToString(); Console.WriteLine(valueOfItem); label = valueOfItem; //references c# file and methods inside GetTheVideos theVids = new GetTheVideos(); theVids.getGoogleSearch(valueOfItem); String durl = GetTheVideos.directURL; ; Console.WriteLine(durl); Uri address = new Uri("http://" + durl); FileDialog fileDialog = new SaveFileDialog(); fileDialog.Filter = "Video File (*.mp4)|*.mp4|All files (*.*)|*.*"; fileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); fileDialog.DefaultExt = ".mp4"; fileDialog.FileName = label; fileDialog.ShowDialog(); saveLocation = fileDialog.FileName; Download.IsEnabled = false; WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback); client.DownloadFileAsync(address, @saveLocation); }