コード例 #1
0
 static async Task UpdateSubtitles()
 {
     _ = ActionPopup.StartIndeterminateLoadinbar("Loading Subtitles...");
     if (subtitleIndex != -1)
     {
         await ChangeSubtitles(subtitles[subtitleIndex].data, subtitles[subtitleIndex].name, subtitleDelay);
     }
     else
     {
         await ChangeSubtitles("", "", 0);
     }
     await ActionPopup.StopIndeterminateLoadinbar();
 }
コード例 #2
0
        public Download()
        {
            InitializeComponent();
            OffBar.Source = App.GetImageSource("gradient.png"); OffBar.HeightRequest = 3; OffBar.HorizontalOptions = LayoutOptions.Fill; OffBar.ScaleX = 100; OffBar.Opacity = 0.3; OffBar.TranslationY = 9;

            if (Settings.IS_TEST_BUILD)
            {
#pragma warning disable CS0162 // Unreachable code detected
                return;

#pragma warning restore CS0162 // Unreachable code detected
            }
            try {
                baseImg.Source = App.GetImageSource("NoDownloads.png");

                bool hasDownloads = App.GetKey("Settings", "hasDownloads", false);

                baseTxt.IsVisible = !hasDownloads;
                baseImg.IsVisible = !hasDownloads;

                /*
                 * RefreshView refresh = new RefreshView() { BackgroundColor = Color.Black, RefreshColor = Color.Blue, Command = RefreshCommand };
                 * refresh.SetBinding(RefreshView.IsRefreshingProperty, new Binding(nameof(IsRefreshing)));
                 * ScrollView scrollView = new ScrollView();
                 * scrollView.Content = episodeView;
                 * refresh.Content = episodeView;*/

                // ytBtt.Source = App.GetImageSource("round_movie_white_48dp.png");
                ytBtt.Source = App.GetImageSource("ytIcon.png");

                ytrealBtt.Clicked += async(o, e) => {
                    string txt = await Clipboard.GetTextAsync();

                    string ytUrl = await ActionPopup.DisplayEntry(InputPopupResult.url, "https://youtu.be/", "Youtube link", confirmText : "Download");

                    if (!ytUrl.IsClean() || ytUrl == "Cancel")
                    {
                        return;
                    }
                    await YouTube.HandleDownload(ytUrl);
                };

                MyEpisodeResultCollection = new ObservableCollection <EpisodeResult>();
                BindingContext            = this;
                BackgroundColor           = Settings.BlackRBGColor;
                ChangeStorage();
            }
            catch (Exception _ex) {
                error(_ex);
            }
        }
コード例 #3
0
        public static async Task ShowUpdate(bool skipIntro = false)
        {
            if (Device.RuntimePlatform == Device.Android)
            {
                var recommendedArc = (App.AndroidVersionArchitecture)App.PlatformDep.GetArchitecture();

                string option = skipIntro ? "Download Update" : await ActionPopup.DisplayActionSheet($"App update {githubUpdateTag}", "Download Update", "Ignore this time", "Dont show this again");

                if (option == "Download Update")
                {
                    List <string> options = new List <string>()
                    {
                    };
                    var arcs = App.GetEnumList <App.AndroidVersionArchitecture>();
                    foreach (var ver in arcs)
                    {
                        options.Add(App.GetVersionPublicName(ver) + (recommendedArc == ver ? " (Recommended)" : " "));
                    }
                    string version = await ActionPopup.DisplayActionSheet("Download App Architecture", options.ToArray());

                    if (version == "Cancel" || version == "")
                    {
                        return;
                    }
                    foreach (var ver in arcs)
                    {
                        if (version.StartsWith(App.GetVersionPublicName(ver) + " "))
                        {
                            App.DownloadNewGithubUpdate(githubUpdateTag, ver);
                            break;
                        }
                    }
                }
                else if (option == "Dont show this again")
                {
                    Settings.ShowAppUpdate = false;
                }
            }
        }
