Exemple #1
0
        public static async Task <string> GetCommonCss(string sourceUrl, bool process, bool setNext = true, string videoCssUrl = "", string bootstrapCssUrl = "")
        {
            string c = await ExtWebInterface.GetHtmlTextFromUrl(sourceUrl);

            c = await GetOverrideCss(c);

            if (videoCssUrl != "")
            {
                string videoCss = await ExtWebInterface.GetTextResponseWithGenericClient(videoCssUrl);
                await GetVideoCss(videoCss);
            }
            if (bootstrapCssUrl != "")
            {
                string bootstrapCss = await ExtWebInterface.GetTextResponseWithGenericClient(bootstrapCssUrl);
                await GetBootStrapCss(bootstrapCss);
            }
            if (setNext)
            {
                //await GetSearchCss(SearchCssUrl);
                await GetFeedCommonCss();
                await GetMyChannelCommonCss();
                await GetSettingsCommonCss();
            }
            CustomCssReadyForRead = true;
            return(c);
        }
Exemple #2
0
        /// <summary>
        /// initializes the mediaplayer object on tab of your choice.
        /// if the mediaplayer is already instantiated then it gets reset for new playback
        /// </summary>
        /// <param name="mp"></param>
        /// <returns></returns>
        public static async Task <MediaPlayer> InitializePlayer(int id, Android.Net.Uri uri, Context ctx, string mediaPath = null)
        {
            if (ctx == null)
            {
                ctx = Android.App.Application.Context;
            }
            var cookieHeader = ExtWebInterface.GetCookieDictionary();

            if (!MainPlaybackSticky.MediaPlayerDictionary.ContainsKey(id))
            {
                MainPlaybackSticky.MediaPlayerDictionary.Add(id, new MediaPlayer());
            }
            else if (MediaPlayerDictionary[id] == null)
            {
                MediaPlayerDictionary[id] = new MediaPlayer();
            }
            else
            {
                MediaPlayerDictionary[id].Reset();
                MediaPlayerDictionary[id].Release();

                MediaPlayerDictionary[id] = null;
                MediaPlayerDictionary[id] = new MediaPlayer();
            }
            if (mediaPath != null)
            {
                await MediaPlayerDictionary[id].SetDataSourceAsync(mediaPath);
            }
            else
            {
                //await MediaPlayerDictionary[id].SetDataSourceAsync(ctx, uri);
                await MediaPlayerDictionary[id].SetDataSourceAsync(Android.App.Application.Context, uri, cookieHeader);
            }
            MediaPlayerDictionary[id].PrepareAsync();

            PlaystateChanged.Invoke(new PlaystateEventArgs(-1, false, false, false, id, false, false, true, id));
            MediaPlayerDictionary[id].SetOnSeekCompleteListener(ExtStickyServ);

            //Wake mode will be partial to keep the CPU still running under lock screen
            MediaPlayerDictionary[id].SetWakeMode(Android.App.Application.Context, WakeLockFlags.Partial);

            //When we have prepared the song start playback
            MediaPlayerDictionary[id].Prepared += (sender, args) => ExtStickyServ.Play(id, PlayerType.NativeMediaPlayer);

            //When we have reached the end of the song stop ourselves, however you could signal next track here.
            MediaPlayerDictionary[id].Completion += (sender, args) => OnVideoFinished(false, id);

            MediaPlayerDictionary[id].Error += (sender, args) =>
            {
                //playback error
                Console.WriteLine("Error in playback resetting: " + args.What);
                Stop();//this will clean up and reset properly.
            };

            return(MediaPlayerDictionary[id]);
        }
 public static async void InitializeVideoDownload(string videoLink)
 {
     if (!VideoDownloadInProgress)
     {
         try
         {
             ViewHelpers.Tab3.DownloadProgressTextView.Text = "Getting permissions";
             if (!FileBrowser.GetExternalPermissions())
             {
                 return;
             }
             VideoDownloadInProgress = true;
             VideoDownloader _vd = new VideoDownloader();
             if (videoLink != null && videoLink != "")
             {
                 ViewHelpers.Tab3.DownloadProgressTextView.Text = "Getting video link";
                 Task <string>    rawHtmlTask   = ExtWebInterface.GetHtmlTextFromUrl(videoLink);
                 var              html          = await rawHtmlTask;
                 Task <VideoCard> videoCardTask = _vd.DecodeHtmlVideoSource(html);
                 var              vidCard       = await videoCardTask;
                 if ((vidCard).VideoUri.AbsolutePath == "" ||
                     (vidCard).VideoUri.AbsolutePath == null)
                 {
                     ViewHelpers.Tab3.DownloadProgressTextView.Text = LanguageSupport.Main.IO.VideoSourceMissing();
                     Toast.MakeText(Android.App.Application.Context, LanguageSupport.Main.IO.VideoSourceMissing(), ToastLength.Long);
                     VideoDownloadInProgress = false;
                     return;
                 }
                 Task <bool> videoDownloadComplete = _vd.DownloadAndSaveVideo(vidCard);
                 await       videoDownloadComplete;
             }
             else
             {
                 await _vd.DownloadAndSaveVideo(null);
             }
         }
         catch (Exception ex)
         {
             VideoDownloadInProgress = false;
             ViewHelpers.Tab3.DownloadProgressTextView.Text = $"An error occured : {ex.Message} ";
         }
     }
     else
     {
         try
         {
             ViewHelpers.Tab3.DownloadProgressTextView.Text = "Video download already in progress, stop it first";
             Toast.MakeText(Android.App.Application.Context, "Video download already in progress, stop it first", ToastLength.Long);
         }
         catch { }
     }
 }
