public ChromeCastPage(ChromecastData data)
        {
            currentChromeData = data;
            isActive          = true;
            //episodeResult = MovieResult.chromeResult;
            //  chromeMovieResult = MovieResult.chromeMovieResult;

            InitializeComponent();

            if (lastId != currentChromeData.episodeId)        //chromeMovieResult.title.id) {
            {
                lastId         = currentChromeData.episodeId; //chromeMovieResult.title.id;
                subtitles      = new List <Subtitle>();
                subtitleDelay  = 0;
                subtitleIndex  = -1;
                HasSubtitlesOn = false;
                print("NOT THE SAME AT LAST ONE");
                if (globalSubtitlesEnabled)
                {
                    PopulateSubtitle();
                }
            }
            else
            {
                //subtitles = lastSubtitles;
            }

            Subbutton.Source   = App.GetImageSource("outline_subtitles_white_48dp.png");
            BindingContext     = this;
            TitleName          = currentChromeData.titleName;                                                    //chromeMovieResult.title.name;
            EpisodeTitleName   = currentChromeData.episodeTitleName;                                             //episodeResult.Title;
            PosterUrl          = CloudStreamCore.ConvertIMDbImagesToHD(currentChromeData.hdPosterUrl, 150, 225); //chromeMovieResult.title.hdPosterUrl, 150, 225);
            EpisodePosterUrl   = currentChromeData.episodePosterUrl;                                             //episodeResult.PosterUrl;
            EpisodeDescription = currentChromeData.descript;                                                     //episodeResult.Description;
            BackgroundColor    = Settings.BlackRBGColor;
            //  CloudStreamForms.MainPage.mainPage.BarBackgroundColor = Color.Transparent;
            ChromeLabel.Text = "Connected to " + MainChrome.chromeRecivever.FriendlyName;

            try {
                DescriptName = DescriptSetName;// currentChromeData.MirrorsNames[currentSelected];//episodeResult.Mirros[currentSelected];
            }
            catch (Exception _ex) {
                print("ERROR LOADING MIRROR " + _ex);
            }



            //https://material.io/resources/icons/?style=baseline
            VideoSlider.DragStarted += (o, e) => {
                draging = true;
            };


            VideoSlider.DragCompleted += (o, e) => {
                MainChrome.SetChromeTime(VideoSlider.Value * CurrentCastingDuration);
                draging = false;
                UpdateTxt();
            };

            const bool rotateAllWay = false;
            const int  rotate       = 90;
            const int  time         = 100;

            Commands.SetTap(FastForwardBtt, new Command(async() => {
                SeekMedia(FastForwardTime);
                FastForward.Rotation = 0;
                if (rotateAllWay)
                {
                    await FastForward.RotateTo(360, 200, Easing.SinOut);
                }
                else
                {
                    FastForward.ScaleTo(0.9, time, Easing.SinOut);
                    await FastForward.RotateTo(rotate, time, Easing.SinOut);
                    FastForward.ScaleTo(1, time, Easing.SinOut);
                    await FastForward.RotateTo(0, time, Easing.SinOut);
                }
            }));

            Commands.SetTap(BackForwardBtt, new Command(async() => {
                SeekMedia(-BackForwardTime);
                BackForward.Rotation = 0;
                if (rotateAllWay)
                {
                    await BackForward.RotateTo(-360, 200, Easing.SinOut);
                }
                else
                {
                    BackForward.ScaleTo(0.9, time, Easing.SinOut);
                    await BackForward.RotateTo(-rotate, time, Easing.SinOut);
                    BackForward.ScaleTo(1, time, Easing.SinOut);
                    await BackForward.RotateTo(0, time, Easing.SinOut);
                }
            }));

            StopAll.Clicked += (o, e) => {
                //  MainChrome.StopCast();
                JustStopVideo();
                OnStop();
            };

            if (currentChromeData.isFromFile)
            {
                UpperIconHolder.TranslationX  = 20;
                LowerIconHolder.ColumnSpacing = 40;

                PlayList.IsEnabled = false;
                PlayList.IsVisible = false;

                SkipForward.IsEnabled = false;
                SkipForward.IsVisible = false;

                SkipBack.IsEnabled = false;
                SkipBack.IsVisible = false;

                Grid.SetColumn(Subbutton, 0);
                Grid.SetColumn(StopAll, 1);
                Grid.SetColumn(Audio, 2);

                if (currentChromeData.movieType == MovieType.YouTube)
                {
                    Subbutton.IsEnabled = false;
                    Subbutton.Opacity   = 0;
                    //TODO Add youtube subtitles download
                }
            }
            else
            {
                PlayList.Clicked += async(o, e) => {
                    //ListScale();
                    string a = await ActionPopup.DisplayActionSheet("Select Mirror", currentChromeData.MirrorsNames.ToArray()); //await DisplayActionSheet("Select Mirror", "Cancel", null, episodeResult.Mirros.ToArray());

                    //ListScale();
                    for (int i = 0; i < currentChromeData.MirrorsNames.Count; i++)
                    {
                        if (a == currentChromeData.MirrorsNames[i])
                        {
                            currentSelected = i;
                            SelectMirror();
                            return;
                        }
                    }
                };

                SkipForward.Clicked += async(o, e) => {
                    currentSelected++;
                    if (currentSelected > currentChromeData.MirrorsNames.Count)
                    {
                        currentSelected = 0;
                    }
                    SelectMirror();
                    await SkipForward.TranslateTo(6, 0, 50, Easing.SinOut);

                    await SkipForward.TranslateTo(0, 0, 50, Easing.SinOut);
                };

                SkipBack.Clicked += async(o, e) => {
                    currentSelected--;
                    if (currentSelected < 0)
                    {
                        currentSelected = currentChromeData.MirrorsNames.Count - 1;
                    }
                    SelectMirror();
                    await SkipBack.TranslateTo(-6, 0, 50, Easing.SinOut);

                    await SkipBack.TranslateTo(0, 0, 50, Easing.SinOut);
                };
            }
            ConstUpdate();

            MainChrome.Volume = (MainChrome.Volume);

            /*
             * LowVol.Source = GetImageSource("round_volume_down_white_48dp.png");
             * MaxVol.Source = GetImageSource("round_volume_up_white_48dp.png");*/

            //   UserDialogs.Instance.TimePrompt(new TimePromptConfig() { CancelText = "Cancel", Title = "da", Use24HourClock = false, OkText = "OK", IsCancellable = true });
        }
