Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool NotifyChannelChange(TVProgramDescription tvProg, int onScreenTimeSeconds)
- {
- // TvHome.cs @ 1885
- TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO);
- TVProgramDescription notify = tvProg;
- if (tvNotifyDlg == null || notify == null)
- {
- return false;
- }
- int minUntilStart = _preNotifyConfig / 60;
- if (notify.StartTime > DateTime.Now)
- {
- 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 - notify.StartTime).Minutes.ToString()));
- }
- tvNotifyDlg.SetHeading("Switch to " + tvProg.Channel.DisplayName);
- tvNotifyDlg.SetLine(1, notify.Title);
- tvNotifyDlg.SetLine(2, notify.Description);
- tvNotifyDlg.SetLine(4, String.Format(GUILocalizeStrings.Get(1207), notify.Channel.DisplayName));
- Channel c = notify.Channel;
- string strLogo = string.Empty;
- if (c.IsTv)
- {
- strLogo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.TVChannel, c.DisplayName);
- }
- else if (c.IsRadio)
- {
- strLogo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Radio, c.DisplayName);
- }
- tvNotifyDlg.SetImage(strLogo);
- tvNotifyDlg.TimeOut = onScreenTimeSeconds;
- //if (TVHome._playNotifyBeep)
- {
- MediaPortal.Util.Utils.PlaySound("notify.wav", false, true);
- }
- tvNotifyDlg.SetDefaultToYes(true);
- tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow);
- if (tvNotifyDlg.IsConfirmed)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool PausePlaybackDelayed(int pauseDelayMilliseconds)
- {
- SleepYield(pauseDelayMilliseconds);
- g_Player.Pause();
- Log.Info("Pausing g_player");
- return true;
- }
- private void SleepYield(int sleepMilliseconds)
- {
- if (sleepMilliseconds < 1)
- {
- sleepMilliseconds = 1;
- }
- int millisecondsYieldTime = 100;
- int elapsedCountMilliseconds = 0;
- while ((elapsedCountMilliseconds) <= (sleepMilliseconds))
- {
- g_Player.Process();
- Thread.Sleep(millisecondsYieldTime);
- elapsedCountMilliseconds += millisecondsYieldTime;
- }
- }
- private void ProcessNotifies(DateTime preNotifySecs)
- {
- if (_notifiesListChanged)
- {
- LoadNotifies();
- _notifiesListChanged = false;
- }
- if (_notifiesList != null && _notifiesList.Count > 0)
- {
- foreach (Program program in _notifiesList)
- {
- // Spidy - switching now, so switch near program start time
- //if (preNotifySecs > program.StartTime)
- if (System.DateTime.Now.AddSeconds(90) > program.StartTime)
- {
- Log.Info("Notify {0} on {1} start {2}", program.Title, program.ReferencedChannel().DisplayName,
- program.StartTime);
- program.Notify = false;
- program.Persist();
- TVProgramDescription tvProg = new TVProgramDescription();
- tvProg.Channel = program.ReferencedChannel();
- tvProg.Title = program.Title;
- tvProg.Description = program.Description;
- tvProg.Genre = program.Genre;
- tvProg.StartTime = program.StartTime;
- tvProg.EndTime = program.EndTime;
- _notifiesList.Remove(program);
- //Channel channel = tvProg.Channel;
- //if (channel.IsTv)
- //{
- // //MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TV);
- // TVHome.ViewChannel(channel);
- // g_Player.ShowFullScreenWindow();
- //}
- //else if (channel.IsRadio)
- //{
- // MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);
- // Radio.CurrentChannel = channel;
- // Radio.Play();
- //}
- if (NotifyChannelChange(tvProg, 30))
- {
- Channel channel = tvProg.Channel;
- if (channel.IsTv)
- {
- MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TVFULLSCREEN);
- if (g_Player.Paused)
- {
- GUIWaitCursor.Show();
- int oldVolume = g_Player.Volume;
- g_Player.Volume = 0;
- TVHome.ViewChannel(channel);
- g_Player.ShowFullScreenWindowTVDefault();
- PausePlaybackDelayed(3000);
- g_Player.Volume = oldVolume;
- GUIWaitCursor.Hide();
- }
- else
- {
- TVHome.ViewChannel(channel);
- g_Player.ShowFullScreenWindow();
- }
- }
- else if (channel.IsRadio)
- {
- MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);
- Radio.CurrentChannel = channel;
- Radio.Play();
- }
- //// Now set a bookmark to help those who are pausing or wishing to go back in the buffer
- GUIVideoFullscreen videoWindow = (GUIVideoFullscreen)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
- videoWindow.CreateBookmark();
- }
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement