コード例 #1
0
        private void ShowNotify(string strHeading, string description, string imgFileName)
        {
            GUIDialogNotify dlgYesNo = (GUIDialogNotify)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_NOTIFY);

            dlgYesNo.SetHeading(strHeading);
            dlgYesNo.SetText(description);
            dlgYesNo.SetImage(imgFileName);
            dlgYesNo.DoModal(GUIWindowManager.ActiveWindow);
        }
コード例 #2
0
        void showDialog(string message)
        {
            GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);

            if (dlg != null)
            {
                dlg.Reset();
                dlg.SetImage(pluginIconPath);
                dlg.SetHeading("Airplay Error");
                dlg.SetText(message);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }
        }
コード例 #3
0
        public void ShowNotifyDialog(int timeOut, string header, string icon, string text, Helper.PLUGIN_NOTIFY_WINDOWS notifyType)
        {
            try {
                GUIWindow guiWindow = GUIWindowManager.GetWindow((int)notifyType);
                switch (notifyType)
                {
                default:
                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_AUTO:
                    if (text.Length <= 60)
                    {
                        ShowNotifyDialog(timeOut, header, icon, text, Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_NOTIFY);
                    }
                    else
                    {
                        ShowNotifyDialog(timeOut, header, icon, text, Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_TEXT);
                    }
                    break;

                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_NOTIFY:
                    GUIDialogNotify notifyDialog = (GUIDialogNotify)guiWindow;
                    notifyDialog.Reset();
                    notifyDialog.TimeOut = timeOut;
                    notifyDialog.SetImage(icon);
                    notifyDialog.SetHeading(header);
                    notifyDialog.SetText(text);
                    notifyDialog.DoModal(GUIWindowManager.ActiveWindow);
                    break;

                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_OK:
                    GUIDialogOK okDialog = (GUIDialogOK)guiWindow;
                    okDialog.Reset();
                    okDialog.SetHeading(header);
                    okDialog.SetLine(1, (text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries))[0]);
                    okDialog.DoModal(GUIWindowManager.ActiveWindow);
                    break;

                case Helper.PLUGIN_NOTIFY_WINDOWS.WINDOW_DIALOG_TEXT:
                    GUIDialogText textDialog = (GUIDialogText)guiWindow;
                    textDialog.Reset();
                    try {
                        textDialog.SetImage(icon);
                    } catch (Exception e) { Debug.WriteLine(e.ToString()); }
                    textDialog.SetHeading(header);
                    textDialog.SetText(text);
                    textDialog.DoModal(GUIWindowManager.ActiveWindow);
                    break;
                }
            } catch (Exception ex) {
                Log.Error(ex);
            }
        }
コード例 #4
0
ファイル: GUIUtils.cs プロジェクト: ncmilhouse/IMDbPlus
        /// <summary>
        /// Displays a notification dialog.
        /// </summary>
        public static void ShowNotifyDialog(string heading, string text, string image, string buttonText, int timeout)
        {
            if (GUIGraphicsContext.form.InvokeRequired)
            {
                ShowNotifyDialogDelegate d = ShowNotifyDialog;
                GUIGraphicsContext.form.Invoke(d, heading, text, image, buttonText, timeout);
                return;
            }

            GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);

            if (pDlgNotify == null)
            {
                return;
            }

            try
            {
                pDlgNotify.Reset();
                pDlgNotify.SetHeading(heading);
                pDlgNotify.SetImage(image);
                pDlgNotify.SetText(text);
                if (timeout >= 0)
                {
                    pDlgNotify.TimeOut = timeout;
                }

                foreach (GUIControl item in pDlgNotify.Children)
                {
                    if (item is GUIButtonControl)
                    {
                        GUIButtonControl btn = (GUIButtonControl)item;
                        if (btn.GetID == 4 && !string.IsNullOrEmpty(buttonText) && !string.IsNullOrEmpty(btn.Label))
                        {
                            // Only if ID is 4 and we have our custom text and if button already has label (in case the skin "hides" the button by emptying the label)
                            btn.Label = buttonText;
                        }
                    }
                }

                pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
            }
            finally
            {
                if (pDlgNotify != null)
                {
                    pDlgNotify.ClearAll();
                }
            }
        }
