protected override void OnDestroy()
        {
            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                if (YoutubePlayerServerActivity.gettearinstancia().spSlidingPanel.IsExpanded)
                {
                    var inst = YoutubePlayerServerActivity.gettearinstancia();
                    if (inst.volumenactual == 0)
                    {
                        inst.imgSlideDownAction.SetBackgroundResource(Resource.Drawable.volumelow);
                    }
                    else
                    if (inst.volumenactual == 50)
                    {
                        inst.imgSlideDownAction.SetBackgroundResource(Resource.Drawable.volumemedium);
                    }
                    else
                    if (inst.volumenactual == 100)
                    {
                        inst.imgSlideDownAction.SetBackgroundResource(Resource.Drawable.volumehigh);
                    }
                }
            }

            Thread.Sleep(200);

            base.OnDestroy();
        }
 public override void OnCreate()
 {
     if (YoutubePlayerServerActivity.gettearinstancia() != null)
     {
         YoutubePlayerServerActivity.gettearinstancia().videoSurfaceHolder.AddCallback(YoutubePlayerServerActivity.gettearinstancia());
     }
     audioManager = (AudioManager)GetSystemService(AudioService);
     instance     = this;
     base.OnCreate();
 }
        protected override void OnHandleIntent(Android.Content.Intent intent)
        {
            string cogida1 = intent.GetStringExtra("querry1");
            string cogida2 = intent.GetStringExtra("querry2");
            string cogida3 = intent.GetStringExtra("querry3");
            string cogida4 = intent.GetStringExtra("querry4");
            string cogida5 = intent.GetStringExtra("querry5");

            if (cogida1 == "si" && !YoutubePlayerServerActivity.gettearinstancia().envideo)
            {
                YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => {
                    YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick();
                });
                // clasesettings.guardarsetting("cquerry", "playpause()");
            }
            else
            if (cogida2 == "si" && !YoutubePlayerServerActivity.gettearinstancia().envideo)
            {
                YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => {
                    YoutubePlayerServerActivity.gettearinstancia().imgNext.CallOnClick();
                });
                //  clasesettings.guardarsetting("cquerry", "siguiente()");
            }
            else
            if (cogida3 == "si" && !YoutubePlayerServerActivity.gettearinstancia().envideo)
            {
                YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => {
                    YoutubePlayerServerActivity.gettearinstancia().imgBack.CallOnClick();
                });
                //  clasesettings.guardarsetting("cquerry", "anterior()");
            }
            else
            if (cogida4 == "si" && !YoutubePlayerServerActivity.gettearinstancia().envideo)
            {
                YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => {
                    YoutubePlayerServerActivity.gettearinstancia().imgForeward.CallOnClick();
                });
                /// clasesettings.guardarsetting("cquerry", "adelantar()");
            }
            else
            if (cogida5 == "si" && !YoutubePlayerServerActivity.gettearinstancia().envideo)
            {
                YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => {
                    YoutubePlayerServerActivity.gettearinstancia().imgBackward.CallOnClick();
                });
                ///  clasesettings.guardarsetting("cquerry", "atrazar()");
            }



            this.StopSelf();
        }
        public void seteartexto()
        {
            while (detenedor)
            {
                if (Mainmenu.gettearinstancia() != null || YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    if (isserver)
                    {
                        RunOnUiThread(() =>
                        {
                            textolista.Text  = YoutubePlayerServerActivity.gettearinstancia().lapara.Count + " Elementos en cola";
                            textoserver.Text = YoutubePlayerServerActivity.gettearinstancia().clienteses.Count + " Clientes conectados";
                            if (YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text.Trim() != "")
                            {
                                if (textonombreelemento.Text != YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text)
                                {
                                    textonombreelemento.Text = YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text;
                                }
                            }
                            else
                            {
                                textonombreelemento.Text = "Ningún elemento el reproducción";
                            }
                        });
                    }
                    else

                    {
                        RunOnUiThread(() =>
                        {
                            textolista.Text  = Mainmenu.gettearinstancia().lista.Count + " Elementos en cola";
                            textoserver.Text = "Conectado a " + Mainmenu.gettearinstancia().devicename;
                            if (Mainmenu.gettearinstancia().label.Text.Trim() != "")
                            {
                                if (textonombreelemento.Text != Mainmenu.gettearinstancia().label.Text)
                                {
                                    textonombreelemento.Text = Mainmenu.gettearinstancia().label.Text;
                                }
                            }
                            else
                            {
                                textonombreelemento.Text = "Ningún elemento el reproducción";
                            }
                        });
                    }
                }
                System.Threading.Thread.Sleep(3000);
            }
        }
        public void crearlista(string playlistname)
        {
            StreamWriter escritor;

            escritor = File.CreateText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + RemoveIllegalPathCharacters(playlistname));
            escritor.Write("  $  ");
            escritor.Close();
            llenarlista();
            Toast.MakeText(this, "Lista guardada satisfactoriamente", ToastLength.Long).Show();
            MultiHelper.ExecuteGarbageCollection();
            new Thread(() =>
            {
                YoutubePlayerServerActivity.gettearinstancia().llenarplaylist();
            }).Start();
        }
        public void six(object sender, EventArgs e)
        {
            listanombres = YoutubePlayerServerActivity.gettearinstancia().lapara;
            listalinks   = YoutubePlayerServerActivity.gettearinstancia().laparalinks;



            // botoneliminar.SetBackgroundResource(Resource.Drawable.playlistedit);
            if (listanombres.Count > 0)
            {
                adapterlistaremotoconeliminar adalter22 = new adapterlistaremotoconeliminar(this, listanombres, listalinks, textbox.Text, false, true);
                var parcelable = listbox.OnSaveInstanceState();
                listbox.Adapter = adalter22;
                listbox.OnRestoreInstanceState(parcelable);
            }
        }
        public void cojerstream()
        {
            while (!this.IsDestroyed)
            {
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    if (YoutubePlayerServerActivity.gettearinstancia().buscando != true)
                    {
                        if (YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text != tv4.Text &&
                            YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text.Trim() != "")
                        {
                            RunOnUiThread(() => tv4.Text = YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text);
                        }
                    }
                    else
                    {
                        RunOnUiThread(() => tv4.Text = "Buscando...");
                    }
                }
                else
                if (Mainmenu.gettearinstancia() != null)
                {
                    if (Mainmenu.gettearinstancia().buscando == false)
                    {
                        if (Mainmenu.gettearinstancia().label.Text != tv4.Text &&
                            Mainmenu.gettearinstancia().label.Text.Trim() != ""
                            )
                        {
                            RunOnUiThread(() => tv4.Text = Mainmenu.gettearinstancia().label.Text);
                        }
                    }
                    else
                    {
                        RunOnUiThread(() => tv4.Text = "Buscando...");
                    }
                }
                else
                {
                }

                if (tv4.Text.Trim() == "" && tv4.Text.Trim() != "No hay elementos en cola")
                {
                    RunOnUiThread(() => { tv4.Text = "No hay elementos en cola"; });
                }
                Thread.Sleep(1000);
            }
        }
        public static void ShowAskIfMenuOrExit(Context ctx)
        {
            var context = (Activity)ctx;

            AlertDialog.Builder ad = new AlertDialog.Builder(ctx);
            ad.SetCancelable(false);
            ad.SetTitle("Advertencia");
            ad.SetIcon(Resource.Drawable.alert);
            ad.SetMessage("Que desea hacer");
            ad.SetNegativeButton("Ir a la pantalla de selección de modos", (obj, evt) =>
            {
                context.StartActivity(new Intent(context, typeof(actsplashscreen)));
                MultiHelper.ExecuteGarbageCollection();
                context.Finish();
                if (Mainmenu.gettearinstancia() != null)
                {
                    Mainmenu.gettearinstancia().Finish();
                }
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    YoutubePlayerServerActivity.gettearinstancia().Finish();
                }
                if (actividadinicio.gettearinstancia() != null)
                {
                    actividadinicio.gettearinstancia().Finish();
                }
            });
            ad.SetNeutralButton("Salir de la aplicacion", (obj, evt) =>
            {
                context.Finish();
                if (Mainmenu.gettearinstancia() != null)
                {
                    Mainmenu.gettearinstancia().Finish();
                }
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    YoutubePlayerServerActivity.gettearinstancia().Finish();
                }
                if (actividadinicio.gettearinstancia() != null)
                {
                    actividadinicio.gettearinstancia().Finish();
                }
            });
            ad.SetPositiveButton("Cancelar", (obj, evt) => { });
            ad.Create();
            ad.Show();
        }
        public void alertaok(object sender, EventArgs e)
        {
            string archivoentexto = File.ReadAllText(elementoscompletos[posicion]);

            if (!encontroparecido(linkvideo, archivoentexto.Split('$')[1].Split(';').ToList()))
            {
                string nombreentero = archivoentexto.Split('$')[0] + nombrevideo;
                string linkentero   = archivoentexto.Split('$')[1] + linkvideo;

                File.Delete(elementoscompletos[posicion]);
                var sd = File.CreateText(elementoscompletos[posicion]);
                sd.Write(nombreentero + ";$" + linkentero + ";");
                sd.Close();
                Toast.MakeText(this, "Elemento agregado exitosamente", ToastLength.Long).Show();

                if (menulistaoffline.gettearinstancia() != null)
                {
                    menulistaoffline.gettearinstancia().llenarlista();
                }
                MultiHelper.ExecuteGarbageCollection();
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    new Thread(() =>
                    {
                        YoutubePlayerServerActivity.gettearinstancia().llenarplaylist();
                    }).Start();
                }
                this.Finish();
            }
            else
            {
                Toast.MakeText(this, "El elemento ya existe en la lista", ToastLength.Long).Show();
                if (menulistaoffline.gettearinstancia() != null)
                {
                    menulistaoffline.gettearinstancia().llenarlista();
                }
                MultiHelper.ExecuteGarbageCollection();

                this.Finish();
            }
        }
