private void DownloadVideosCompleted(object sender, DownloadDataCompletedEventArgs e) { dynamic res = JsonConvert.DeserializeObject(System.Text.Encoding.UTF8.GetString(e.Result)); foreach (var item in res.items) { //need to cast item values into strings string a = item.id.videoId; string b = item.snippet.thumbnails.medium.url; string c = item.snippet.title; string d = item.snippet.channelTitle; string eee = item.snippet.channelId; VideoResult v = new VideoResult(a, b, c, d, eee); if (item.snippet.liveBroadcastContent == "none") { v.broadcast = false; } if (item.snippet.liveBroadcastContent == "live") { v.broadcast = true; } vRes.Add(v); } res = null; FillDataGrid(vRes); }
private async Task RunCmd(string args, VideoResult item) { var proc = new Process { StartInfo = new ProcessStartInfo { FileName = "cmd.exe", Arguments = args, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; proc.Start(); string output = await proc.StandardOutput.ReadToEndAsync(); proc.Close(); if (output != "") { output = output.Remove(output.Length - 1); if (item.broadcast == true) { output = "<!DOCTYPE html><html><head><title></title><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><meta charset='utf-8'></head><body><video controls autoplay id='videotag' style='width:100%;'><source src='" + output + "' >Your browser does not support the video tag.</video></body><script type='text/javaScript'>var vid = document.getElementById('videotag');vid.volume=" + Properties.Settings.Default.volume + ";</script></html>"; using (System.IO.StreamWriter sw = System.IO.File.CreateText("temp.html")) { sw.WriteLine(output); } Process.Start("temp.html", "--window-position=10,10 --window-size = 600, 600"); wbMain.NavigateToString("due to compatibility problems, the Livestream was opened on your default browser"); this.checkBox_Loop.IsEnabled = false; } else { output = "<!DOCTYPE html><html><head><title></title><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><meta charset='utf-8'></head><body style='background:black;'>" + "<audio controls autoplay style='width:100%;height:45px;'id='audiotag'><source src='" + output + "' type='audio/mpeg'>Your browser does not support the audio tag.</audio></body>" + "<script type='text/javaScript'>var vid = document.getElementById('audiotag');vid.volume=" + Properties.Settings.Default.volume + "; vid.loop=" + loopMusicMode.ToString().ToLower() + "; vid.onvolumechange = function(){window.external.GetVolumeChanged(vid.volume);};function EnableLoop(){vid.loop = true;} function DisableLoop(){vid.loop = false;} </script></html>"; wbMain.NavigateToString(output); if (this.checkBox_Loop.IsEnabled == false) { this.checkBox_Loop.IsEnabled = true; } } this.Title = " ► " + item.videoname; } else { wbMain.NavigateToString("<h1 style='font-family: modern, serif; font-size:14pt;' >This video is unavialble... Sorry :/</h1>"); } }