public void descmp3() { progreso.Visibility = ViewStates.Visible; enporceso = true; /* * videoinfoss = DownloadUrlResolver.GetDownloadUrls(linkvid, false); * * VideoInfo video2 = videoinfoss.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 0); */ RunOnUiThread(() => Toast.MakeText(this, "obteniendo informacion del video", ToastLength.Long).Show()); RunOnUiThread(() => progreso.Progress = 25); var asd = VideosHelper.GetShortVideoInfo(linkvid, false, -1); if (asd != null) { RunOnUiThread(() => progreso.Progress = 50); // Intent intento = new Intent(this, typeof(serviciodownload)); string localFilename = RemoveIllegalPathCharacters(asd.Title).Trim() + ".mp3"; string localPath = Path.Combine(rutadedescarga, localFilename); // intento.PutExtra("path", localPath); // intento.PutExtra("archivo", asd.downloadurl); // intento.PutExtra("titulo", asd.titulo); // intento.PutExtra("link", linkvid); if (serviciodownload.gettearinstancia() != null) { serviciodownload.gettearinstancia().descargar(localPath, asd.DownloadUrl, asd.Title, linkvid); } else { StartService(new Intent(this, typeof(serviciodownload))); Thread.Sleep(300); serviciodownload.gettearinstancia().descargar(localPath, asd.DownloadUrl, asd.Title, linkvid); } RunOnUiThread(() => progreso.Progress = 100); /// StartService(intento); RunOnUiThread(() => this.Finish()); RunOnUiThread(() => Toast.MakeText(this, "Descarga iniciada", ToastLength.Long).Show()); } else { RunOnUiThread(() => { Toast.MakeText(this, "Error al extraer el video posiblemente los servidores esten en mantenimiento", ToastLength.Long).Show(); }); } }
public void descvids() { progreso.Visibility = ViewStates.Visible; enporceso = true; string video2 = ""; string title = ""; RunOnUiThread(() => Toast.MakeText(this, "obteniendo informacion del video", ToastLength.Long).Show()); RunOnUiThread(() => progreso.Progress = 25); var elemento = VideosHelper.GetShortVideoInfo(linkvid, false, quality); if (elemento != null) { title = elemento.Title; video2 = elemento.DownloadUrl; RunOnUiThread(() => progreso.Progress = 50); var pathFile = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads); string documentsPath = pathFile.AbsolutePath; RunOnUiThread(() => progreso.Progress = 75); string localFilename = RemoveIllegalPathCharacters(title).Trim() + ".mp4"; string localPath = Path.Combine(rutadedescarga, localFilename); if (serviciodownload.gettearinstancia() != null) { serviciodownload.gettearinstancia().descargar(localPath, video2, title, linkvid); } else { StartService(new Intent(this, typeof(serviciodownload))); Thread.Sleep(300); serviciodownload.gettearinstancia().descargar(localPath, video2, title, linkvid); } RunOnUiThread(() => this.Finish()); RunOnUiThread(() => progreso.Progress = 100); RunOnUiThread(() => Toast.MakeText(this, "Descarga iniciada", ToastLength.Long).Show()); } else { RunOnUiThread(() => { Toast.MakeText(this, "Error al extraer el video posiblemente los servidores esten en mantenimiento", ToastLength.Long).Show(); }); } }
public void descmp3() { enporceso = true; /* * videoinfoss = DownloadUrlResolver.GetDownloadUrls(linkvid, false); * * VideoInfo video2 = videoinfoss.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 0); */ RunOnUiThread(() => { #pragma warning disable CS0618 // El tipo o el miembro están obsoletos dialogoprogreso = new ProgressDialog(this); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos dialogoprogreso.SetCanceledOnTouchOutside(false); dialogoprogreso.SetCancelable(false); dialogoprogreso.SetTitle("Analizando video..."); dialogoprogreso.SetMessage("Por favor espere"); dialogoprogreso.Show(); }); var asd = VideosHelper.GetShortVideoInfo(linkvid, false, -1); if (asd != null) { Intent intento = new Intent(this, typeof(serviciodownload)); string localFilename = RemoveIllegalPathCharacters(asd.Title).Trim() + ".mp3"; string localPath = Path.Combine(rutadedescarga, localFilename); /* intento.PutExtra("path", localPath); * intento.PutExtra("archivo", asd.downloadurl); * intento.PutExtra("titulo", asd.titulo); * intento.PutExtra("link", linkvid); * StartService(intento);*/ if (serviciodownload.gettearinstancia() != null) { serviciodownload.gettearinstancia().descargar(localPath, asd.DownloadUrl, asd.Title, linkvid); } else { StartService(new Intent(this, typeof(serviciodownload))); Thread.Sleep(300); serviciodownload.gettearinstancia().descargar(localPath, asd.DownloadUrl, asd.Title, linkvid); } RunOnUiThread(() => this.Finish()); RunOnUiThread(() => Toast.MakeText(this, "Descarga iniciada", ToastLength.Long).Show()); /* * WebClient webClient = new WebClient(); * webClient.DownloadDataAsync(new Uri(video2.DownloadUrl)); * RunOnUiThread(() => Toast.MakeText(this, "Descarga iniciada", ToastLength.Long).Show()); * webClient.DownloadProgressChanged += (sendel, easter) => * { * * pv.Progress = easter.ProgressPercentage; * * }; * webClient.DownloadDataCompleted += (s, e) => { * RunOnUiThread(() => Toast.MakeText(this, "Descarga completada", ToastLength.Long).Show()); * mostrarnotificacion(100, video2.Title, linkvid); * var bytes = e.Result; // get the downloaded data * * var pathFile = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads); * string documentsPath = pathFile.AbsolutePath; * * string localFilename = video2.Title + ".mp3"; * string localPath = Path.Combine(rutadedescarga, localFilename); * archivocompleto = localPath; * File.WriteAllBytes(localPath, bytes); // writes to local storage * enporceso = false; * pv.Progress = 0; * };*/ } else { RunOnUiThread(() => { Toast.MakeText(this, "Error al extraer el video posiblemente los servidores esten en mantenimiento", ToastLength.Long).Show(); }); } RunOnUiThread(() => dialogoprogreso.Dismiss()); }
/// <summary> /// //////////////////////////////////////////////////////////////////voids/////////////////////////////////////////////////////////////////////// /// </summary> /// public void mp3play() { while (parador == true) { RunOnUiThread(() => tv3.Text = "Cargando."); /* * videoinfoss = null; * VideoInfo video = null; * * * * videoinfoss = DownloadUrlResolver.GetDownloadUrls(linkvid.Trim(), false); * Thread.Sleep(200); * * * * * video = videoinfoss.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 0); * * */ var prrin = VideosHelper.GetShortVideoInfo(linkvid, false, -1); if (prrin != null) { #pragma warning disable CS0618 // El tipo o el miembro están obsoletos musicaplayer.SetAudioStreamType(Android.Media.Stream.Music); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos RunOnUiThread(() => tv3.Text = "Cargando.."); musicaplayer = Android.Media.MediaPlayer.Create(this, Android.Net.Uri.Parse(prrin.DownloadUrl)); RunOnUiThread(() => tv3.Text = "Cargando..."); try { } catch (Exception) { } RunOnUiThread(() => tv3.Text = prrin.Title); RunOnUiThread(() => seek.Max = musicaplayer.Duration); while (parador == true) { try { if (musicaplayer.IsPlaying == true) { seek.Progress = musicaplayer.CurrentPosition; Thread.Sleep(400); } } catch (Exception) { }; //RunOnUiThread(() => seek.Progress = musicaplayer.CurrentPosition); } } else { RunOnUiThread(() => { Toast.MakeText(this, "Error al extraer el video posiblemente los servidores esten en mantenimiento", ToastLength.Long).Show(); }); } } }
protected override void OnCreate(Bundle savedInstanceState) { ISharedPreferences prefs = Application.Context.GetSharedPreferences("Settings", FileCreationMode.Private); ISharedPreferencesEditor prefEditor = prefs.Edit(); SetContentView(Resource.Layout.Downloadcenterofflinedialog); base.OnCreate(savedInstanceState); var perrito = this.Theme; //////////////////////////////////TCpclientconnect///////////// var intento = Intent; var share = intento.Action; var tipo = intento.Type; if (Intent.ActionSend.Equals(share)) { if (tipo.Contains("text/plain")) { string krecibio = intento.GetStringExtra(Intent.ExtraText); if (krecibio.Contains("youtu.be") || krecibio.Contains("youtube.com")) { linkvid = "https://www.youtube.com/watch?v=" + krecibio.Split('/')[3]; colores = "DarkGray"; } else { Toast.MakeText(this, "Este enlace no proviene de youtube", ToastLength.Long).Show(); this.Finish(); } } else { Toast.MakeText(this, "Este enlace no proviene de youtube", ToastLength.Long).Show(); this.Finish(); } } else { linkvid = Intent.GetStringExtra("zelda"); colores = Intent.GetStringExtra("color"); } Intent.Extras.Clear(); TextView titulo = FindViewById <TextView>(Resource.Id.textView4); titulo.Selected = true; this.SetFinishOnTouchOutside(true); new Thread(() => { RunOnUiThread(() => { var videoTitle = VideosHelper.GetVideoTitle(linkvid); titulo.Text = videoTitle; }); }).Start(); //////////////////////////////////DEclaraciones//////////////// RadioGroup radio1 = FindViewById <RadioGroup>(Resource.Id.radioGroup1); progreso = FindViewById <ProgressBar>(Resource.Id.progressBar1); Button iv2 = FindViewById <Button>(Resource.Id.imageView2); ImageView iv4 = FindViewById <ImageView>(Resource.Id.imageView3); progreso.Visibility = ViewStates.Gone; RadioButton rb4 = FindViewById <RadioButton>(Resource.Id.radioButton4); RadioButton rb5 = FindViewById <RadioButton>(Resource.Id.radioButton5); RadioButton rb6 = FindViewById <RadioButton>(Resource.Id.radioButton6); ImageView fondo = FindViewById <ImageView>(Resource.Id.fondo1); ImageView imagenredonda = FindViewById <ImageView>(Resource.Id.imageView4); lineall2 = FindViewById <LinearLayout>(Resource.Id.linearLayout2); llayout = FindViewById <LinearLayout>(Resource.Id.LinearLayout0); progreso.Visibility = ViewStates.Gone; new Thread(() => { var imagenklk = ImageHelper.GetImageBitmapFromUrl("https://i.ytimg.com/vi/" + linkvid.Split('=')[1] + "/mqdefault.jpg"); RunOnUiThread(() => { imagenredonda.BringToFront(); imagenredonda.BringToFront(); imagenredonda.SetImageBitmap(ImageHelper.GetRoundedShape(imagenklk)); fondo.SetImageBitmap(imagenklk); animar4(imagenredonda); }); }).Start(); ///////////////////////////////////////mp3load+durationbarload////////////////////// // lineall2.SetBackgroundColor(Android.Graphics.Color.Black); // animar2(lineall2); /////////////////////////////miselaneo/////////////////////////////////////////////// if (colores != "none" && colores != "" && colores != " ") { // llayout.SetBackgroundColor(Android.Graphics.Color.ParseColor(colores)); } rutadedescarga = prefs.GetString("rutadescarga", null); // lineall2.SetBackgroundColor(Android.Graphics.Color.ParseColor(clasesettings.gettearvalor("color"))); ///////////////////////////////////events////////////////////////////////////// iv4.Click += delegate { animar(iv4); parador = false; this.Finish(); }; iv2.Click += delegate { animar(iv2); progreso.Visibility = ViewStates.Visible; if (enporceso == false && rb4.Checked == true) { quality = 720; Thread tree = new Thread(new ThreadStart(descvids)); tree.Start(); } else if (enporceso == false && rb5.Checked == true) { quality = 360; Thread tree2 = new Thread(new ThreadStart(descvids)); tree2.Start(); } else if (enporceso == false && rb6.Checked == true) { quality = 0; Thread tree3 = new Thread(new ThreadStart(descmp3)); tree3.Start(); } }; musicaplayer.SeekComplete += delegate { }; }
public void buscaryabrir() { RunOnUiThread(() => { #pragma warning disable CS0618 // El tipo o el miembro están obsoletos dialogoprogreso = new ProgressDialog(this); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos #pragma warning restore CS0618 // El tipo o el miembro están obsoletos dialogoprogreso.SetCanceledOnTouchOutside(false); dialogoprogreso.SetCancelable(false); dialogoprogreso.SetTitle("Buscando resultados..."); dialogoprogreso.SetMessage("Por favor espere"); dialogoprogreso.Show(); }); try { string url = getearurl(termino); // RunOnUiThread(() => progreso.Progress = 50); if (url != "%%nulo%%") { var a = VideosHelper.GetShortVideoInfo(url, true, -1); // RunOnUiThread(() => progreso.Progress = 100); if (a != null) { Intent intentar = new Intent(this, typeof(customdialogact)); RunOnUiThread(() => { dialogoprogreso.Dismiss(); intentar.PutExtra("ipadress", ip); intentar.PutExtra("imagen", "https://i.ytimg.com/vi/" + url.Split('=')[1] + "/mqdefault.jpg"); intentar.PutExtra("url", url); intentar.PutExtra("titulo", a.Title); intentar.PutExtra("color", "DarkGray"); StartActivity(intentar); }); } else { RunOnUiThread(() => { dialogoprogreso.Dismiss(); Toast.MakeText(this, "Error al extraer el video posiblemente los servidores esten en mantenimiento", ToastLength.Long).Show(); }); } } else { RunOnUiThread(() => { dialogoprogreso.Dismiss(); }); } } catch (Exception) { RunOnUiThread(() => Toast.MakeText(this, "No se encotraron resultados", ToastLength.Long).Show()); dialogoprogreso.Dismiss(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Agregardialog); ProgressBar barra = FindViewById <ProgressBar>(Resource.Id.progressBar1); TextView texto = FindViewById <TextView>(Resource.Id.textView1); imagenview = FindViewById <ImageView>(Resource.Id.imageView1); LinearLayout descargar = FindViewById <LinearLayout>(Resource.Id.imageView5); LinearLayout addlista = FindViewById <LinearLayout>(Resource.Id.imageView6); LinearLayout agregar = FindViewById <LinearLayout>(Resource.Id.imageView2); buscar = FindViewById <LinearLayout>(Resource.Id.imageView3); ImageView volver = FindViewById <ImageView>(Resource.Id.imageView4); fondo = FindViewById <ImageView>(Resource.Id.fondo1); LinearLayout lineall2 = FindViewById <LinearLayout>(Resource.Id.linearLayout4); LinearLayout lineaa = FindViewById <LinearLayout>(Resource.Id.linearlayout0); buscar.Visibility = ViewStates.Visible; // animar2(lineaa); texto.Selected = true; string titulo = ""; texto.Text = ""; this.SetFinishOnTouchOutside(true); //receiver from intent var intentoo = Intent; var share = intentoo.Action; var tipo = intentoo.Type; if (Intent.ActionSend.Equals(share)) { if (tipo.Contains("text/plain")) { string krecibio = intentoo.GetStringExtra(Intent.ExtraText); if (krecibio.Contains("youtu.be") || krecibio.Contains("youtube.com")) { url = "https://www.youtube.com/watch?v=" + krecibio.Split('/')[3]; new Thread(() => { buscando = true; proc = new Thread(new ThreadStart(ponerimagen)); proc.Start(); titulo = VideosHelper.GetVideoTitle(url); buscando = false; RunOnUiThread(() => { texto.Text = titulo; barra.Visibility = ViewStates.Gone; }); }).Start(); } else { RunOnUiThread(() => barra.Visibility = ViewStates.Gone); Toast.MakeText(this, "Este enlace no proviene de youtube", ToastLength.Long).Show(); this.Finish(); } } else { RunOnUiThread(() => barra.Visibility = ViewStates.Gone); Toast.MakeText(this, "Este enlace no proviene de youtube", ToastLength.Long).Show(); this.Finish(); } } else { RunOnUiThread(() => barra.Visibility = ViewStates.Gone); titulo = Intent.GetStringExtra("titulo"); texto.Text = titulo; url = Intent.GetStringExtra("url"); url = "https://www.youtube.com/watch?v=" + url.Split('=')[1]; imagem = Intent.GetStringExtra("imagen"); proc = new Thread(new ThreadStart(ponerimagen)); proc.Start(); } // animar2(lineall2); addlista.Click += delegate { animar(addlista); if (!buscando) { Intent intentar = new Intent(this, typeof(actividadagregarlistahecha)); intentar.PutExtra("nombrevid", titulo); intentar.PutExtra("linkvid", url); StartActivity(intentar); this.Finish(); } else { Toast.MakeText(this, "Aun se esta buscando la info del video", ToastLength.Long).Show(); } }; volver.Click += delegate { animar(volver); this.Finish(); }; descargar.Click += delegate { animar(descargar); if (!buscando) { Intent intento = new Intent(this, typeof(actdownloadcenterofflinedialog)); intento.PutExtra("ip", "localhost"); intento.PutExtra("zelda", url); intento.PutExtra("color", "Black"); StartActivity(intento); this.Finish(); } else { Toast.MakeText(this, "Aun se esta buscando la info del video", ToastLength.Long).Show(); } }; agregar.Click += delegate { animar(agregar); if (!buscando) { if (Mainmenu.gettearinstancia() != null || YoutubePlayerServerActivity.gettearinstancia() != null) { if (YoutubePlayerServerActivity.gettearinstancia() == null) { Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes("agregar()")); Thread.Sleep(250); Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes(url)); } else { new Thread(() => { YoutubePlayerServerActivity.gettearinstancia().agregarviddireckt(url, titulo); }).Start(); } this.Finish(); } else { Toast.MakeText(this, "No esta conectado a ningun servidor ni tiene la aplicacion abierta en modo de reproductor online", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Aun se esta buscando la info del video", ToastLength.Long).Show(); } }; buscar.Click += delegate { animar(buscar); if (!buscando) { if (Mainmenu.gettearinstancia() != null || YoutubePlayerServerActivity.gettearinstancia() != null) { if (YoutubePlayerServerActivity.gettearinstancia() == null) { if (Mainmenu.gettearinstancia().clientela.Connected == true) { Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes(url)); } } else { new Thread(() => { YoutubePlayerServerActivity.gettearinstancia().buscarviddireckt(url, false); }).Start(); } this.Finish(); } else { Toast.MakeText(this, "No esta conectado a ningun servidor ni tiene la aplicacion abierta en modo de reproductor online", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Aun se esta buscando la info del video", ToastLength.Long).Show(); } }; // Create your application here }
private void TabParserLoad(string tabName, string parserType) { parserTabDataGridView.ColumnCount = 1; parserTabDataGridView.Rows.Clear(); parserTabDataGridView.Refresh(); parserTabDataGridView.ColumnHeadersVisible = false; parserTabDataGridView.Parent = tabControlParsers.TabPages[tabName]; var parserName = tabName.Replace("ParserTab", string.Empty); var filteredParser = parsers.Where(p => p.type == parserType && p.name == parserName).ToList(); var filter = $"key_id = {keyId} and parser_id in ({string.Join(", ", filteredParser.Select(x => x.id))})"; IEnumerable <object> data = null; switch (parserType) { case Parsers.type_texts: data = new TextsHelper().Select(dbName, filter).Select(x => new string[] { x.text, x.spin, x.url }); if (data != null && data.Any()) { parserTabDataGridView.ColumnHeadersVisible = true; parserTabDataGridView.ColumnCount = 3; parserTabDataGridView.Columns[0].Name = "text"; parserTabDataGridView.Columns[1].Name = "spin"; parserTabDataGridView.Columns[2].Name = "url"; foreach (string[] item in data) { parserTabDataGridView.Rows.Add(item); } } break; case Parsers.type_images: DataGridViewRow row1 = new DataGridViewRow(); data = new ImagesHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; case Parsers.type_videos: data = new VideosHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; case Parsers.type_snippets: data = new SnippetsHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; case Parsers.type_suggests: data = new SuggestsHelper().Select(dbName, filter).Select(x => x.text).ToArray(); break; } if (parserTabDataGridView.RowCount == 0 && data != null) { foreach (var item in data) { parserTabDataGridView.Rows.Add(item); } } }