コード例 #4
0
        async void WaitChangeChromeCast()
        {
            if (MainChrome.IsCastingVideo)
            {
                Device.BeginInvokeOnMainThread(() => {
                    OpenChromecastView(1, EventArgs.Empty);
                });
            }
            else
            {
                List <string> names = MainChrome.GetChromeDevicesNames();
                if (MainChrome.IsConnectedToChromeDevice)
                {
                    names.Add("Disconnect");
                }
                string a = await ActionPopup.DisplayActionSheet("Cast to", names.ToArray());                //await DisplayActionSheet("Cast to", "Cancel", MainChrome.IsConnectedToChromeDevice ? "Disconnect" : null, names.ToArray());

                if (a != "Cancel")
                {
                    MainChrome.ConnectToChromeDevice(a);
                }
            }
        }
コード例 #5
0
        public async void SelectSubtitleOption()
        {
            List <string> options = new List <string>();

            if (subtitles.Count == 0)
            {
                options.Add($"Download Subtitles ({Settings.NativeSubLongName})");
            }
            else
            {
                // if (subtitleIndex != -1) {
                // options.Add($"Turn {(HasSubtitlesOn ? "Off" : $"On ({subtitles[subtitleIndex].name})")}");
                //}
                if (HasSubtitlesOn)
                {
                    //if (subtitleIndex != -1) {
                    //  options.Add($"Turn off");
                    //}
                    options.Add($"Change Delay ({subtitleDelay} ms)");
                }
                options.Add("Select Subtitles");
            }
            options.Add("Download Subtitles");

            async Task UpdateSubtitles()
            {
                ActionPopup.StartIndeterminateLoadinbar("Loading Subtitles...");
                if (subtitleIndex != -1)
                {
                    await ChangeSubtitles(subtitles[subtitleIndex].data, subtitles[subtitleIndex].name, subtitleDelay);
                }
                else
                {
                    await ChangeSubtitles("", "", 0);
                }
                await ActionPopup.StopIndeterminateLoadinbar();
            }

            string action = await ActionPopup.DisplayActionSheet("Subtitles", options.ToArray());

            if (action == "Download Subtitles")
            {
                string subAction = await ActionPopup.DisplayActionSheet("Download Subtitles", subtitleNames);

                if (subAction != "Cancel")
                {
                    int index = subtitleNames.IndexOf(subAction);
                    PopulateSubtitle(subtitleShortNames[index], subAction);
                }
            }
            else if (action == "Select Subtitles")
            {
                List <string> subtitlesList = subtitles.Select(t => t.name).ToList();
                subtitlesList.Insert(0, "None");

                string subAction = await ActionPopup.DisplayActionSheet("Select Subtitles", subtitleIndex + 1, subtitlesList.ToArray());

                if (subAction != "Cancel")
                {
                    int setTo = subtitlesList.IndexOf(subAction) - 1;
                    if (setTo != subtitleIndex)
                    {
                        subtitleIndex  = setTo;
                        HasSubtitlesOn = subtitleIndex != -1;
                        await Task.Delay(100);
                        await UpdateSubtitles();
                    }
                }
            }
            else if (action == $"Download Subtitles ({Settings.NativeSubLongName})")
            {
                PopulateSubtitle();
            }
            else if (action.StartsWith("Turn off"))
            {
                subtitleIndex = -1;
                await UpdateSubtitles();

                // await MainChrome.ToggleSubtitles(!HasSubtitlesOn);
                HasSubtitlesOn = !HasSubtitlesOn;
            }
            else if (action.StartsWith("Change Delay"))
            {
                int del = await ActionPopup.DisplayIntEntry("ms", "Subtitle Delay", 50, false, subtitleDelay.ToString(), "Set Delay");

                if (del != -1)
                {
                    subtitleDelay = del;
                    await Task.Delay(100);
                    await UpdateSubtitles();
                }
            }
        }
コード例 #6
0
        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 });
        }