Exemple #4
0
            public async override void Run()
            {
                if (AppSettings.Notifying)
                {
                    try
                    {
                        if (!ExtNotifications.NotificationHttpRequestInProgress && !_notificationStackExecutionInProgress)
                        {
                            _notificationStackExecutionInProgress = true;
                            var noteText = await ExtWebInterface.GetNotificationText("https://www.bitchute.com/notifications/");

                            var noteList = await ExtNotifications.DecodeHtmlNotifications(noteText);

                            ExtNotifications.SendNotifications(noteList);
                            _notificationStackExecutionInProgress = false;
                        }
                    }
                    catch {   }
                }
            }
Exemple #5
0
        public static async Task <string> GetSearchCss(string url = null)
        {
            if (SearchCss == "" || SearchCss == null)
            {
                SearchCss = await ExtWebInterface.GetHtmlTextFromUrl(url);
            }

            Task <string> fct = Task.FromResult <string>(SearchCss
                                                         .Replace(@"""", @"'")
                                                         .Replace(Strings.VidResultImageOrg, Strings.VidResultImageNew)
                                                         .Replace(Strings.VidResultImageContOrg, Strings.VidResultImageContNew)
                                                         .Replace(Strings.ResultListImgContOrg, Strings.ResultListImgContNew)
                                                         .Replace(Strings.VidResultTextOrg, Strings.VidResultTextNew)
                                                         .Replace(Strings.VidResultTextContainerOrg, Strings.VidResultTextContainerNew)
                                                         .Replace("270px", "100%")
                                                         .Replace(@"[max-width~='592px']", "")
                                                         );

            SearchCss = await fct; return(SearchCss);
        }
Exemple #6
0
        /// <summary>
        /// starts/restarts the notifications,
        /// takes a ms int as the delay for starting,
        /// if this is called with no delay TheFragment5 sometimes
        /// is null or has issues when it's methods are called
        /// immediately after the app initially loads.
        ///
        /// Once the notifications are started this loop returns
        /// and invokes a long running TimerTask
        /// The reason for this is because the loop is
        /// stopping after a while so I am moving to a timer
        /// system for the long running task to see if that
        /// will prevent the loop from breaking.
        /// </summary>
        public static async void StartNotificationLoop(int delay, List <ExtNotifications.CustomNotification> initialNotifications = null, bool afterLogin = false)
        {
            NotificationLoopStartTimesInvoked++;
            //wait on a delay so that the cookie is ready when we make
            //httprequest for the notifications
            await Task.Delay(delay);

            //use a while loop to start the notifications
            //they move over to a service timer eventually to prevent the loop from breaking
            while (AppSettings.Notifying)
            {
                if (!ExtNotifications.NotificationHttpRequestInProgress && !_notificationStackExecutionInProgress && AppState.UserIsLoggedIn)
                {
                    if (initialNotifications == null)
                    {
                        _notificationStackExecutionInProgress = true;
                        var noteText = await ExtWebInterface.GetNotificationText("https://www.bitchute.com/notifications/");

                        var noteList = await ExtNotifications.DecodeHtmlNotifications(noteText);

                        if (noteList.Count > 0)
                        {
                            ExtNotifications.SendNotifications(noteList);
                            NotificationsHaveBeenSent = true;
                        }
                        _notificationStackExecutionInProgress = false;
                    }
                    else
                    {
                        ExtNotifications.SendNotifications(initialNotifications);
                    }
                }
                if (NotificationsHaveBeenSent)
                {
                    //check to make sure the timer isn't already started or the app will crash
                    if (!MainPlaybackSticky._notificationLongTimerSet)
                    {
                        try
                        {
                            //after the initial notifications are sent, start the long running service timer task
                            _timer.ScheduleAtFixedRate(_extTimerTask, 500000, 780000); // 780000
                            _notificationLongTimerSet = true;
                            return;
                        }
                        catch { }
                    }
                }
                if (NotificationLoopStartTimesInvoked > 1)
                {
                    NotificationLoopStartTimesInvoked--; break;
                }
                else if (!AppState.UserIsLoggedIn)
                {
                    await Task.Delay(220000);
                }
                //user is logged in but has not yet received a notification
                else
                {
                    await Task.Delay(220000);
                }
            }
        }
 public static void OnPostLogout(LogoutEventArgs e)
 {
     ExtWebInterface.ClearLoginCredentials();
 }