protected override void OnDestroy()
 {
     if (AppState.UserIsLoggedIn)
     {
         AppSettings.UserWasLoggedInLastAppClose = true;
     }
     else
     {
         AppSettings.UserWasLoggedInLastAppClose = false;
     }
     try
     {
         //UnregisterReceiver(ForegroundReceiver); //@TODO check what this does
         //
         AppState.NotificationStartedApp = false;
         MainPlaybackSticky.NotificationShouldPlayInBkgrd = false; // set this to false if user closes the app so that future notification clicks will restart the app
     }
     catch { }
     ViewPager.PageSelected -= ViewPager_PageSelected;
     NavigationView.NavigationItemSelected -= NavigationView_NavigationItemSelected;
     try { MainPlaybackSticky.ExternalStopForeground();
           AppState.ForeNote = null; }
     catch (Exception ex) { }
     try
     {
         foreach (var wv in PlaystateManagement.WebViewIdDictionary)
         {
             wv.Value.LoadUrl(JavascriptCommands._jsPauseVideo);
         }
     }
     catch { }
     MainPlaybackSticky.AppIsMovingIntoBackgroundAndStreaming = false;
     base.OnDestroy();
 }
Exemple #2
0
        public async Task <VideoCard> LoadVideoDetailFromVideoCard(View view, VideoCard vc = null, string url = null,
                                                                   LinearLayout container  = null, RelativeLayout relContainer = null, int id = -1)
        {
            if (vc != null)
            {
                GetVideoDetailViewTitles(id, view.FindViewById <TextView>(Resource.Id.videoDetailTitleTextView))
                .GetValueOrDefault(id).Text = vc?.Title;
                view.FindViewById <TextView>(Resource.Id.videoDetailCreatorName).Text = vc?.CreatorName;
            }
            var response = await ExtWebInterface.HttpClient.GetAsync(Request.GetFullRequest(vc.Link));

            if (relContainer != null)
            {
                SwapView(view, null, relContainer);
            }
            else if (container != null)
            {
                SwapView(view, container, null);
            }
            var html = await response.Content.ReadAsStringAsync();

            try
            {
                var doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(html);

                if (doc != null)
                {
                    var vidurl = doc.DocumentNode.SelectSingleNode("//source").GetAttributeValue("src", "");
                    var link   = Android.Net.Uri.Parse(doc.DocumentNode.SelectSingleNode("//source").GetAttributeValue("src", ""));
                    Fragments.CommonFrag.GetFragmentById(id).VideoView        = GetVideoViewById(id, view.FindViewById <VideoView>(Resource.Id.videoView));
                    Fragments.CommonFrag.GetFragmentById(id).VideoView.Click += Fragments.CommonFrag.GetFragmentById(id).VideoView_OnClick;
                    MainPlaybackSticky.InitializePlayer(id, null, MainActivity.GetMainContext(), vidurl);
                    SetLayoutParameters(view.FindViewById <VideoView>(Resource.Id.videoView));
                    ISurfaceHolder holder = view.FindViewById <VideoView>(Resource.Id.videoView).Holder;
                    holder.AddCallback(this);
                    MainPlaybackSticky.InitializeMediaController(view.FindViewById <VideoView>(Resource.Id.videoView), vc.FragmentId);
                    GetPostPageLoadObjects(view, doc, id);
                }
            } catch (Exception ex) { }  return(null);
        }
        public static async void StartStickyAfterDelay(int d = 3000, bool userRequestedStickyBackground = false, int idOverride = -1)
        {
            if (idOverride != -1)
            {
            }
            else
            {
                idOverride = CommonFrag.GetFragmentById(-1, null, ViewPager.CurrentItem).Wv.Id;
            }
            if (userRequestedStickyBackground)
            {
                MainPlaybackSticky.StartVideoInBkgrd(idOverride);
                CommonFrag.GetFragmentById(-1, null, ViewPager.CurrentItem).Wv.StickyBackgroundRequested = true;
            }
            await Task.Delay(d);

            if (MainPlaybackSticky.IsInBkGrd() && PlaystateManagement.WebViewPlayerIsStreaming && AppSettings.AutoPlayOnMinimized != "off")
            {
                if (AppState.ForeNote == null)
                {
                    MainPlaybackSticky.StartForeground(BitChute.ExtNotifications.BuildPlayControlNotification(), true, true);
                }
            }
        }
 /// <summary>
 /// Requests the app start sticky background playback service
 /// and move into background, regardless of playstate
 /// </summary>
 public static void ForceAppIntoStickyBackground()
 {
     UserRequestedStickyBackground = true;
     MainPlaybackSticky.StartForeground(BitChute.ExtNotifications.BuildPlayControlNotification(), true, true);
     Instance.MoveTaskToBack(true);
 }
 public void OnClick(View v)
 {
     MainPlaybackSticky.SkipToNext(null);
 }
 public void OnClick(View v)
 {
     MainPlaybackSticky.SkipToPrev();
 }
Exemple #7
0
        public static async Task <List <CustomNotification> > DecodeHtmlNotifications(string html, bool fromInitialAppLoad = false, HtmlAgilityPack.HtmlDocument doc = null)
        {
            await Task.Run(() =>
            {
                try
                {
                    doc = new HtmlAgilityPack.HtmlDocument();
                    doc.LoadHtml(html);

                    NotificationTextList.Clear();
                    NotificationTypes.Clear();
                    NotificationLinks.Clear();

                    if (doc != null)
                    {
                        foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//title"))
                        {
                            var _tagContents = node.InnerText;
                            if (_tagContents.Contains("Notifications"))
                            {
                                AppState.UserIsLoggedIn = true;
                            }
                            else
                            {
                                AppState.UserIsLoggedIn = false;
                                return;
                            }
                        }
                    }
                }
                catch
                {
                } try {
                    foreach (HtmlNode node in doc.DocumentNode.SelectNodes(".//span[@class='notification-target']"))
                    {
                        //&#39; <<< '   ... &amp; <<< & "&#x27; '
                        var _tagContents = node.InnerText;
                        _tagContents     = _tagContents.Replace(@"&#39;", @"'")
                                           .Replace(@"&#x27;", @"'")
                                           .Replace(@"&amp;", @"&")
                                           .Replace(@"&quot;", "\"");
                        NotificationTextList.Add(_tagContents);
                    }

                    foreach (HtmlNode node in doc.DocumentNode.SelectNodes(".//span[@class='notification-detail']"))
                    {
                        var _tagContents = node.InnerText;
                        NotificationTypes.Add(_tagContents.Split('-')[0]);
                    }

                    foreach (HtmlNode node in doc.DocumentNode.SelectNodes(".//a[@class='notification-view']"))
                    {
                        var _tagContents = "https://bitchute.com" + node.Attributes["href"].Value.ToString();

                        NotificationLinks.Add(_tagContents);
                    }
                    _currentListIndex = 0;
                    CustomNoteList.Clear();

                    foreach (var nt in NotificationTypes)
                    {
                        var note = new CustomNotification();

                        note.NoteType = nt.ToString();
                        note.NoteLink = NotificationLinks[_currentListIndex].ToString();
                        note.NoteText = NotificationTextList[_currentListIndex].ToString();
                        CustomNoteList.Add(note);
                        _currentListIndex++;
                    }
                    CustomNoteList.Reverse();
                }
                catch (Exception ex) { Console.WriteLine(ex.Message); }
                if (fromInitialAppLoad)
                {
                    if (CustomNoteList.Count > 0)
                    {
                        MainPlaybackSticky.StartNotificationLoop(30000, CustomNoteList);
                        ExtNotifications.NotificationHttpRequestInProgress = false;
                        return;
                    }
                    else
                    {
                        ExtNotifications.NotificationHttpRequestInProgress = false;
                        MainPlaybackSticky.StartNotificationLoop(30000);
                    }
                }
                ExtNotifications.NotificationHttpRequestInProgress = false;
            });

            return(CustomNoteList);
        }