示例#10
0
        public static void SetBackgroundAndRefresh(Activity context)
        {
            bool isOnline = false;

            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                isOnline = false;
            }
            else
            if (Mainmenu.gettearinstancia() != null)
            {
                isOnline = true;
            }
            var thread = new Thread(() =>
            {
                KeepRefreshingBackground(isOnline ? "online" : "", context);
            });

            thread.IsBackground = true;
            thread.Start();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);


            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                SetContentView(Resource.Layout.layoutinicio);
            }
            else
            {
                SetContentView(Resource.Layout.layoutinicioremote);
            }
            ins = this;
            ImageView botonreconocer = FindViewById <ImageView>(Resource.Id.imageView2);

            texto            = FindViewById <EditText>(Resource.Id.editText1);
            listamas         = FindViewById <RecyclerView>(Resource.Id.listamas);
            listaultimos     = FindViewById <RecyclerView>(Resource.Id.listaultimos);
            listafavoritos   = FindViewById <RecyclerView>(Resource.Id.listafavoritos);
            listasugerencias = FindViewById <RecyclerView>(Resource.Id.listasugerencias);
            List <PlaylistElement> listafake = new List <PlaylistElement>();
            var imagentipoconex = FindViewById <ImageView>(Resource.Id.tipoconexion);

            textoserver         = FindViewById <TextView>(Resource.Id.textoconexion);
            textonombreelemento = FindViewById <TextView>(Resource.Id.textoreprodactual);
            textolista          = FindViewById <TextView>(Resource.Id.textoencola);
            SetSupportActionBar(FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.my_toolbar));
            secciones = new List <LinearLayout>()
            {
                FindViewById <LinearLayout>(Resource.Id.secion1),
                FindViewById <LinearLayout>(Resource.Id.secion2),
                FindViewById <LinearLayout>(Resource.Id.secion3),
                FindViewById <LinearLayout>(Resource.Id.secion4)
            };

            foreach (var ax in secciones)
            {
                ax.Visibility = ViewStates.Gone;
            }


            SupportActionBar.Title = "Inicio";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            itemsm = FindViewById <NavigationView>(Resource.Id.content_frame);
            sidem  = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.hambur);
            textolista.Selected          = true;
            textoserver.Selected         = true;
            textonombreelemento.Selected = true;
            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                isserver      = true;
                Diccfavoritos = YoutubePlayerServerActivity.gettearinstancia().listafavoritos;
                favoritos     = Diccfavoritos.Values.ToList();

                objetohistorial = YoutubePlayerServerActivity.gettearinstancia().objetohistorial;
                imagentipoconex.SetBackgroundResource(Resource.Drawable.remotecontrolbuttons);
            }
            else
            {
                isserver      = false;
                Diccfavoritos = Mainmenu.gettearinstancia().listafavoritos;
                favoritos     = Diccfavoritos.Values.ToList();
                imagentipoconex.SetBackgroundResource(Resource.Drawable.antena);
                objetohistorial = Mainmenu.gettearinstancia().objetohistorial;
            }

            if (objetohistorial == null)
            {
                objetohistorial = new History()
                {
                    Videos = new List <PlaylistElement>(),
                    Links  = new Dictionary <string, int>()
                }
            }
            ;

            if (favoritos == null)
            {
                favoritos = new List <PlaylistElement>();
            }

            if (Diccfavoritos == null)
            {
                Diccfavoritos = new Dictionary <string, PlaylistElement>();
            }



            favoritos.Reverse();
            recargarhistorial();

            new System.Threading.Thread(() =>
            {
                seteartexto();
            }).Start();



            /*    for (int i = 0; i < 20; i++)
             *  {
             *
             *      listafake.Add(new playlistelements
             *      {
             *          nombre = "klk wawawa",
             *          link = "https://www.youtube.com/watch?v=4G40N0G6lzE"
             *      });
             *  }
             */



            LinearLayoutManager enlinea = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);

            listamas.SetLayoutManager(enlinea);
            LinearLayoutManager enlinea2 = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);

            listaultimos.SetLayoutManager(enlinea2);
            LinearLayoutManager enlinea3 = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);

            listafavoritos.SetLayoutManager(enlinea3);
            LinearLayoutManager enlinea4 = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);

            listasugerencias.SetLayoutManager(enlinea4);

            adaptadorcartas adap = new adaptadorcartas(listafake, this);

            //   listafavoritos.SetAdapter(adap);
            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                if (System.IO.File.Exists(Constants.CachePath + "/backupplaylist.json") && !YoutubePlayerServerActivity.gettearinstancia().backupprompted)
                {
                    var snack = Snackbar.Make(FindViewById <View>(Android.Resource.Id.Content), "Desea cargar los elementos que estaba reproduciendo la vez anterior?", Snackbar.LengthIndefinite);
                    snack.SetAction("Cargar", (o) =>
                    {
                        YoutubePlayerServerActivity.gettearinstancia().loadbackupplaylist();
                        YoutubePlayerServerActivity.gettearinstancia().backupprompted = true;
                    });
                    snack.SetDuration(6000);
                    snack.Show();
                    Task.Delay(6000).ContinueWith(delegate
                    {
                        YoutubePlayerServerActivity.gettearinstancia().backupprompted = true;
                    });


                    /* new Android.Support.V7.App.AlertDialog.Builder(this)
                     * .SetTitle("Advertencia")
                     * .SetMessage("Desea cargar los elementos que estaba reproduciendo la vez anterior?")
                     * .SetPositiveButton("Si", (aa, aaa) =>
                     * {
                     * mainmenu_Offline.gettearinstancia().loadbackupplaylist();
                     * mainmenu_Offline.gettearinstancia().backupprompted = true;
                     *
                     * })
                     * .SetNegativeButton("No", (afaa, aaffa) =>
                     * {
                     *
                     * mainmenu_Offline.gettearinstancia().backupprompted = true;
                     *
                     * })
                     * .SetCancelable(false)
                     * .Create()
                     * .Show();*/
                }
                else
                {
                    YoutubePlayerServerActivity.gettearinstancia().backupprompted = true;
                }
            }

            FindViewById <CardView>(Resource.Id.cartainicio).Click += delegate
            {
                this.Finish();
            };



            texto.KeyPress += (aaxx, e) =>
            {
                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    // Code executed when the enter key is pressed down

                    new System.Threading.Thread(() =>
                    {
                        buscaryabrir(texto.Text);
                    }).Start();
                }
                else
                {
                    e.Handled = false;
                }
            };



            botonreconocer.Click += delegate
            {
                animar(botonreconocer);
                try
                {
                    var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 500);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 500);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 10000);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                    StartActivityForResult(voiceIntent, 7);
                }
                catch (Exception)
                {
                }
            };
            itemsm.NavigationItemSelected += (sender, e) =>
            {
                switch (e.MenuItem.TitleFormatted.ToString())
                {
                case "Reproductor":
                    this.Finish();
                    break;

                case "Control remoto":
                    this.Finish();
                    break;

                case "Navegador personalizado":
                    Intent intento = new Intent(this, typeof(customsearcheract));
                    intento.PutExtra("ipadre", "localhost");
                    intento.PutExtra("color", "black");
                    StartActivity(intento);
                    break;

                case "Conectar clientes":


                    Intent intetno = new Intent(this, typeof(qrcodigoact));
                    intetno.PutExtra("ipadre", "localhost");
                    StartActivity(intetno);


                    break;

                case "Listas de reproduccion":

                    if (YoutubePlayerServerActivity.gettearinstancia() != null)
                    {
                        Intent elint = new Intent(this, typeof(menulistaoffline));
                        elint.PutExtra("ipadre", "localhost");
                        StartActivity(elint);
                    }
                    else
                    {
                        var con = Mainmenu.gettearinstancia();
                        if (con.compatible)
                        {
                            if (con.jsonlistasremotas.Trim() != "")
                            {
                                Intent intentoo = new Intent(this, typeof(Reproducirlistaact));
                                intentoo.PutExtra("ip", "localhost");
                                StartActivity(intentoo);
                            }
                            else
                            {
                                Toast.MakeText(this, "Aun no se han recibido las listas de el servidor...", ToastLength.Long).Show();
                            }
                        }
                        else
                        {
                            Toast.MakeText(this, "Su servidor no es compatible con esta version", ToastLength.Long).Show();
                        }
                    }

                    break;
                }
                e.MenuItem.SetChecked(false);
                e.MenuItem.SetChecked(false);
                sidem.CloseDrawers();
            };
        }
        public void reproducir(string downloadurl)
        {
            // musicaplayer.SetDataSource(downloadurl);

            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                musicaplayer.Release();


                musicaplayer = new MediaPlayer();

                if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.N)
                {
                    musicaplayer.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Music).Build());
                }
                else
                {
#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
                }
                musicaplayer.SetWakeMode(this, WakeLockFlags.Partial);