コード例 #7
0
        public Home()
        {
            InitializeComponent();
            baseImg.Source = App.GetImageSource("NoBookmarks.png");

            selectTabItems = new BorderView[] {
                HomeBtt, RelatedBtt, TopBtt, TrendingBtt,
            };
            selectTabLabels = new Label[] {
                HomeLbl, RelatedLbl, TopLbl, TrendingLbl,
            };
            FastTxtBtt.Clicked += async(o, e) => {
                string a = await ActionPopup.DisplayActionSheet("Clear watching", "Yes, clear currently watching", "No, dont clear currently watching");

                if (a.StartsWith('Y'))
                {
                    App.RemoveFolder(nameof(CachedCoreEpisode));
                    UpdateNextEpisode();
                }
            };
            ChangeSizeOfTabs();
            for (int i = 0; i < selectTabItems.Length; i++)
            {
                Commands.SetTap(selectTabItems[i], new Command((o) => {
                    int id          = int.Parse(o.ToString());
                    selectedTabItem = id;
                    ChangeSizeOfTabs();
                }));
                Commands.SetTapParameter(selectTabItems[i], i.ToString());
            }

            if (Settings.IS_TEST_BUILD)
            {
#pragma warning disable CS0162 // Unreachable code detected
                return;

#pragma warning restore CS0162 // Unreachable code detected
            }
            try {
                epView         = new MainEpisodeView();
                BindingContext = epView;

                BackgroundColor = Settings.BlackRBGColor;

                MovieTypePicker = new LabelList(MovieTypePickerBtt, genresNames)
                {
                    SelectedIndex = 0
                };

                MovieTypePicker.SelectedIndexChanged += (o, e) => {
                    ClearEpisodes(!IsRecommended);
                    if (IsRecommended)
                    {
                        CoreHelpers.Shuffle(iMDbTopList);
                        LoadMoreImages();
                    }
                    else
                    {
                        mainCore.PurgeThreads(21);
                        Fething = false;
                        GetFetch();
                    }
                };

                double lastScroll = 0;

                episodeView.Scrolled += (o, e) => {
                    MovieTypePickerBttScrollY -= lastScroll - e.ScrollY;
                    lastScroll = e.ScrollY;

                    if (MovieTypePickerBttScrollY > MovieTypePickerBttMinScrollY)
                    {
                        MovieTypePickerBttScrollY = MovieTypePickerBttMinScrollY;
                    }
                    else if (MovieTypePickerBttScrollY < 0)
                    {
                        MovieTypePickerBttScrollY = 0;
                    }

                    MovieTypePickerBtt.TranslationY = MovieTypePickerBttScrollY;

                    double maxY = episodeView.HeightRequest - episodeView.Height;
                    //print(maxY);
                    if (e.ScrollY >= maxY - 200)
                    {
                        LoadMoreImages();
                    }
                };


                if (Device.RuntimePlatform == Device.UWP)
                {
                    // BlueSeperator.IsVisible = false;
                    // BlueSeperator.IsEnabled = false;
                    OffBar.IsVisible = false;
                    OffBar.IsEnabled = false;
                }
                else
                {
                    OffBar.Source = App.GetImageSource("gradient.png"); OffBar.HeightRequest = 3; OffBar.HorizontalOptions = LayoutOptions.Fill; OffBar.ScaleX = 100; OffBar.Opacity = 0.3;
                }

                episodeView.VerticalScrollBarVisibility = Settings.ScrollBarVisibility;
            }
            catch (Exception _ex) {
                error(_ex);
            }

            /*
             * ImageScroller.Scrolled += (o, e) => {
             * double maxY = ImageScroller.ContentSize.Height - ImageScroller.Height;
             * if (e.ScrollY >= maxY - 200) {
             * LoadMoreImages();
             * }
             *
             * };*/
        }