コード例 #5
0
        void ShowOptionsForSite(OnlineVideosWebservice.Site site)
        {
            SiteSettings localSite      = null;
            int          localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(site.Name, out localSite);

            GUIDialogMenu dlgSel = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            dlgSel.ShowQuickNumbers = false;
            if (dlgSel != null)
            {
                dlgSel.Reset();
                dlgSel.SetHeading(Translation.Instance.Actions);

                if (localSiteIndex == -1)
                {
                    if (site.State != OnlineVideosWebservice.SiteState.Broken)
                    {
                        dlgSel.Add(Translation.Instance.AddToMySites);
                    }
                }
                else
                {
                    if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 2 && site.State != OnlineVideosWebservice.SiteState.Broken)
                    {
                        dlgSel.Add(Translation.Instance.UpdateMySite);
                        dlgSel.Add(Translation.Instance.UpdateMySiteSkipCategories);
                    }
                    dlgSel.Add(Translation.Instance.RemoveFromMySites);
                }

                if (GUI_infoList.Count > 1)
                {
                    dlgSel.Add(Translation.Instance.RemoveAllFromMySites);
                    dlgSel.Add(Translation.Instance.UpdateAll);
                    dlgSel.Add(Translation.Instance.UpdateAllSkipCategories);
                }

                if (!string.IsNullOrEmpty(site.Owner_FK) && localSiteIndex >= 0) // !only local && ! only global
                {
                    dlgSel.Add(Translation.Instance.ShowReports);
                    if (site.State != OnlineVideosWebservice.SiteState.Broken)
                    {
                        dlgSel.Add(Translation.Instance.ReportBroken);
                    }
                }
            }
            dlgSel.DoModal(GUIWindowManager.ActiveWindow);
            if (dlgSel.SelectedId == -1)
            {
                return;                          // ESC used, nothing selected
            }
            if (dlgSel.SelectedLabelText == Translation.Instance.AddToMySites ||
                dlgSel.SelectedLabelText == Translation.Instance.UpdateMySite ||
                dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories)
            {
                if (CheckOnlineVideosVersion())
                {
                    Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(
                        () =>
                    {
                        bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites(null, new List <OnlineVideosWebservice.Site> {
                            site
                        }, false,
                                                                                   dlgSel.SelectedLabelText == Translation.Instance.UpdateMySiteSkipCategories);
                        if (updateResult == true)
                        {
                            newDllsDownloaded = true;
                        }
                        else if (updateResult == null)
                        {
                            newDataSaved = true;
                        }
                        return(updateResult != false);
                    },
                        (success, result) =>
                    {
                        if (success && (bool)result)
                        {
                            SiteImageExistenceCache.UnCacheImageForSite(site.Name);
                            RefreshDisplayedOnlineSites();
                        }
                    },
                        Translation.Instance.GettingSiteXml, true);
                }
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.UpdateAll ||
                     dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories)
            {
                if (CheckOnlineVideosVersion())
                {
                    GUIDialogProgress dlgPrgrs = PrepareProgressDialog(Translation.Instance.FullUpdate);
                    new System.Threading.Thread(delegate()
                    {
                        bool?updateResult = OnlineVideos.Sites.Updater.UpdateSites((m, p) =>
                        {
                            if (dlgPrgrs != null)
                            {
                                if (!string.IsNullOrEmpty(m))
                                {
                                    dlgPrgrs.SetLine(1, m);
                                }
                                if (p != null)
                                {
                                    dlgPrgrs.SetPercentage(p.Value);
                                }
                                return(dlgPrgrs.ShouldRenderLayer());
                            }
                            else
                            {
                                return(true);
                            }
                        }, GUI_infoList.ListItems.Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList(), dlgSel.SelectedLabelText == Translation.Instance.UpdateAllSkipCategories);
                        if (updateResult == true)
                        {
                            newDllsDownloaded = true;
                        }
                        else if (updateResult == null)
                        {
                            newDataSaved = true;
                        }
                        if (updateResult != false)
                        {
                            SiteImageExistenceCache.ClearCache();
                        }
                        if (dlgPrgrs != null)
                        {
                            dlgPrgrs.Close();
                        }
                        GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) => { RefreshDisplayedOnlineSites(); return(0); }, 0, 0, null);
                    })
                    {
                        Name = "OVSelectUpdate", IsBackground = true
                    }.Start();
                }
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveFromMySites)
            {
                OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex);
                OnlineVideoSettings.Instance.SaveSites();
                newDataSaved = true;
                RefreshDisplayedOnlineSites(GUI_infoList.SelectedListItemIndex);
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.RemoveAllFromMySites)
            {
                bool needRefresh = false;
                foreach (var siteToRemove in GUI_infoList.ListItems.Where(g => g.IsPlayed).Select(g => g.TVTag as OnlineVideosWebservice.Site).ToList())
                {
                    localSiteIndex = OnlineVideoSettings.Instance.GetSiteByName(siteToRemove.Name, out localSite);
                    if (localSiteIndex >= 0)
                    {
                        OnlineVideoSettings.Instance.RemoveSiteAt(localSiteIndex);
                        needRefresh = true;
                    }
                }
                if (needRefresh)
                {
                    OnlineVideoSettings.Instance.SaveSites();
                    newDataSaved = true;
                    RefreshDisplayedOnlineSites();
                }
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.ShowReports)
            {
                Gui2UtilConnector.Instance.ExecuteInBackgroundAndCallback(
                    () =>
                {
                    OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService();
                    return(ws.GetReports(site.Name));
                },
                    (success, result) =>
                {
                    if (success)
                    {
                        OnlineVideosWebservice.Report[] reports = result as OnlineVideosWebservice.Report[];

                        if (reports == null || reports.Length == 0)
                        {
                            GUIDialogNotify dlg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                            if (dlg != null)
                            {
                                dlg.Reset();
                                dlg.SetImage(SiteImageExistenceCache.GetImageForSite("OnlineVideos", type: "Icon"));
                                dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                                dlg.SetText(Translation.Instance.NoReportsForSite);
                                dlg.DoModal(GUIWindowManager.ActiveWindow);
                            }
                        }
                        else
                        {
                            selectedSite = site.Name;
                            GUIControl.ClearControl(GetID, GUI_infoList.GetID);

                            Array.Sort(reports, new Comparison <OnlineVideosWebservice.Report>(delegate(OnlineVideosWebservice.Report a, OnlineVideosWebservice.Report b)
                            {
                                return(b.Date.CompareTo(a.Date));
                            }));

                            foreach (OnlineVideosWebservice.Report report in reports)
                            {
                                string shortMsg            = report.Message.Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " ");
                                GUIListItem loListItem     = new GUIListItem(shortMsg.Length > 44 ? shortMsg.Substring(0, 40) + " ..." : shortMsg);
                                loListItem.TVTag           = report;
                                loListItem.Label2          = report.Type.ToString();
                                loListItem.Label3          = report.Date.ToString("g", OnlineVideoSettings.Instance.Locale);
                                loListItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(OnReportSelected);
                                GUI_infoList.Add(loListItem);
                            }
                            GUIControl.SelectItemControl(GetID, GUI_infoList.GetID, 0);
                            GUIPropertyManager.SetProperty("#itemcount", GUI_infoList.Count.ToString());
                            GUIPropertyManager.SetProperty("#itemtype", Translation.Instance.Reports);
                        }
                    }
                }, Translation.Instance.GettingReports, true);
            }
            else if (dlgSel.SelectedLabelText == Translation.Instance.ReportBroken)
            {
                if (CheckOnlineVideosVersion())
                {
                    if ((site.LastUpdated - localSite.LastUpdated).TotalMinutes > 1)
                    {
                        GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                        if (dlg != null)
                        {
                            dlg.Reset();
                            dlg.SetHeading(site.Name);
                            dlg.SetLine(1, Translation.Instance.PleaseUpdateLocalSite);
                            dlg.DoModal(GUIWindowManager.ActiveWindow);
                        }
                    }
                    else
                    {
                        string userReason = "";
                        if (GUIOnlineVideos.GetUserInputString(ref userReason, false))
                        {
                            if (userReason.Length < 15)
                            {
                                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                                if (dlg != null)
                                {
                                    dlg.Reset();
                                    dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                                    dlg.SetLine(1, Translation.Instance.PleaseEnterDescription);
                                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                                }
                            }
                            else
                            {
                                OnlineVideosWebservice.OnlineVideosService ws = new OnlineVideosWebservice.OnlineVideosService();
                                string      message = "";
                                bool        success = ws.SubmitReport(site.Name, userReason, OnlineVideosWebservice.ReportType.Broken, out message);
                                GUIDialogOK dlg     = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK);
                                if (dlg != null)
                                {
                                    dlg.Reset();
                                    dlg.SetHeading(PluginConfiguration.Instance.BasicHomeScreenName);
                                    dlg.SetLine(1, success ? Translation.Instance.Done : Translation.Instance.Error);
                                    dlg.SetLine(2, message);
                                    dlg.DoModal(GUIWindowManager.ActiveWindow);
                                }
                                if (success)
                                {
                                    // reload online sites
                                    OnlineVideos.Sites.Updater.GetRemoteOverviews(true);
                                    RefreshDisplayedOnlineSites();
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        public static void OnGlobalMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            /// <summary>
            /// We need to stop the player if our livestream ends unexpectedly.
            /// If the stream stopped for a recording, we show it in a message.
            /// Without this mediaportal can hang,crash (c++ error in tsreader).
            /// </summary>
            case GUIMessage.MessageType.GUI_MSG_STOP_SERVER_TIMESHIFTING:
            {
                Log.Debug("TvHome: GUI_MSG_STOP_SERVER_TIMESHIFTING, param1 = {0}", message.Param1);
                if (PluginMain.Navigator.IsLiveStreamOn)
                {
                    if (message.Param1 == 4321)        //fired by eventlistener
                    {
                        LiveStream liveStream          = message.Object as LiveStream;
                        LiveStream navigatorLiveStream = PluginMain.Navigator.LiveStream;
                        Channel    channel             = PluginMain.Navigator.CurrentChannel;

                        if (liveStream != null && channel != null &&
                            navigatorLiveStream.TimeshiftFile == liveStream.TimeshiftFile &&
                            liveStream.StreamStartedTime == navigatorLiveStream.StreamStartedTime)
                        {
                            if (g_Player.Playing && (g_Player.IsTV || g_Player.IsRadio))
                            {
                                g_Player.Stop();
                                Log.Info("TvHome: our live stream seems to be aborted, stop the playback now");
                            }

                            string text = GUILocalizeStrings.Get(1516);
                            if (message.Label == LiveStreamAbortReason.RecordingStartedOnCard.ToString())
                            {
                                text = GUILocalizeStrings.Get(1513);
                            }
                            text = text.Replace("\\r", " ");

                            string heading = string.Empty;
                            string tvlogo  = string.Empty;
                            using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                            {
                                if (channel.ChannelType == ChannelType.Television)
                                {
                                    heading = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName;         //my tv
                                }
                                else
                                {
                                    heading = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName;         //my radio
                                }
                                tvlogo = Utility.GetLogoImage(channel, SchedulerAgent);
                            }

                            GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                            if (pDlgNotify != null)
                            {
                                pDlgNotify.Reset();
                                pDlgNotify.ClearAll();
                                pDlgNotify.SetHeading(heading);
                                if (!string.IsNullOrEmpty(text))
                                {
                                    pDlgNotify.SetText(text);
                                }
                                pDlgNotify.SetImage(tvlogo);
                                pDlgNotify.TimeOut = 5;
                                Utils.PlaySound("notify.wav", false, true);
                                pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                            }
                        }
                    }
                    else        //fired by mp player
                    {
                        PluginMain.Navigator.AsyncStopLiveStream();
                    }
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_NOTIFY_REC:
            {
                if (_enableRecNotification)
                {
                    Log.Debug("TvHome: GUI_MSG_NOTIFY_REC");
                    string    head      = string.Empty;
                    string    logo      = string.Empty;
                    Recording recording = message.Object as Recording;

                    if (message.Param1 == 1)
                    {
                        head = GUILocalizeStrings.Get(1446);
                    }
                    else
                    {
                        head = GUILocalizeStrings.Get(1447);
                    }

                    using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                    {
                        Channel chan = SchedulerAgent.GetChannelById(recording.ChannelId);
                        logo = Utility.GetLogoImage(chan, SchedulerAgent);
                    }

                    string _text = String.Format("{0} {1}-{2}",
                                                 recording.Title,
                                                 recording.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                                 recording.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                    GUIDialogNotify DlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    if (DlgNotify != null)
                    {
                        DlgNotify.Reset();
                        DlgNotify.ClearAll();
                        DlgNotify.SetHeading(head);
                        if (!string.IsNullOrEmpty(_text))
                        {
                            DlgNotify.SetText(_text);
                        }
                        DlgNotify.SetImage(logo);
                        DlgNotify.TimeOut = 5;
                        if (_playNotifyBeep)
                        {
                            Utils.PlaySound("notify.wav", false, true);
                        }
                        DlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                    }
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_NOTIFY_TV_PROGRAM:
            {
                Log.Debug("TvHome: GUI_MSG_NOTIFY_TV_PROGRAM");
                TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO);
                UpcomingProgram     prog        = message.Object as UpcomingProgram;
                if (tvNotifyDlg == null || prog == null)
                {
                    return;
                }

                tvNotifyDlg.Reset();
                if (prog.StartTime > DateTime.Now)
                {
                    int minUntilStart = (prog.StartTime - DateTime.Now).Minutes;
                    if (minUntilStart > 1)
                    {
                        tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1018), minUntilStart));
                    }
                    else
                    {
                        tvNotifyDlg.SetHeading(1019);         // Program is about to begin
                    }
                }
                else
                {
                    tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1206), (DateTime.Now - prog.StartTime).Minutes.ToString()));
                }

                string description = GUILocalizeStrings.Get(736);
                using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent())
                {
                    try
                    {
                        if (prog.GuideProgramId.HasValue)
                        {
                            GuideProgram Program = tvGuideAgent.GetProgramById(prog.GuideProgramId.Value);
                            description = Program.CreateCombinedDescription(false);
                        }
                    }
                    catch { }
                }

                tvNotifyDlg.SetLine(1, prog.Title);
                tvNotifyDlg.SetLine(2, description);
                tvNotifyDlg.SetLine(4, String.Format(GUILocalizeStrings.Get(1207), prog.Channel.DisplayName));
                string strLogo = string.Empty;
                using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                {
                    strLogo = Utility.GetLogoImage(prog.Channel, SchedulerAgent);
                }

                tvNotifyDlg.SetImage(strLogo);
                tvNotifyDlg.TimeOut = _notifyTVTimeout;
                if (_playNotifyBeep)
                {
                    Utils.PlaySound("notify.wav", false, true);
                }
                tvNotifyDlg.SetDefaultToYes(false);
                tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow);

                if (tvNotifyDlg.IsConfirmed)
                {
                    try
                    {
                        if (prog.Channel.ChannelType == ChannelType.Television)
                        {
                            if (g_Player.Playing && g_Player.IsTV && PluginMain.Navigator.IsLiveStreamOn)
                            {
                                GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TVFULLSCREEN);
                            }
                            else
                            {
                                GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TV);
                            }

                            PluginMain.Navigator.ZapToChannel(prog.Channel, false);
                            if (PluginMain.Navigator.CheckChannelChange())
                            {
                                TvHome.UpdateProgressPercentageBar(true);
                                if (!PluginMain.Navigator.LastChannelChangeFailed)
                                {
                                    g_Player.ShowFullScreenWindow();
                                }
                            }
                        }
                        else
                        {
                            PluginMain.Navigator.ZapToChannel(prog.Channel, false);
                            GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_RADIO);
                        }
                    }
                    catch (Exception e)
                    {
                        Log.Error("TVHome: TVNotification: Error on starting channel {0} after notification: {1} {2} {3}", prog.Channel.DisplayName, e.Message, e.Source, e.StackTrace);
                    }
                }
            }
            break;

            //this (GUI_MSG_RECORDER_VIEW_CHANNEL) event is used to let other plugins play a recording,
            //lastMediaHandler does this (with param1 = 5577 for indentification).
            case GUIMessage.MessageType.GUI_MSG_RECORDER_VIEW_CHANNEL:
            {
                if (message.Param1 == 5577)
                {
                    try
                    {
                        Recording rec = message.Object as Recording;
                        RecordedBase.PlayRecording(rec, message.Param2);
                    }
                    catch { Log.Error("TVHome: GUI_MSG_RECORDER_VIEW_CHANNEL error"); }
                }
            }
            break;
            }
        }