#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                var focusResult = audioManager.RequestAudioFocus(this, Stream.Music, AudioFocus.Gain);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                //    musicaplayer.SetVideoScalingMode(VideoScalingMode.ScaleToFitWithCropping);

                if (focusResult != AudioFocusRequest.Granted)
                {
                    //could not get audio focus
                    Console.WriteLine("Could not get audio focus");
                }


                musicaplayer.Error += (aa, aaaa) =>
                {
                    Console.WriteLine("klk aw aw aw");
                };

                musicaplayer.Info += (aa, aaa) =>
                {
                    var instancia = YoutubePlayerServerActivity.gettearinstancia();
                    if (instancia != null)
                    {
                        switch (aaa.What)
                        {
                        case MediaInfo.BufferingStart:
                            if (instancia.prgBuffering.Visibility != ViewStates.Visible)
                            {
                                instancia.prgBuffering.Visibility = ViewStates.Visible;
                            }
                            break;

                        case MediaInfo.BufferingEnd:
                            if (instancia.prgBuffering.Visibility != ViewStates.Gone)
                            {
                                instancia.prgBuffering.Visibility = ViewStates.Gone;
                            }
                            break;

                        case MediaInfo.VideoRenderingStart:
                            if (instancia.prgBuffering.Visibility != ViewStates.Gone)
                            {
                                instancia.prgBuffering.Visibility = ViewStates.Gone;
                            }
                            break;
                        }
                        ;
                    }
                };



                musicaplayer.Prepared += delegate
                {
                    if (YoutubePlayerServerActivity.gettearinstancia().videoon)
                    {
                        YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                        {
                            try
                            {
                                musicaplayer.SetDisplay(null);
                                musicaplayer.SetDisplay(YoutubePlayerServerActivity.gettearinstancia().videoSurfaceHolder);
                            }
                            catch (Exception) {
                            }


                            YoutubePlayerServerActivity.gettearinstancia().SetVideoSize();
                        });
                    }
                    musicaplayer.Start();
                    if (YoutubePlayerServerActivity.gettearinstancia().qualitychanged)
                    {
                        try
                        {
                            YoutubePlayerServerActivity.gettearinstancia().qualitychanged = false;
                            musicaplayer.SeekTo(YoutubePlayerServerActivity.gettearinstancia().previousprogress);
                        }
                        catch (Exception) { }
                    }
                };
                musicaplayer.Completion += delegate
                {
                    if ((musicaplayer.Duration > 5 && musicaplayer.CurrentPosition > 5))
                    {
                        new Thread(() =>
                        {
                            YoutubePlayerServerActivity.gettearinstancia().NextVideo();
                        }).Start();
                    }
                };


                mostrarnotificacion();
                musicaplayer.SetDataSource(this, Android.Net.Uri.Parse(downloadurl));
                musicaplayer.PrepareAsync();
            }
            else
            {
                musicaplayer.Reset();
                StopSelf();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Menulistaoffline);
            string ipadress = Intent.GetStringExtra("ipadre");

            listareprod   = new List <string>();
            listareprod2  = new List <string>();
            textboxtitulo = FindViewById <TextView>(Resource.Id.textView1);
            ImageView playpause    = FindViewById <ImageView>(Resource.Id.imageView5);
            var       botonelimiar = FindViewById <Android.Support.Design.Widget.FloatingActionButton>(Resource.Id.imageView7);
            var       botonagregar = FindViewById <Android.Support.Design.Widget.FloatingActionButton>(Resource.Id.imageView6);
            ImageView botonhome    = FindViewById <ImageView>(Resource.Id.imageView4);

            listbox = FindViewById <ListView>(Resource.Id.listView1);
            ImageView botonreproducir = FindViewById <ImageView>(Resource.Id.imageView3);

            lineall2     = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            listaenlinea = Intent.GetStringExtra("listaenlinea");
            lineaa       = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            instance     = this;

            botonagregar.Enabled = true;
            //  animar2(lineall2);
            var adaptadolo = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string> {
                "No hay elementos para mostrar.."
            });

            RunOnUiThread(() => {
                var parcelable  = listbox.OnSaveInstanceState();
                listbox.Adapter = adaptadolo;
                listbox.OnRestoreInstanceState(parcelable);
            });
            llenarlista();
            AnimationHelper.AnimateFAB(botonagregar);
            // lineaa.SetBackgroundColor(Android.Graphics.Color.DarkGray);
            tree = new Thread(new ThreadStart(cojerstream));
            tree.Start();
            textboxtitulo.Selected = true;
            // botonelimiar.SetBackgroundResource(Resource.Drawable.playlistedit);
            UiHelper.SetBackgroundAndRefresh(this);
            //  lineall2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#2b2e30"));

            listbox.ItemClick += (aaa, aaaa) =>
            {
                if (listareprod.Count > 0)
                {
                    if (File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + listareprod[aaaa.Position]).Split('$')[0].Split(';').ToList().Count >= 1 && File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + listareprod[aaaa.Position]).Split('$')[0].Split(';')[0].Trim() != "")
                    {
                        Intent internado = new Intent(this, typeof(Reproducirlistadialog));
                        internado.PutExtra("ip", Intent.GetStringExtra("ipadre"));
                        internado.PutExtra("nombrelista", listareprod[aaaa.Position]);
                        internado.PutExtra("index", aaaa.Position.ToString());
                        StartActivity(internado);
                    }
                    else
                    {
                        Toast.MakeText(this, "La lista esta vacia", ToastLength.Long).Show();
                    }
                }
            };
            botonelimiar.Click += delegate
            {
                animar(botonelimiar);
                if (eneliminacion)
                {
                    eneliminacion = false;
                    //  botonelimiar.SetBackgroundResource(Resource.Drawable.playlistedit);
                    ArrayAdapter adaptador  = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, listareprod);
                    var          parcelable = listbox.OnSaveInstanceState();

                    listbox.Adapter = adaptador;
                    listbox.OnRestoreInstanceState(parcelable);
                }

                else
                {
                    //   botonelimiar.SetBackgroundResource(Resource.Drawable.playlistcheck);
                    adapterlistaremotoconeliminar adaptador = new adapterlistaremotoconeliminar(this, listareprod, listareprod2, "noser", true, false);
                    var parcelable = listbox.OnSaveInstanceState();
                    listbox.Adapter = adaptador;
                    listbox.OnRestoreInstanceState(parcelable);
                    eneliminacion = true;
                }
            };
            botonagregar.Click += delegate
            {
                /*  Intent intento = new Intent(this,typeof(agregarlistaoffline));
                 * intento.PutExtra("ipadre", ipadress);
                 * StartActivity(intento);
                 */
                EditText texto = new EditText(this);
                texto.Hint = "Nombre de la lista";

                new AlertDialog.Builder(this)
                .SetTitle("Introduzca el nombre de la nueva lista de reproduccion")
                .SetView(texto)
                .SetCancelable(false)
                .SetNegativeButton("Cancelar", (ax, ax100) => { })
                .SetPositiveButton("Crear", (xd, xdd) => {
                    if (texto.Text.Length < 3)
                    {
                        Toast.MakeText(this, "El nombre debe tener almenos 3 caracteres", ToastLength.Long).Show();
                    }
                    else
                    {
                        var saas = Directory.GetFiles(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist");
                        if (!saas.Contains(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + RemoveIllegalPathCharacters(texto.Text)))
                        {
                            crearlista(texto.Text);
                        }
                        else
                        {
                            AlertDialog.Builder ad = new AlertDialog.Builder(this);
                            ad.SetTitle("Advertencia");
                            ad.SetMessage("El elemento " + texto.Text + " ya existe desea reemplazarlo??");
                            ad.SetCancelable(false);
                            ad.SetIcon(Resource.Drawable.warningsignonatriangularbackground);
                            ad.SetPositiveButton("Si", (axx, axxx) => {
                                crearlista(texto.Text);
                            });
                            ad.SetNegativeButton("No", (ux, uxdd) => {
                                Toast.MakeText(this, "Operacion cancelada", ToastLength.Long).Show();
                            });
                            ad.Create();
                            ad.Show();
                        }
                    }
                })
                .Create().Show();
            };

            playpause.Click += delegate
            {
                animar(playpause);
                YoutubePlayerServerActivity.gettearinstancia().imgPlay.PerformClick();
            };
            botonhome.Click += delegate
            {
                animar(botonhome);

                tree.Abort();
                this.Finish();
            };



            // Create your application here
        }
        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
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.agregaralistahecha);
            listbox = FindViewById <ListView>(Resource.Id.listView1);
            ImageView    cerrar = FindViewById <ImageView>(Resource.Id.imageView1);
            LinearLayout linea  = FindViewById <LinearLayout>(Resource.Id.root);
            LinearLayout linea1 = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            Button       nueva  = FindViewById <Button>(Resource.Id.imageView3);

            //  linea.SetBackgroundColor(Android.Graphics.Color.DarkGray);
            //   linea1.SetBackgroundColor(Android.Graphics.Color.Black);
            nombrevideo = Intent.GetStringExtra("nombrevid");
            nombrevideo = RemoveIllegalPathCharacters(nombrevideo);
            nombrevideo = nombrevideo.Replace('$', ' ').Replace(';', ' ');
            linkvideo   = Intent.GetStringExtra("linkvid");
            linkvideo   = RemoveIllegalPathCharacters(linkvideo);
            linkvideo   = linkvideo.Replace('$', ' ').Replace(';', ' ');
            fondo       = FindViewById <ImageView>(Resource.Id.fondo1);
            this.SetFinishOnTouchOutside(true);

            /*    var adaptadolo = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, new List<string> { "No hay elementos para mostrar.." });
             *  RunOnUiThread(() => listbox.Adapter = adaptadolo);*/
            llenarlista();

            new Thread(() =>
            {
                try
                {
                    var imagen = ImageHelper.GetImageBitmapFromUrl("http://i.ytimg.com/vi/" + linkvideo.Split('=')[1] + "/mqdefault.jpg");
                    RunOnUiThread(() =>
                    {
                        fondo.SetImageBitmap(imagen);
                        animar4(fondo);
                    });
                }
                catch (Exception)
                {
                }
            }).Start();
            listbox.ItemClick += (aasd, adsf) =>
            {
                if (elementos.Count > 0)
                {
                    posicion = adsf.Position;
                    AlertDialog.Builder ad = new AlertDialog.Builder(this);
                    ad.SetCancelable(false);
                    ad.SetMessage("Esta seguro que desea agregar " + nombrevideo + " A la lista de reproduccion " + elementos[adsf.Position] + "??");
                    ad.SetTitle("Advertencia");
                    ad.SetIcon(Resource.Drawable.warningsignonatriangularbackground);
                    ad.SetPositiveButton("Si", alertaok);
                    ad.SetNegativeButton("No", alertano);
                    ad.Create();
                    ad.Show();
                }
            };

            //    linea1.SetBackgroundColor(Android.Graphics.Color.ParseColor(clasesettings.gettearvalor("color")));
            nueva.Click += delegate
            {
                EditText texto = new EditText(this);
                texto.Hint = "Nombre de la lista";

                new AlertDialog.Builder(this)
                .SetTitle("Introduzca el nombre de la nueva lista de reproduccion")
                .SetView(texto)
                .SetCancelable(false)
                .SetNegativeButton("Cancelar", (ax, ax100) => { })
                .SetPositiveButton("Crear", (xd, xdd) => {
                    if (texto.Text.Length < 3)
                    {
                        Toast.MakeText(this, "El nombre debe tener almenos 3 caracteres", ToastLength.Long).Show();
                    }
                    else
                    {
                        var saas = Directory.GetFiles(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist");
                        if (!saas.Contains(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + RemoveIllegalPathCharacters(texto.Text)))
                        {
                            crearlista(texto.Text);
                            llenarlista();
                            if (menulistaoffline.gettearinstancia() != null)
                            {
                                menulistaoffline.gettearinstancia().llenarlista();
                            }
                        }
                        else
                        {
                            AlertDialog.Builder ad = new AlertDialog.Builder(this);
                            ad.SetTitle("Advertencia");
                            ad.SetMessage("El elemento " + texto.Text + " ya existe desea reemplazarlo??");
                            ad.SetCancelable(false);
                            ad.SetIcon(Resource.Drawable.warningsignonatriangularbackground);
                            ad.SetPositiveButton("Si", (axx, axxx) => {
                                crearlista(texto.Text);
                                llenarlista();
                                if (menulistaoffline.gettearinstancia() != null)
                                {
                                    menulistaoffline.gettearinstancia().llenarlista();
                                }

                                new Thread(() =>
                                {
                                    YoutubePlayerServerActivity.gettearinstancia().llenarplaylist();
                                }).Start();
                            });
                            ad.SetNegativeButton("No", (ux, uxdd) => {
                                Toast.MakeText(this, "Operacion cancelada", ToastLength.Long).Show();
                            });
                            ad.Create();
                            ad.Show();
                        }
                    }
                })
                .Create().Show();
            };
            cerrar.Click += delegate
            {
                this.Finish();
            };
            // Create your application here
        }