示例#2
0
 static string GetPoster(string _poster)
 {
     return(CloudStreamCore.ConvertIMDbImagesToHD(_poster, 2240, 1260, 1, false, true));
 }
        public ChromeCastPage()
        {
            isActive          = true;
            episodeResult     = MovieResult.chromeResult;
            chromeMovieResult = MovieResult.chromeMovieResult;

            InitializeComponent();
            BindingContext     = this;
            TitleName          = chromeMovieResult.title.name;
            EpisodeTitleName   = episodeResult.Title;
            PosterUrl          = CloudStreamCore.ConvertIMDbImagesToHD(chromeMovieResult.title.hdPosterUrl, 150, 225);
            EpisodePosterUrl   = episodeResult.PosterUrl;
            EpisodeDescription = episodeResult.Description;
            BackgroundColor    = Settings.BlackRBGColor;
            //  CloudStreamForms.MainPage.mainPage.BarBackgroundColor = Color.Transparent;
            ChromeLabel.Text = "Connected to " + MainChrome.chromeRecivever.FriendlyName;

            try {
                DescriptName = episodeResult.Mirros[currentSelected];
            }
            catch (Exception _ex) {
                print("ERROR LOADING MIRROR " + _ex);
            }

            MainChrome.OnDisconnected += (o, e) => {
                OnStop();
            };

            MainChrome.OnPauseChanged += (o, e) => {
                SetPause(e);
            };

            //https://material.io/resources/icons/?style=baseline
            VideoSlider.DragStarted += (o, e) => {
                draging = true;
            };

            VideoSlider.DragCompleted += (o, e) => {
                MainChrome.SetChromeTime(VideoSlider.Value * CurrentCastingDuration);
                draging = false;
                UpdateTxt();
            };
            const bool rotateAllWay = false;
            const int  rotate       = 90;

            FastForward.Clicked += async(o, e) => {
                SeekMedia(FastForwardTime);
                FastForward.Rotation = 0;
                if (rotateAllWay)
                {
                    await FastForward.RotateTo(360, 200, Easing.SinOut);
                }
                else
                {
                    await FastForward.RotateTo(rotate, 50, Easing.SinOut);

                    await FastForward.RotateTo(0, 50, Easing.SinOut);
                }
            };

            BackForward.Clicked += async(o, e) => {
                SeekMedia(-BackForwardTime);
                BackForward.Rotation = 0;
                if (rotateAllWay)
                {
                    await BackForward.RotateTo(-360, 200, Easing.SinOut);
                }
                else
                {
                    await BackForward.RotateTo(-rotate, 50, Easing.SinOut);

                    await BackForward.RotateTo(0, 50, Easing.SinOut);
                }
            };

            StopAll.Clicked += (o, e) => {
                MainChrome.StopCast();
                OnStop();
            };

            SkipForward.Clicked += async(o, e) => {
                currentSelected++;
                if (currentSelected > episodeResult.Mirros.Count)
                {
                    currentSelected = 0;
                }
                SelectMirror();
                await SkipForward.TranslateTo(6, 0, 50, Easing.SinOut);

                await SkipForward.TranslateTo(0, 0, 50, Easing.SinOut);
            };

            SkipBack.Clicked += async(o, e) => {
                currentSelected--;
                if (currentSelected < 0)
                {
                    currentSelected = episodeResult.Mirros.Count - 1;
                }
                SelectMirror();
                await SkipBack.TranslateTo(-6, 0, 50, Easing.SinOut);

                await SkipBack.TranslateTo(0, 0, 50, Easing.SinOut);
            };

            PlayList.Clicked += async(o, e) => {
                //ListScale();
                string a = await DisplayActionSheet("Select Mirror", "Cancel", null, episodeResult.Mirros.ToArray());

                //ListScale();

                for (int i = 0; i < episodeResult.Mirros.Count; i++)
                {
                    if (a == episodeResult.Mirros[i])
                    {
                        currentSelected = i;
                        SelectMirror();
                        return;
                    }
                }
            };
            ConstUpdate();

            MainChrome.Volume = (MainChrome.Volume);

            /*
             * LowVol.Source = GetImageSource("round_volume_down_white_48dp.png");
             * MaxVol.Source = GetImageSource("round_volume_up_white_48dp.png");*/

            //   UserDialogs.Instance.TimePrompt(new TimePromptConfig() { CancelText = "Cancel", Title = "da", Use24HourClock = false, OkText = "OK", IsCancellable = true });
        }