コード例 #7
0
        private void ChannelTuneFailedNotifyUser(LiveStreamResult result, Channel channel)
        {
            string TuningResult = string.Empty;

            switch (result)
            {
            case LiveStreamResult.ChannelTuneFailed:
                TuningResult = (Utility.GetLocalizedText(TextId.ChannelTuneFailed));
                break;

            case LiveStreamResult.NoFreeCardFound:
                TuningResult = (Utility.GetLocalizedText(TextId.NoFreeCardFound));
                break;

            case LiveStreamResult.NotSupported:
                TuningResult = (Utility.GetLocalizedText(TextId.NotSupported));
                break;

            case LiveStreamResult.NoRetunePossible:
                TuningResult = (Utility.GetLocalizedText(TextId.NoRetunePossible));
                break;

            case LiveStreamResult.IsScrambled:
                TuningResult = (Utility.GetLocalizedText(TextId.IsScrambled));
                break;

            case LiveStreamResult.UnknownError:
                TuningResult = (Utility.GetLocalizedText(TextId.UnknownError));
                break;
            }

            if (GUIWindowManager.ActiveWindow == (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN)
            {
                // If failed and wasPlaying TV, left screen as it is and show zaposd with error message
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_TV_ERROR_NOTIFY, GUIWindowManager.ActiveWindow, 0,
                                                0, 0, 0,
                                                null);

                msg.SendToTargetWindow = true;
                msg.Object             = TuningResult; // forward error info object
                msg.TargetWindowId     = (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN;
                GUIGraphicsContext.SendMessage(msg);
            }
            else
            {
                // if not fulscreen, show notify dialog with the error message
                string caption = string.Empty;
                string tvlogo  = string.Empty;
                if (channel != null)
                {
                    _navigatorChannels[_currentChannel.ChannelType].PreviousChannel = channel;
                    _currentChannel = null;

                    using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                    {
                        tvlogo = Utility.GetLogoImage(channel, SchedulerAgent);
                    }

                    if (channel.ChannelType == ChannelType.Television)
                    {
                        caption = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName;
                    }
                    else
                    {
                        caption = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName;
                    }
                }

                GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                if (pDlgNotify != null)
                {
                    pDlgNotify.Reset();
                    pDlgNotify.ClearAll();
                    pDlgNotify.SetHeading(caption);
                    if (!string.IsNullOrEmpty(TuningResult))
                    {
                        pDlgNotify.SetText(TuningResult);
                    }
                    pDlgNotify.SetImage(tvlogo);
                    pDlgNotify.TimeOut = 5;
                    pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                }
            }
        }
コード例 #8
0
        public bool Scrobble(string filename)
        {
            StopScrobble();
            istStoppingScrobble = false;

            if (!g_Player.IsTV)
            {
                return(false);
            }

            EbasicHandler.setCurrentProgram(GetCurrentProgram());

            if (EbasicHandler.getCurrentProgram() == null)
            {
                return(false);
            }
            EbasicHandler.SetCurrentProgramIsScrobbling(true);

            TVJustTurnedOn = true;
            if (EbasicHandler.getCurrentProgramType() == VideoType.Series)
            {
                TraktLogger.Info("Detected tv show playing on Live TV. Title = '{0}'", EbasicHandler.getCurrentProgram().Title.ToString());
            }
            else
            {
                TraktLogger.Info("Detected movie playing on Live TV. Title = '{0}'", EbasicHandler.getCurrentProgram().Title.ToString());
            }

            #region Scrobble Timer

            TraktTimer = new Timer(new TimerCallback((stateInfo) =>
            {
                Thread.CurrentThread.Name = "Scrobble";

                // get the current program airing on tv now
                // this may have changed since last status update on trakt
                EVideoInfo videoInfo = GetCurrentProgram();

                //Reinit all variables
                item     = new TraktEPGCacheRecord();
                response = new TraktScrobbleResponse();

                // I have problems with GUI rendering most of the times. If i set the thread to sleep it really helps with GUI rendering.
                // This might also work well to handle zapping correctly.
                Thread.Sleep((TraktSettings.ETVScrobbleDelay) * 1000);

                try
                {
                    if (videoInfo != null)
                    {
                        // if we are watching something different,
                        // check if we should mark previous as watched
                        //if (!videoInfo.Equals(CurrentProgram))

                        if (!videoInfo.Equals(EbasicHandler.getCurrentProgram()))
                        {
                            TraktLogger.Info("Detected new tv program has started. Previous Program = '{0}', New Program = '{1}'", EbasicHandler.getCurrentProgram().ToString(), videoInfo.ToString());
                            //The new program has changed. I should check if the active window is GUIShowSelect and eventually close it.
                            if (GUIWindowManager.ActiveWindow.Equals((int)TraktGUIWindows.EPGShowSelect))
                            {
                                GUIShowSelectGUI.exitGUI();
                            }
                            if (IsProgramWatched(EbasicHandler.getCurrentProgram()) && EbasicHandler.IsCurrentProgramScrobbling())
                            {
                                TraktLogger.Info("Playback of program on Live TV is considered watched. Title = '{0}'", EbasicHandler.getCurrentProgram().ToString());
                                BasicHandler.StopScrobble(EbasicHandler.getCurrentProgram(), true);
                            }
                            //The programs are different so we should start the whole scrobbling process.
                            //For that we set the new videoInfo scrobbling status to true
                            //later we're checking if videoInfo is scrobbling, and it should be false if we don't set it true here.
                            videoInfo.IsScrobbling = true;
                            //EbasicHandler.SetCurrentProgramIsScrobbling(true);
                        }

                        // continue watching new program
                        // dont try to scrobble if previous attempt failed
                        // If the current program is scrobbling, according to the APIARY there's no need to resend every 15 minutes,
                        // it will expire after runtime has elapsed.

                        if ((videoInfo.IsScrobbling) | (TVJustTurnedOn))
                        {
                            TVJustTurnedOn = false;
                            //Starts the scrobble of the new program because it changed
                            //cache should search here because some shows have no name and could be in cache.

                            #region CACHE CHECK and SCROBBLE from CACHE
                            if (EPGCache.searchOnCache(videoInfo.Title, out item))
                            {
                                if (item.Type.Equals("nullRecord"))
                                {
                                    response.Code        = 901;
                                    response.Description = "Manually set don't scrobble";
                                }
                                else if ((item.Type.Equals("movie")) & (videoInfo.Type == VideoType.Movie))
                                {
                                    EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Movie);
                                    response = EbasicHandler.StartScrobbleMovie(videoInfo);
                                }
                                else if ((item.Type.Equals("show")) & (videoInfo.Type == VideoType.Series))
                                {
                                    EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Show);
                                    response = EbasicHandler.StartScrobbleEpisode(videoInfo);
                                }
                                else
                                //The item type is different from the videoinfo type. Cache is authoritative here so overriding videoInfo with the cache.
                                //It's most likely that a show is detected wrong as a movie, because a movie with episode and season number is totally nonsense, but handles both.
                                {
                                    response.Code = 904; //This code will be used later.
                                    if (item.Type.Equals("show"))
                                    {
                                        EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Show);
                                        response.Description = item.Show.Ids.Slug;
                                    }
                                    else
                                    {
                                        EbasicHandler.overrideVideoInfoProgram(ref videoInfo, item.Movie);
                                    }
                                }
                            }// end cache thingy if it was successful it should be scrobbled.
                            #endregion
                            #region CACHE MATCH UNSUCCESSFUL: TRY RETRIEVE ORIGINAL LANGUAGE AND SCROBBLE
                            else
                            {
                                #region FOUND ORIGINAL LANGUAGE TITLE WITH A SINGLE MATCH
                                // Try first to scrobble without changing anything. This is to avoid problems with shows that uses
                                // real non translated shows. In this case the name of the show usually is enough to succesfully scrobble.
                                if (videoInfo.Type == VideoType.Series)
                                {
                                    response = EbasicHandler.StartScrobbleEpisode(videoInfo);
                                }
                                else
                                {
                                    response = EbasicHandler.StartScrobbleMovie(videoInfo);
                                }
                                if (!(response.Code == 0) && EbasicHandler.setOriginalTitle(ref videoInfo))
                                {
                                    if ((videoInfo.Type == VideoType.Series))
                                    {
                                        response = EbasicHandler.StartScrobbleEpisode(videoInfo);
                                    }
                                    else
                                    {
                                        response = EbasicHandler.StartScrobbleMovie(videoInfo);
                                    }
                                }
                                #endregion
                                #region NO CACHE, NO ORIGINAL LANGUAGE SINGLE MATCH FOUND everything is very likely to fail.
                                else if (!response.Code.Equals(0))
                                {
                                    response.Code        = 404;
                                    response.Description = "Not Found";
                                }
                                #endregion
                            }
                            #endregion
                            EbasicHandler.setCurrentProgram(videoInfo);
                            if (response.Code.Equals(901))
                            {
                                TraktLogger.Info("Program {0} skipped because manually marked to skip on cache", videoInfo.Title);
                            }
                            else if (response.Code.Equals(0))
                            {
                                if (TraktSettings.AllowPopUPOnSuccessfulScrobbling)
                                {
                                    GUIDialogNotify notification = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                                    notification.Reset();
                                    notification.SetHeading(string.Format("{0} scrobbled!", EbasicHandler.getCurrentProgram().Type.ToString()));
                                    notification.SetText(string.Format("Scrobbling '{0}' as '{1}'", EbasicHandler.getCurrentProgram().getOriginalTitle(), EbasicHandler.getCurrentProgram().Title));
                                    notification.SetImage(Path.Combine(Config.GetFolder(Config.Dir.Skin), string.Format(@"{0}\Media\Logos\trakt.png", Config.SkinName)));
                                    notification.DoModal(GUIWindowManager.ActiveWindow);
                                }
                            }
                            else // the response was bad! Everything gone worse than ever, again open the GUI
                            {
                                GUIDialogYesNo askManualSelection = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                                if (askManualSelection != null)
                                {
                                    askManualSelection.Reset();
                                    askManualSelection.SetHeading("Start manual matching?");
                                    askManualSelection.SetLine(1, string.Format("Cannot find a match for '{0}'", videoInfo.Title));
                                    askManualSelection.SetDefaultToYes(true);
                                    askManualSelection.DoModal(GUIWindowManager.ActiveWindow);
                                    if (askManualSelection.IsConfirmed)
                                    {
                                        if (!istStoppingScrobble) //maybe we can handle this better. If the user stops the program right before this the plugin crashes.
                                        {
                                            EbasicHandler.StartGui(response.Code, item, TraktSettings.GUIAsDialog);
                                        }
                                    }
                                    else
                                    {
                                        // Need to handle cancel button with a null on cache to avoid future scrobbling.
                                        EPGCache.addOnCache(videoInfo.Title);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (NullReferenceException exception)
                {
                    //handle the worst. This usually happens when the user stops the player during a dialog.
                    //We should at least log this in the mediaportal error.
                }
            }), null, 1000, 300000);

            #endregion
            return(true);
        }