示例#16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.loadplaylistoffline);
            string ipadre = Intent.GetStringExtra("ip");


            llayout         = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            llayout2        = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            botonatras      = FindViewById <ImageView>(Resource.Id.imageView1);
            botonreproducir = FindViewById <Button>(Resource.Id.imageView3);
            listbox         = FindViewById <ListView>(Resource.Id.listView1);
            botonborrar     = FindViewById <ImageView>(Resource.Id.imageView2);
            fondo           = FindViewById <ImageView>(Resource.Id.fondo1);
            animar2(llayout2);
            nombrelista = Intent.GetStringExtra("nombrelista");


            //  llayout.SetBackgroundColor(Android.Graphics.Color.DarkGray);
            //  llayout2.SetBackgroundColor(Android.Graphics.Color.ParseColor(clasesettings.gettearvalor("color")));
            animar2(llayout2);
            // Create your application here
            this.SetFinishOnTouchOutside(true);
            string listaenlinea = File.ReadAllText(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/gr3playerplaylist/" + nombrelista);

            new Thread(() =>
            {
                adart();
            }
                       ).Start();



            partes = listaenlinea.Split('$')[0].Split(';').ToList();
            links  = listaenlinea.Split('$')[1].Split(';').ToList();
            if (partes[partes.Count - 1].Trim() == "")
            {
                partes.RemoveAt(partes.Count - 1);
                links.RemoveAt(links.Count - 1);
            }
            int indez = 0;

            botonborrar.SetBackgroundResource(Resource.Drawable.playlistedit);
            foreach (string it in partes.ToArray())
            {
                if (it.StartsWith(">"))
                {
                    string        papu = it;
                    StringBuilder ee   = new StringBuilder(papu);
                    ee.Replace('>', ' ');
                    ee.Replace('<', ' ');

                    partes[indez] = ee.ToString();
                }

                indez++;
            }

            var lista = partes.ToList();


            adapterlistaremotoconeliminar adalteeel = new adapterlistaremotoconeliminar(this, partes.ToList(), links.ToList(), nombrelista, false, false);

            var parcelable = listbox.OnSaveInstanceState();

            listbox.Adapter = adalteeel;
            listbox.OnRestoreInstanceState(parcelable);

            new Thread(() =>
            {
                try
                {
                    var imagen = ImageHelper.GetImageBitmapFromUrl("http://i.ytimg.com/vi/" + links[0].Split('=')[1] + "/mqdefault.jpg");
                    RunOnUiThread(() =>
                    {
                        fondo.SetImageBitmap(imagen);
                        animar4(fondo);
                    });
                }
                catch (Exception)
                {
                }
            }).Start();


            //   adart(adalteeel);



            listbox.ItemClick += (aa, aaa) =>
            {
                if (links.Count > 0)
                {
                    Intent intento = new Intent(this, typeof(customdialogact));
                    intento.PutExtra("color", "DarkGray");
                    intento.PutExtra("url", links[aaa.Position]);
                    intento.PutExtra("titulo", partes[aaa.Position]);
                    intento.PutExtra("ipadress", "localhost");
                    intento.PutExtra("imagen", @"https://i.ytimg.com/vi/" + links[aaa.Position].Split('=')[1] + "/hqdefault.jpg");
                    StartActivity(intento);
                }
            };

            botonatras.Click += delegate
            {
                animar(botonatras);
                cerraractividad();
            };
            botonreproducir.Click += delegate
            {
                var indice = int.Parse(Intent.GetStringExtra("index"));
                new Thread(() =>
                {
                    YoutubePlayerServerActivity.gettearinstancia().reproducirlalistalocal(nombrelista);
                }).Start();
                cerraractividad();
            };
            botonborrar.Click += delegate
            {
                animar(botonborrar);


                if (enedicion == false)
                {
                    animar(botonborrar);
                    enedicion = true;
                    botonborrar.SetBackgroundResource(Resource.Drawable.playlistcheck);
                    adapterlistaremotoconeliminar adalteeel33 = new adapterlistaremotoconeliminar(this, partes.ToList(), links.ToList(), nombrelista, false, false);
                    var parcelablex = listbox.OnSaveInstanceState();
                    listbox.Adapter = adalteeel33;
                    listbox.OnRestoreInstanceState(parcelablex);
                }
                else
                {
                    animar(botonborrar);
                    enedicion = false;
                    botonborrar.SetBackgroundResource(Resource.Drawable.playlistedit);
                    adapterlistaremotoconeliminar adalteeel2 = new adapterlistaremotoconeliminar(this, partes.ToList(), links.ToList(), nombrelista, false, false);

                    var parcelablexx = listbox.OnSaveInstanceState();
                    listbox.Adapter = adalteeel2;
                    listbox.OnRestoreInstanceState(parcelablexx);
                }
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.menuvolumen);
            bajo  = FindViewById <ImageView>(Resource.Id.imageView1);
            medio = FindViewById <ImageView>(Resource.Id.imageView2);
            alto  = FindViewById <ImageView>(Resource.Id.imageView3);
            fondo = FindViewById <LinearLayout>(Resource.Id.fondo1);
            fondo.SetBackgroundColor(Color.ParseColor("#2b2e30"));
            string ip = Intent.GetStringExtra("ipadre");

            this.SetFinishOnTouchOutside(true);

            ////////////////////////////////////////clicks//////////////
            bajo.Click += delegate
            {
                animar(bajo);

                if (Mainmenu.gettearinstancia() != null)
                {
                    Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.UTF8.GetBytes("vol0()"));
                }
                else
                if (Clouding_service.gettearinstancia() != null)
                {
                    YoutubePlayerServerActivity.gettearinstancia().volumenactual = 0;
                    Clouding_service.gettearinstancia().musicaplayer.SetVolume(0f, 0f);
                    YoutubePlayerServerActivity.gettearinstancia().imgSlideDownAction.SetBackgroundResource(Resource.Drawable.volumelowrojo);
                }

                this.Finish();
                ;
            };
            medio.Click += delegate
            {
                animar(medio);
                if (Mainmenu.gettearinstancia() != null)
                {
                    Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.UTF8.GetBytes("vol50()"));
                }
                else
                if (Clouding_service.gettearinstancia() != null)
                {
                    YoutubePlayerServerActivity.gettearinstancia().volumenactual = 50;
                    Clouding_service.gettearinstancia().musicaplayer.SetVolume(0.5f, 0.5f);
                    YoutubePlayerServerActivity.gettearinstancia().imgSlideDownAction.SetBackgroundResource(Resource.Drawable.volumemediumrojo);
                }
                this.Finish();
            };
            alto.Click += delegate
            {
                animar(alto);
                if (Mainmenu.gettearinstancia() != null)
                {
                    Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.UTF8.GetBytes("vol100()"));
                }
                else
                if (Clouding_service.gettearinstancia() != null)
                {
                    YoutubePlayerServerActivity.gettearinstancia().volumenactual = 100;
                    Clouding_service.gettearinstancia().musicaplayer.SetVolume(1f, 1f);
                    YoutubePlayerServerActivity.gettearinstancia().imgSlideDownAction.SetBackgroundResource(Resource.Drawable.volumehighrojo);
                }

                this.Finish();
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Qrdialog);

            ipadre = "";
            IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
            foreach (IPAddress ip in localIPs)
            {
                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork && ip.ToString() != "localhost")
                {
                    ipadre = ip.ToString();
                }
            }
            imagenview = new ImageView(this);
            FloatingActionButton btn = FindViewById <FloatingActionButton>(Resource.Id.floatingActionButton1);

            ImageView volver = FindViewById <ImageView>(Resource.Id.imageView4);

            imagenview.SetImageBitmap(GetQRCode());
            LinearLayout ll  = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            LinearLayout ll2 = FindViewById <LinearLayout>(Resource.Id.linearLayout4);

            playpause     = FindViewById <ImageView>(Resource.Id.imageView5);
            textboxtitulo = FindViewById <TextView>(Resource.Id.textView2);
            lista         = FindViewById <ListView>(Resource.Id.listView1);
            // ll.SetBackgroundColor(Android.Graphics.Color.DarkGray);
            //  ll2.SetBackgroundColor(Android.Graphics.Color.Black);
            tr = new Thread(new ThreadStart(cojerstream));
            tr.Start();
            textboxtitulo.Selected = true;
            var adaptadol = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string> {
                "No hay dispositivos conectados.."
            });

            RunOnUiThread(() => {
                var parcelable = lista.OnSaveInstanceState();
                lista.Adapter  = adaptadol;
                lista.OnRestoreInstanceState(parcelable);
            });
            alerta = new AlertDialog.Builder(this).SetView(imagenview)
                     .SetTitle("Vincular nuevo dispositivo").SetMessage("Para conectarse entre al modo control remoto de la app desde el otro dispositivo\n")
                     .SetPositiveButton("Entendido!", (ax, ass) => { alerta.Dismiss(); })
                     .SetCancelable(false)
                     .Create();
            //    animar2(ll2);

            AnimationHelper.AnimateFAB(btn);
            UiHelper.SetBackgroundAndRefresh(this);
            lista.ItemClick += (se, del) =>
            {
            };
            btn.Click += delegate
            {
                alerta.Show();
            };
            volver.Click += delegate
            {
                animar(volver);

                tr.Abort();
                this.Finish();
            };
            playpause.Click += delegate
            {
                animar(playpause);
                YoutubePlayerServerActivity.gettearinstancia().imgPlay.PerformClick();
            };

            //   ll2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#2b2e30"));
        }
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Customsearcher);
            ///////////////////////////////////////declaraciones/////////////////////////////////

            string ip = Intent.GetStringExtra("ipadre").Trim();

            listaimagen = new List <VideoImage>();
            viddeos     = new List <Video>();
            imagelist   = new List <Android.Graphics.Bitmap>();

            texto = FindViewById <EditText>(Resource.Id.editText1);
            //  ImageView botonbuscar = FindViewById<ImageView>(Resource.Id.imageView1);
            ImageView botonreconocer = FindViewById <ImageView>(Resource.Id.imageView2);
            ImageView playpause      = FindViewById <ImageView>(Resource.Id.imageView4);

            tv1    = FindViewById <TextView>(Resource.Id.textView1);
            lineaa = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            ImageView botonhome = FindViewById <ImageView>(Resource.Id.imageView3);

            lineall2 = FindViewById <LinearLayout>(Resource.Id.linearLayout4);
            listbox  = FindViewById <ListView>(Resource.Id.listView1);
            //  progresooo = FindViewById<ProgressBar>(Resource.Id.progresss);

            UiHelper.SetBackgroundAndRefresh(this);
            var adaptadol = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string> {
                "No hay elementos para mostrar.."
            });

            RunOnUiThread(() => {
                var parcelable  = listbox.OnSaveInstanceState();
                listbox.Adapter = adaptadol;
                listbox.OnRestoreInstanceState(parcelable);
            });
            ////////////////////////////////////////////////miselaneo///////////////////////////////////
            color      = Intent.GetStringExtra("color");
            nombreses  = new List <string>();
            linkeses   = new List <string>();
            autoreses  = new List <string>();
            duraciones = new List <string>();
            //   lineall2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#4f5459"));
            //  animar2(lineall2);
            tv1.Selected = true;


            if (color.Trim() != "none")
            {
                //  lineaa.SetBackgroundColor(Android.Graphics.Color.ParseColor(color.Trim()));
            }

            if (!Directory.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache"))
            {
                Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache");
            }


            if (!Directory.Exists(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/webbrowser"))
            {
                Directory.CreateDirectory(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/webbrowser");
            }
            else
            {
            }

            /////////////////////////////////////////////////threads///////////////////////////////////////////////
            //  lineall2.SetBackgroundColor(Android.Graphics.Color.ParseColor("#2b2e30"));
            procc = new Thread(new ThreadStart(cojerstream));
            procc.Start();

            var procc2 = new Thread(new ThreadStart(cargardesdecache));

            procc2.Start();
            ////////////////////////////////////////events//////////////////////////////////////////////////////
            texto.KeyPress += (aaxx, e) =>
            {
                if (e.Event.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter)
                {
                    // Code executed when the enter key is pressed down

                    if (buscando == false)
                    {
                        termino = texto.Text;
                        //  Toast.MakeText(this, "Buscando.. por favor espere", ToastLength.Long);
                        foreach (string aa in Directory.GetFiles(Android.OS.Environment.ExternalStorageDirectory + "/.gr3cache/webbrowser"))
                        {
                            File.Delete(aa);
                        }
                        MultiHelper.ExecuteGarbageCollection();
                        Thread proc = new Thread(new ThreadStart(buscar));
                        proc.Start();
                    }
                }
                else
                {
                    e.Handled = false;
                }
            };

            botonhome.Click += delegate {
                animar(botonhome);

                procc.Abort();

                MultiHelper.ExecuteGarbageCollection();
                this.Finish();
            };

            playpause.Click += delegate
            {
                animar(playpause);
                if (Mainmenu.gettearinstancia() != null)
                {
                    Mainmenu.gettearinstancia().play.PerformClick();
                }
                else
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    YoutubePlayerServerActivity.gettearinstancia().imgPlay.PerformClick();
                }
            };

            botonreconocer.Click += delegate
            {
                animar(botonreconocer);
                try {
                    var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 500);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 500);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 10000);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
                    voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                    StartActivityForResult(voiceIntent, voz);
                } catch (Exception)
                {
                }
            };

            listbox.ItemClick += (easter, sender) =>
            {
                if (nombreses.Count > 0)
                {
                    if (sender.Position >= 0)
                    {
                        Intent intentar = new Intent(this, typeof(customdialogact));
                        string ipadree  = Intent.GetStringExtra("ipadre");
                        intentar.PutExtra("ipadress", ipadree);
                        intentar.PutExtra("imagen", "http://i.ytimg.com/vi/" + linkeses[sender.Position].Split('=')[1] + "/mqdefault.jpg");
                        intentar.PutExtra("url", linkeses[sender.Position]);
                        intentar.PutExtra("titulo", nombreses[sender.Position]);
                        intentar.PutExtra("color", color);
                        StartActivity(intentar);
                    }
                }
            };



            // Create your application here
        }
        public override void OnReceive(Context context, Intent intent)
        {
            if (playeroffline.gettearinstancia() != null || YoutubePlayerServerActivity.gettearinstancia() != null || Mainmenu.gettearinstancia() != null)
            {
                if (intent.Action != Intent.ActionMediaButton && intent.Action != AudioManager.ActionAudioBecomingNoisy)
                {
                    return;
                }
                else
                {
                    if (intent.Action == Intent.ActionMediaButton)
                    {
                        var keyEvent = (KeyEvent)intent.GetParcelableExtra(Intent.ExtraKeyEvent);



                        if (keyEvent.Action == KeyEventActions.Down)
                        {
                            switch (keyEvent.KeyCode)
                            {
                            case Android.Views.Keycode.Headsethook:



                                if (playeroffline.gettearinstancia() != null)
                                {
                                    Android.OS.Handler mHandler = new Android.OS.Handler();
                                    mHandler.PostDelayed(new Action(() => { playeroffline.gettearinstancia().counter = 0; }), 500);

                                    playeroffline.gettearinstancia().millis = SystemClock.CurrentThreadTimeMillis();



                                    if (playeroffline.gettearinstancia().counter < 1)
                                    {
                                        playeroffline.gettearinstancia().counter++;

                                        playeroffline.gettearinstancia().RunOnUiThread(() =>
                                        {
                                            playeroffline.gettearinstancia().playpause.CallOnClick();
                                        });
                                    }
                                    else
                                    {
                                        playeroffline.gettearinstancia().counter = 0;
                                        playeroffline.gettearinstancia().RunOnUiThread(() =>
                                        {
                                            playeroffline.gettearinstancia().siguiente.CallOnClick();
                                        });
                                    }
                                }
                                else
                                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                                {
                                    Android.OS.Handler mHandler = new Android.OS.Handler();
                                    mHandler.PostDelayed(new Action(() => { YoutubePlayerServerActivity.gettearinstancia().counter = 0; }), 500);

                                    YoutubePlayerServerActivity.gettearinstancia().millis = SystemClock.CurrentThreadTimeMillis();



                                    if (YoutubePlayerServerActivity.gettearinstancia().counter < 1)
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().counter++;

                                        YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                        {
                                            YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick();
                                        });
                                    }
                                    else
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().counter = 0;
                                        YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                        {
                                            YoutubePlayerServerActivity.gettearinstancia().imgNext.CallOnClick();
                                        });
                                    }
                                }


                                break;

                            case Keycode.MediaPlayPause:
                                if (playeroffline.gettearinstancia() != null)
                                {
                                    playeroffline.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        playeroffline.gettearinstancia().playpause.CallOnClick();
                                    });
                                }
                                else
                                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                                {
                                    YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick();
                                    });
                                }

                                break;

                            case Keycode.MediaNext:
                                if (playeroffline.gettearinstancia() != null)
                                {
                                    playeroffline.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        playeroffline.gettearinstancia().siguiente.CallOnClick();
                                    });
                                }
                                else
                                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                                {
                                    YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().imgNext.CallOnClick();
                                    });
                                }

                                break;

                            case Keycode.MediaPlay:
                                if (playeroffline.gettearinstancia() != null)
                                {
                                    playeroffline.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        playeroffline.gettearinstancia().playpause.CallOnClick();
                                    });
                                }
                                else
                                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                                {
                                    YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick();
                                    });
                                }
                                break;

                            case Keycode.MediaPause:
                                if (playeroffline.gettearinstancia() != null)
                                {
                                    playeroffline.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        playeroffline.gettearinstancia().playpause.CallOnClick();
                                    });
                                }
                                else
                                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                                {
                                    YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick();
                                    });
                                }
                                break;

                            case Keycode.MediaPrevious:
                                if (playeroffline.gettearinstancia() != null)
                                {
                                    playeroffline.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        playeroffline.gettearinstancia().anterior.CallOnClick();
                                    });
                                }
                                else
                                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                                {
                                    YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() =>
                                    {
                                        YoutubePlayerServerActivity.gettearinstancia().imgBack.CallOnClick();
                                    });
                                }
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (Clouding_service.gettearinstancia() != null)
                        {
                            if (YoutubePlayerServerActivity.gettearinstancia() != null)
                            {
                                YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => YoutubePlayerServerActivity.gettearinstancia().imgPlay.SetBackgroundResource(Resource.Drawable.playbutton2));
                                Clouding_service.gettearinstancia().musicaplayer.Pause();
                            }
                        }
                        else
                        if (Clouding_serviceoffline.gettearinstancia() != null)
                        {
                            if (playeroffline.gettearinstancia() != null)
                            {
                                playeroffline.gettearinstancia().RunOnUiThread(() => playeroffline.gettearinstancia().playpause.SetBackgroundResource(Resource.Drawable.playbutton2));
                                Clouding_serviceoffline.gettearinstancia().musicaplayer.Pause();
                            }
                        }
                    }
                }
            }
            else
            {
            }
        }
        public void cojerstream()
        {
            while (!this.IsDestroyed)
            {
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    if (YoutubePlayerServerActivity.gettearinstancia().buscando != true)
                    {
                        if (YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text != textboxtitulo.Text &&
                            YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text.Trim() != "")
                        {
                            RunOnUiThread(() => textboxtitulo.Text = YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text);
                        }
                    }
                    else
                    {
                        RunOnUiThread(() => textboxtitulo.Text = "Buscando...");
                    }

                    if (textboxtitulo.Text.Trim() == "" && textboxtitulo.Text.Trim() != "No hay elementos en cola")
                    {
                        RunOnUiThread(() => { textboxtitulo.Text = "No hay elementos en cola"; });
                    }



                    if (YoutubePlayerServerActivity.gettearinstancia().clienteses.Count > 0)
                    {
                        try
                        {
                            var dummynames = YoutubePlayerServerActivity.gettearinstancia()
                                             .clienteses.Select(ax => ((IPEndPoint)ax.Client.RemoteEndPoint).Address.ToString())
                                             .Where(aax => aax != YoutubePlayerServerActivity.gettearinstancia().ipAddress.Trim()).Distinct()
                                             .ToList();
                            var dummylinks = dummynames.Select(ax => ax + "=sdss").ToList();

                            RunOnUiThread(() =>
                            {
                                if (dummynames.Count != countold)
                                {
                                    countold = dummynames.Count;
                                    adapterlistaremoto ada = new adapterlistaremoto(this, dummynames, dummylinks, null, Resource.Drawable.remotecontrolbuttons);

                                    var parcelable = lista.OnSaveInstanceState();
                                    lista.Adapter  = ada;
                                    lista.OnRestoreInstanceState(parcelable);
                                }
                            });
                        }
                        catch (Exception) { }
                    }
                    else
                    {
                        RunOnUiThread(() => {
                            var adaptadol = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new List <string> {
                                "No hay dispositivos conectados.."
                            });

                            var parcelable = lista.OnSaveInstanceState();
                            lista.Adapter  = adaptadol;
                            lista.OnRestoreInstanceState(parcelable);
                        });
                    }
                }
                else
                if (Mainmenu.gettearinstancia() != null)
                {
                    if (Mainmenu.gettearinstancia().label.Text != textboxtitulo.Text)
                    {
                        RunOnUiThread(() => textboxtitulo.Text = Mainmenu.gettearinstancia().label.Text);
                    }
                }
                else
                {
                }


                Thread.Sleep(1000);
            }
        }
        public void cargarresults()
        {
            try
            {
                RunOnUiThread(() =>
                {
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                    alerta = new ProgressDialog(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                    alerta.SetTitle("Buscando videos sugeridos");
                    alerta.SetMessage("Por favor espere...");
                    alerta.SetCancelable(false);
                    alerta.Create();
                    alerta.Show();
                });

                YoutubeSearch.VideoSearch             buscar  = new YoutubeSearch.VideoSearch();
                List <YoutubeSearch.VideoInformation> results = new List <YoutubeSearch.VideoInformation>();
                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    if (YoutubePlayerServerActivity.gettearinstancia().sugerencias.Count > 0)
                    {
                        results = YoutubePlayerServerActivity.gettearinstancia().sugerencias;
                    }
                    else
                    {
                        results = buscar.SearchQuery("", 1);
                        YoutubePlayerServerActivity.gettearinstancia().sugerencias = results;
                    }
                }
                else
                if (Mainmenu.gettearinstancia() != null)
                {
                    if (Mainmenu.gettearinstancia().sugerencias.Count > 0)
                    {
                        results = Mainmenu.gettearinstancia().sugerencias;
                    }
                    else
                    {
                        results = buscar.SearchQuery("", 1);
                        Mainmenu.gettearinstancia().sugerencias = results;
                    }
                }



                List <PlaylistElement> listafake = new List <PlaylistElement>();
                foreach (var data in results)
                {
                    listafake.Add(new PlaylistElement
                    {
                        Name = WebUtility.HtmlDecode(data.Title),
                        Link = data.Url
                    });
                }
                RunOnUiThread(() =>
                {
                    adaptadorcartas adap = new adaptadorcartas(listafake, this);
                    adap.ItemClick      += (aa, aaa) =>
                    {
                        RunOnUiThread(() =>
                        {
                            var elemento   = listafake[aaa.Position];
                            Intent intento = new Intent(this, typeof(customdialogact));

                            intento.PutExtra("url", elemento.Link);
                            intento.PutExtra("titulo", elemento.Name);
                            intento.PutExtra("imagen", "http://i.ytimg.com/vi/" + elemento.Link.Split('=')[1] + "/mqdefault.jpg");
                            StartActivity(intento);
                        });
                    };
                    listasugerencias.SetAdapter(adap);
                    alerta.Dismiss();

                    if (listafake.Count > 0)
                    {
                        secciones[3].Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        secciones[3].Visibility = ViewStates.Gone;
                    }
                });
            }
            catch (Exception)
            {
                RunOnUiThread(() => alerta.Dismiss());
            }
        }
        public void mostrarnotificacion()
        {
            List <PendingIntent> listapending = listapendingintents();


            RemoteViews contentView = new RemoteViews(PackageName, Resource.Layout.layoutminiplayer);

            if (linkactual.Trim().Length > 1)
            {
                try
                {
                    contentView.SetImageViewBitmap(Resource.Id.imageView1, ImageHelper.GetRoundedShape(GetImageBitmapFromUrl("https://i.ytimg.com/vi/" + linkactual.Split('=')[1] + "/mqdefault.jpg")));
                    contentView.SetImageViewBitmap(Resource.Id.fondo1, ImageHelper.CreateBlurredImageFromUrl(this, 20, linkactual));
                }
                catch (Exception)
                {
                }
            }
            contentView.SetTextViewText(Resource.Id.textView1, tituloactual);

            contentView.SetOnClickPendingIntent(Resource.Id.imageView2, listapending[0]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView4, listapending[1]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView3, listapending[2]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView6, listapending[3]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView5, listapending[4]);
            contentView.SetOnClickPendingIntent(Resource.Id.imageView1, listapending[5]);

            Notification.Action accion1 = new Notification.Action(Resource.Drawable.playpause, "Playpause", listapending[0]);
            Notification.Action accion2 = new Notification.Action(Resource.Drawable.skipnext, "Siguiente", listapending[1]);
            Notification.Action accion3 = new Notification.Action(Resource.Drawable.skipprevious, "Anterior", listapending[2]);
            Notification.Action accion4 = new Notification.Action(Resource.Drawable.skipforward, "adelantar", listapending[3]);
            Notification.Action accion5 = new Notification.Action(Resource.Drawable.skipbackward, "atrazar", listapending[4]);

            Notification.MediaStyle estilo = new Notification.MediaStyle();
            if (YoutubePlayerServerActivity.gettearinstancia() != null)
            {
                estilo.SetMediaSession(YoutubePlayerServerActivity.gettearinstancia().mSession.SessionToken);

                estilo.SetShowActionsInCompactView(1, 2, 3);
            }

#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            var nBuilder = new Notification.Builder(this);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
                try
                {
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
                    nBuilder.SetContent(contentView);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
                }
                catch (Exception) {
                }
            }
            else
            {
                nBuilder.SetStyle(estilo);
                nBuilder.SetLargeIcon(ImageHelper.GetImageBitmapFromUrl("http://i.ytimg.com/vi/" + linkactual.Split('=')[1] + "/mqdefault.jpg"));
                nBuilder.SetContentTitle(tituloactual);
                nBuilder.SetContentText(linkactual);
                nBuilder.AddAction(accion5);
                nBuilder.AddAction(accion3);
                nBuilder.AddAction(accion1);
                nBuilder.AddAction(accion2);
                nBuilder.AddAction(accion4);
                nBuilder.SetContentIntent(listapending[5]);
                nBuilder.SetColor(Android.Graphics.Color.ParseColor("#ce2c2b"));
            }
            nBuilder.SetOngoing(true);

            nBuilder.SetSmallIcon(Resource.Drawable.play);

            Notification notification = nBuilder.Build();
            StartForeground(19248736, notification);
            listapending.Clear();
        }
示例#24
0
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
        protected override void OnCreate(Bundle savedInstanceState)
        {
            SetContentView(Resource.Layout.Downloadcenteroffline);


            base.OnCreate(savedInstanceState);
            ISharedPreferences       prefs      = Application.Context.GetSharedPreferences("Settings", FileCreationMode.Private);
            ISharedPreferencesEditor prefEditor = prefs.Edit();

            //////////////////////////////////TCpclientconnect/////////////

            string ip = Intent.GetStringExtra("ip");

            linkvid = Intent.GetStringExtra("zelda");
            colores = Intent.GetStringExtra("color");

            Intent.Extras.Clear();
            //////////////////////////////////DEclaraciones////////////////
            RadioGroup radio1 = FindViewById <RadioGroup>(Resource.Id.radioGroup1);


            ImageView iv2       = FindViewById <ImageView>(Resource.Id.imageView2);
            ImageView playpause = FindViewById <ImageView>(Resource.Id.imageView7);

            ImageView iv4 = FindViewById <ImageView>(Resource.Id.imageView3);

            tv4 = FindViewById <TextView>(Resource.Id.textView6);


            RadioButton rb4 = FindViewById <RadioButton>(Resource.Id.radioButton4);
            RadioButton rb5 = FindViewById <RadioButton>(Resource.Id.radioButton5);
            RadioButton rb6 = FindViewById <RadioButton>(Resource.Id.radioButton6);

            lineall2 = FindViewById <LinearLayout>(Resource.Id.linearLayout2);
            llayout  = FindViewById <LinearLayout>(Resource.Id.LinearLayout0);


            UiHelper.SetBackgroundAndRefresh(this);
            ///////////////////////////////////////mp3load+durationbarload//////////////////////
            tv4.Selected = true;
            trer         = new Thread(new ThreadStart(cojerstream));
            trer.Start();

            //    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("#2b2e30"));
            ///////////////////////////////////events//////////////////////////////////////
            playpause.Click += delegate
            {
                animar(playpause);
                YoutubePlayerServerActivity.gettearinstancia().imgPlay.PerformClick();
            };



            iv4.Click += delegate
            {
                animar(iv4);
                trer.Abort();

                musicaplayer.Reset();
                parador = false;
                this.Finish();
            };
            iv2.Click += delegate
            {
                animar(iv2);

                if (enporceso == false && rb4.Checked == true)
                {
                    quality = 360;
                    Thread tree = new Thread(new ThreadStart(descvids));
                    tree.Start();
                }
                else
                if (enporceso == false && rb5.Checked == true)
                {
                    quality = 720;
                    Thread tree2 = new Thread(new ThreadStart(descvids));
                    tree2.Start();
                }

                else
                if (enporceso == false && rb6.Checked == true)
                {
                    quality = -1;
                    Thread tree3 = new Thread(new ThreadStart(descmp3));
                    tree3.Start();
                }
            };
            musicaplayer.SeekComplete += delegate
            {
            };
        }
示例#25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.eliminardialog);

            TextView texto = FindViewById <TextView>(Resource.Id.textView1);

            imagenview = FindViewById <ImageView>(Resource.Id.imageView1);
            LinearLayout agregar = FindViewById <LinearLayout>(Resource.Id.imageView2);

            buscar = FindViewById <LinearLayout>(Resource.Id.imageView3);
            ImageView    volver    = FindViewById <ImageView>(Resource.Id.imageView4);
            LinearLayout lineall2  = FindViewById <LinearLayout>(Resource.Id.linearLayout4);
            LinearLayout lineaa    = FindViewById <LinearLayout>(Resource.Id.linearlayout0);
            LinearLayout descargar = FindViewById <LinearLayout>(Resource.Id.imageView5);
            LinearLayout addlista  = FindViewById <LinearLayout>(Resource.Id.imageView6);

            fondo = FindViewById <ImageView>(Resource.Id.fondo1);
            //   animar2(lineaa);
            texto.Selected = true;

            buscar.Visibility = ViewStates.Visible;
            string colol = Intent.GetStringExtra("color");

            url = Intent.GetStringExtra("url");
            string posicion = Intent.GetStringExtra("index");

            url = "https://www.youtube.com/watch?v=" + url.Split('=')[1];
            if (colol.Trim() != "none")
            {
                // lineaa.SetBackgroundColor(Color.ParseColor(colol));
                if (colol == "Black")
                {
                    //   lineall2.SetBackgroundColor(Android.Graphics.Color.DarkGray);
                }
                else
                {
                    //  lineall2.SetBackgroundColor(Android.Graphics.Color.Black);
                };
            }
            imagem = Intent.GetStringExtra("imagen");
            string titulo = Intent.GetStringExtra("titulo");

            texto.Text = titulo;


            this.SetFinishOnTouchOutside(true);

            animar2(lineall2);

            proc = new Thread(new ThreadStart(ponerimagen));
            proc.Start();
            volver.Click += delegate
            {
                animar(volver);


                this.Finish();
            };
            addlista.Click += delegate
            {
                animar(addlista);
                Intent intentar = new Intent(this, typeof(actividadagregarlistahecha));
                intentar.PutExtra("nombrevid", titulo);
                intentar.PutExtra("linkvid", url);
                StartActivity(intentar);
                this.Finish();
            };
            agregar.Click += delegate
            {
                animar(agregar);



                if (YoutubePlayerServerActivity.gettearinstancia() == null)
                {
                    if (Mainmenu.gettearinstancia().clientela.Connected == true)
                    {
                        Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes("eliminarelemento()"));
                        Thread.Sleep(250);
                        Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes(posicion));
                    }
                }
                else
                {
                    new Thread(() =>
                    {
                        YoutubePlayerServerActivity.gettearinstancia().eliminarelementodireckt(int.Parse(posicion));
                    }).Start();
                }



                this.Finish();
            };
            descargar.Click += delegate
            {
                animar(descargar);
                Intent intento = new Intent(this, typeof(actdownloadcenterofflinedialog));
                intento.PutExtra("ip", "localhost");
                intento.PutExtra("zelda", url);
                intento.PutExtra("color", colol);
                StartActivity(intento);
                this.Finish();
            };
            buscar.Click += delegate
            {
                animar(buscar);



                if (YoutubePlayerServerActivity.gettearinstancia() == null)
                {
                    if (Mainmenu.gettearinstancia().clientela.Connected == true)
                    {
                        Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes("pedirindice()"));
                        Thread.Sleep(250);
                        Mainmenu.gettearinstancia().clientela.Client.Send(Encoding.Default.GetBytes(posicion));
                    }
                }
                else
                {
                    new Thread(() =>
                    {
                        YoutubePlayerServerActivity.gettearinstancia().reproddelistadireckt(int.Parse(posicion));
                    }).Start();
                }



                this.Finish();
            };

            // Create your application here
        }
