Exemplo n.º 1
0
        private void ProgramDetailsPopup_Load(object sender, EventArgs e)
        {
            _channelLabel.Text       = _channel.DisplayName;
            _dateLabel.Text          = _guideProgram.StartTime.ToLongDateString();
            _widescreenLabel.Visible = (0 != (_guideProgram.Flags & GuideProgramFlags.WidescreenAspectRatio));
            _timeLabel.Text          = _guideProgram.StartTime.ToShortTimeString() + "-" + _guideProgram.StopTime.ToShortTimeString();
            _titleLabel.Text         = _guideProgram.Title;
            if (String.IsNullOrEmpty(_guideProgram.SubTitle))
            {
                _detailsTableLayoutPanel.RowStyles[2].SizeType = SizeType.Absolute;
                _detailsTableLayoutPanel.RowStyles[2].Height   = 0;
            }
            else
            {
                _subTitleLabel.Text = _guideProgram.SubTitle;
            }

            string description = _guideProgram.CreateCombinedDescription(false);

            _descriptionLabel.Text = description;

            using (Graphics g = this.CreateGraphics())
            {
                SizeF  size         = g.MeasureString(_descriptionLabel.Text, _descriptionLabel.Font, _descriptionLabel.Width);
                double heightFactor = g.DpiY / 96;
                this.Height = (int)Math.Max(100.0 * heightFactor, 75 + Math.Round(size.Height * heightFactor) + 10);
            }
        }
Exemplo n.º 2
0
        private void SetProperties(UpcomingProgram upcoming, ScheduleSummary schedule)
        {
            string guiPropertyPrefix = this._channelType == ChannelType.Television ? "#TV" : "#Radio";

            if (schedule != null)
            {
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", schedule.Name);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", " ");
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", "defaultFolderBig.png");
            }
            else if (upcoming != null)
            {
                GuideProgram guideProgram = upcoming.GuideProgramId.HasValue ?
                                            Proxies.GuideService.GetProgramById(upcoming.GuideProgramId.Value).Result : null;

                string strTime = string.Format("{0} {1} - {2}",
                                               Utility.GetShortDayDateString(upcoming.StartTime),
                                               upcoming.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                               upcoming.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", upcoming.Channel.DisplayName);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", upcoming.Title);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", upcoming.Category);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", strTime);

                string description = String.Empty;
                if (guideProgram != null)
                {
                    description = guideProgram.CreateCombinedDescription(true);
                }
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", description);

                string logo = Utility.GetLogoImage(upcoming.Channel.ChannelId, upcoming.Channel.DisplayName);
                if (!string.IsNullOrEmpty(logo))
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", logo);
                }
                else
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", "defaultVideoBig.png");
                }
            }
            else
            {
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Channel", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Title", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Genre", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Time", String.Empty);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.Description", " ");
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Upcoming.thumb", String.Empty);
            }
        }
Exemplo n.º 3
0
        private void SetProperties(UpcomingProgram program)
        {
            string guiPropertyPrefix = _channelType == ChannelType.Television ? "#TV" : "#Radio";

            if (program == null)
            {
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Channel");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Title");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Genre");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Time");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.Description");
                Utility.ClearProperty(guiPropertyPrefix + ".Search.thumb");
            }
            else
            {
                string strTime = string.Format("{0} {1} - {2}",
                                               Utility.GetShortDayDateString(program.StartTime),
                                               program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                               program.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Channel", program.Channel.DisplayName);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Title", program.Title);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Genre", program.Category);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Time", strTime);
                string logo = Utility.GetLogoImage(program.Channel.ChannelId, program.Channel.DisplayName, _tvSchedulerAgent);
                if (System.IO.File.Exists(logo))
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.thumb", logo);
                }
                else
                {
                    GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.thumb", "defaultVideoBig.png");
                }

                GuideProgram guideProgram = GuideAgent.GetProgramById(program.GuideProgramId.Value);
                GUIPropertyManager.SetProperty(guiPropertyPrefix + ".Search.Description", guideProgram.CreateCombinedDescription(true));
            }
        }
Exemplo n.º 4
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;
            }
        }