コード例 #8
0
        public Download()
        {
            InitializeComponent();
            OffBar.Source = App.GetImageSource("gradient.png"); OffBar.HeightRequest = 3; OffBar.HorizontalOptions = LayoutOptions.Fill; OffBar.ScaleX = 100; OffBar.Opacity = 0.3; OffBar.TranslationY = 9;

            if (Settings.IS_TEST_BUILD)
            {
                return;
            }
            try {
                baseImg.Source = App.GetImageSource("NoDownloads.png");

                bool hasDownloads = App.GetKey("Settings", "hasDownloads", false);

                baseTxt.IsVisible = !hasDownloads;
                baseImg.IsVisible = !hasDownloads;

                /*
                 * RefreshView refresh = new RefreshView() { BackgroundColor = Color.Black, RefreshColor = Color.Blue, Command = RefreshCommand };
                 * refresh.SetBinding(RefreshView.IsRefreshingProperty, new Binding(nameof(IsRefreshing)));
                 * ScrollView scrollView = new ScrollView();
                 * scrollView.Content = episodeView;
                 * refresh.Content = episodeView;*/

                // ytBtt.Source = App.GetImageSource("round_movie_white_48dp.png");
                ytBtt.Source = App.GetImageSource("ytIcon.png");

                ytrealBtt.Clicked += async(o, e) => {
                    string txt = await Clipboard.GetTextAsync();

                    string ytUrl = await ActionPopup.DisplayEntry(InputPopupResult.url, "https://youtu.be/", "Youtube link", confirmText : "Download");

                    if (!ytUrl.IsClean() || ytUrl == "Cancel")
                    {
                        return;
                    }
                    await Device.InvokeOnMainThreadAsync(async() => {
                        //string ytUrl = t.Text;
                        Video v = null;
                        const string errorTxt = "Error Downloading YouTube Video";
                        try {
                            v = await YouTube.GetYTVideo(ytUrl);
                        }
                        catch (Exception) {
                            App.ShowToast(errorTxt);
                        }
                        if (v == null)
                        {
                            App.ShowToast(errorTxt);
                        }
                        else
                        {
                            try {
                                //   string dpath = YouTube.GetYTPath(v.Title);
                                var author = await YouTube.GetAuthorFromVideoAsync(v);
                                var data   = await YouTube.GetInfoAsync(v);
                                int id     = ConvertStringToInt(v.Id);


                                string vId = v.Id.Value;
                                var t      = mainCore.CreateThread(4);
                                mainCore.StartThread("Sponsorblock", () => {
                                    try {
                                        string _d = mainCore.DownloadString("https://sponsor.ajay.app/api/skipSegments?videoID=" + vId, t);
                                        if (_d != "")
                                        {
                                            var smgs = JsonConvert.DeserializeObject <List <YTSponsorblockVideoSegments> >(_d);
                                            App.SetKey("Sponsorblock", v.Id.Value.ToString(), smgs);
                                        }
                                    }
                                    catch (Exception) { }
                                });
                                double mb = App.ConvertBytesToAny(data.Size.TotalBytes, 5, 2);

                                ImageService.Instance.LoadUrl(v.Thumbnails.HighResUrl, TimeSpan.FromDays(30));                                 // CASHE IMAGE

                                DownloadHeader header = new DownloadHeader()
                                {
                                    movieType = MovieType.YouTube, id = author.Id, name = author.Title, hdPosterUrl = author.LogoUrl, posterUrl = author.LogoUrl, ogName = author.Title
                                };                                                                                                                                                                                                                                    //description = v.Description,hdPosterUrl=v.Thumbnails.HighResUrl, };//ConvertTitleToHeader(title);

                                string filePath = YouTube.DownloadVideo(data, v.Title, data, v, id, header, true);

                                //  YouTube.client.Videos.ClosedCaptions.GetManifestAsync().Result.Tracks.
                                // YouTube.client.Videos.ClosedCaptions.DownloadAsync(v.,)

                                App.ShowToast("YouTube download started");
                                App.SetKey(nameof(DownloadHeader), "id" + header.RealId, header);
                                App.SetKey(nameof(DownloadEpisodeInfo), "id" + id, new DownloadEpisodeInfo()
                                {
                                    dtype = DownloadType.YouTube, source = v.Url, description = v.Description, downloadHeader = header.RealId, episode = -1, season = -1, fileUrl = filePath, id = id, name = v.Title, hdPosterUrl = v.Thumbnails.HighResUrl
                                });
                                App.SetKey("DownloadIds", id.ToString(), id);
                                await YouTube.DownloadSubtitles(v, filePath.Replace(".mp4", ".srt"));
                            }
                            catch (Exception _ex) {
                                print("MAINERROR:: " + _ex);
                                App.ShowToast(errorTxt);
                            }
                        }
                    });
                };

                MyEpisodeResultCollection = new ObservableCollection <EpisodeResult>();
                BindingContext            = this;
                BackgroundColor           = Settings.BlackRBGColor;
                ChangeStorage();
            }
            catch (Exception _ex) {
                error(_ex);
            }
        }