示例#26
0
        public void cojerstreamlocal()
        {
            bool cojioto = false;

            string[] listica;
            var      strim = clientelocal.GetStream();

            byte[] elbuffer          = new byte[120000];
            int    o                 = 0;
            bool   enviomensaje      = false;
            string lalistacompletita = "";

            while (parador)
            {
                if (!enviomensaje)
                {
                    clientelocal.Client.Send(Encoding.UTF8.GetBytes("recall()"));
                    enviomensaje = true;
                }
                while (strim.DataAvailable)
                {
                    o = strim.Read(elbuffer, 0, elbuffer.Length);
                    lalistacompletita += Encoding.UTF8.GetString(elbuffer, 0, o);
                    cojioto            = true;
                }
                if (cojioto == true && lalistacompletita.Trim() != "")
                {
                    listica = lalistacompletita.Split(';');
                    if (listica[0] == "caratula()><")
                    {
                        lalistacompletita = "";
                    }
                    else
                    if (listica[0] == "links()><")
                    {
                        listalinks = listica.ToList();
                        listalinks.RemoveAt(0);
                        lalistacompletita = "";
                        Thread proc = new Thread(new ThreadStart(enviarlistitaaa));
                        proc.IsBackground = true;
                        proc.Start();
                    }
                    else
                    if (lalistacompletita.Length > 0)
                    {
                        listanombres      = listica.ToList();
                        lalistacompletita = "";
                    }

                    cojioto  = false;
                    elbuffer = new byte[120000];
                    o        = 0;
                }


                if (YoutubePlayerServerActivity.gettearinstancia() != null)
                {
                    if (YoutubePlayerServerActivity.gettearinstancia().buscando == false)
                    {
                        if (YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text.Trim() != "" &&
                            tvnombrecancion.Text != YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text)
                        {
                            RunOnUiThread(() => tvnombrecancion.Text = YoutubePlayerServerActivity.gettearinstancia().tvTitle.Text);
                        }
                    }
                    else
                    {
                        RunOnUiThread(() => tvnombrecancion.Text = "Buscando...");
                    }
                }
                else
                if (Mainmenu.gettearinstancia() != null)
                {
                    if (Mainmenu.gettearinstancia().buscando == false)
                    {
                        if (Mainmenu.gettearinstancia().label.Text.Trim() != "" &&
                            tvnombrecancion.Text != Mainmenu.gettearinstancia().label.Text)
                        {
                            RunOnUiThread(() => tvnombrecancion.Text = Mainmenu.gettearinstancia().label.Text);
                        }
                    }
                    else
                    {
                        RunOnUiThread(() => tvnombrecancion.Text = "Buscando...");
                    }
                }


                if (tvnombrecancion.Text.Trim() == "" && tvnombrecancion.Text.Trim() != "No hay elementos en cola")
                {
                    RunOnUiThread(() => { tvnombrecancion.Text = "No hay elementos en cola"; });
                }


                Thread.Sleep(200);
            }
        }