Example #1
0
 /// <summary>
 /// This function replaces g_player.ShowFullScreenWindowTV
 /// </summary>
 ///<returns></returns>
 private static bool ShowFullScreenWindowTVHandler()
 {
     TvHome.SetRecordingChaptersAndJumpPoints();
     if (g_Player.IsTVRecording)
     {
         // watching TV
         if (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_TVFULLSCREEN)
         {
             return(true);
         }
         Log.Info("TVRecorded: ShowFullScreenWindow switching to fullscreen tv");
         GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_TVFULLSCREEN);
         GUIGraphicsContext.IsFullScreenVideo = true;
         return(true);
     }
     return(g_Player.ShowFullScreenWindowTVDefault());
 }
Example #2
0
        private void SaveSettings(bool onlyServerSettings)
        {
            using (Settings xmlwriter = new MPSettings())
            {
                xmlwriter.SetValue(_settingSection, TvHome.SettingName.Server, _serverSettings.ServerName);
                xmlwriter.SetValue(_settingSection, TvHome.SettingName.TcpPort, _serverSettings.Port);
                xmlwriter.SetValue(_settingSection, TvHome.SettingName.MacAddresses, _serverSettings.WakeOnLan.MacAddresses);
                xmlwriter.SetValue(_settingSection, TvHome.SettingName.IPAddress, _serverSettings.WakeOnLan.IPAddress);
                xmlwriter.SetValueAsBool(_settingSection, TvHome.SettingName.UseWakeOnLan, _serverSettings.WakeOnLan.Enabled);
                xmlwriter.SetValue(_settingSection, TvHome.SettingName.WakeOnLanTimeoutSeconds, _serverSettings.WakeOnLan.TimeoutSeconds);

                if (!onlyServerSettings)
                {
                    xmlwriter.SetValueAsBool(_settingSection, TvHome.SettingName.NoClientStandbyWhenNotHome, _standbyOnHomeButton.Selected);
                    xmlwriter.SetValueAsBool(_settingSection, TvHome.SettingName.AvoidRtspForLiveTv, !_rtspStreamingTVButton.Selected);
                    xmlwriter.SetValueAsBool(_settingSection, TvHome.SettingName.PlayRecordingsOverRtsp, _rtspStreamingRecButton.Selected);
                    xmlwriter.SetValueAsBool(_settingSection, TvHome.SettingName.AutoStreamingMode, _autoStreamingButton.Selected);
                    xmlwriter.SetValueAsBool(_settingSection, TvHome.SettingName.IsSingleSeat, Utility.IsThisASingleSeatSetup(_serverSettings.ServerName));

                    xmlwriter.SetValueAsBool("mytv", "enableRecNotifier", _recordingNotificationButton.Selected);
                    xmlwriter.SetValueAsBool("mytv", "autofullscreen", _autoFullScreenButton.Selected);
                    xmlwriter.SetValueAsBool("mytv", "showchannelnumber", _showChannelNumbersButton.Selected);
                    xmlwriter.SetValueAsBool("mytv", "hideAllChannelsGroup", _hideAllChannelsGroupButton.Selected);
                    xmlwriter.SetValueAsBool("tvservice", "dvbbitmapsubtitles", _dvbSubtitlesButton.Selected);
                    xmlwriter.SetValueAsBool("tvservice", "dvbttxtsubtitles", _teletextSubtitleButton.Selected);
                    xmlwriter.SetValueAsBool("tvservice", "preferac3", _preferAC3Button.Selected);
                }
            }

            PluginMain.ClearCachedBooleanSettings();
            if (PluginMain.Navigator != null)
            {
                PluginMain.Navigator.Reload();
            }

            TvHome.SettingChanged();
            HomeBase.OnSettingChanged();
        }
Example #3
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;
            }
        }