Advertisement
Guest User

Untitled

a guest
Jul 4th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.41 KB | None | 0 0
  1. private bool NotifyChannelChange(TVProgramDescription tvProg, int onScreenTimeSeconds)
  2. {
  3. // TvHome.cs @ 1885
  4. TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO);
  5.  
  6. TVProgramDescription notify = tvProg;
  7. if (tvNotifyDlg == null || notify == null)
  8. {
  9. return false;
  10. }
  11. int minUntilStart = _preNotifyConfig / 60;
  12. if (notify.StartTime > DateTime.Now)
  13. {
  14. if (minUntilStart > 1)
  15. {
  16. tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1018), minUntilStart));
  17. }
  18. else
  19. {
  20. tvNotifyDlg.SetHeading(1019); // Program is about to begin
  21. }
  22. }
  23. else
  24. {
  25. tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1206), (DateTime.Now - notify.StartTime).Minutes.ToString()));
  26. }
  27. tvNotifyDlg.SetHeading("Switch to " + tvProg.Channel.DisplayName);
  28. tvNotifyDlg.SetLine(1, notify.Title);
  29. tvNotifyDlg.SetLine(2, notify.Description);
  30. tvNotifyDlg.SetLine(4, String.Format(GUILocalizeStrings.Get(1207), notify.Channel.DisplayName));
  31. Channel c = notify.Channel;
  32. string strLogo = string.Empty;
  33. if (c.IsTv)
  34. {
  35. strLogo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.TVChannel, c.DisplayName);
  36. }
  37. else if (c.IsRadio)
  38. {
  39. strLogo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Radio, c.DisplayName);
  40. }
  41.  
  42. tvNotifyDlg.SetImage(strLogo);
  43. tvNotifyDlg.TimeOut = onScreenTimeSeconds;
  44. //if (TVHome._playNotifyBeep)
  45. {
  46. MediaPortal.Util.Utils.PlaySound("notify.wav", false, true);
  47. }
  48. tvNotifyDlg.SetDefaultToYes(true);
  49. tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow);
  50.  
  51. if (tvNotifyDlg.IsConfirmed)
  52. {
  53. return true;
  54. }
  55. else
  56. {
  57. return false;
  58. }
  59. }
  60.  
  61. private bool PausePlaybackDelayed(int pauseDelayMilliseconds)
  62. {
  63. SleepYield(pauseDelayMilliseconds);
  64. g_Player.Pause();
  65. Log.Info("Pausing g_player");
  66.  
  67. return true;
  68. }
  69.  
  70. private void SleepYield(int sleepMilliseconds)
  71. {
  72. if (sleepMilliseconds < 1)
  73. {
  74. sleepMilliseconds = 1;
  75. }
  76.  
  77. int millisecondsYieldTime = 100;
  78. int elapsedCountMilliseconds = 0;
  79. while ((elapsedCountMilliseconds) <= (sleepMilliseconds))
  80. {
  81. g_Player.Process();
  82. Thread.Sleep(millisecondsYieldTime);
  83. elapsedCountMilliseconds += millisecondsYieldTime;
  84. }
  85. }
  86.  
  87. private void ProcessNotifies(DateTime preNotifySecs)
  88. {
  89. if (_notifiesListChanged)
  90. {
  91. LoadNotifies();
  92. _notifiesListChanged = false;
  93. }
  94. if (_notifiesList != null && _notifiesList.Count > 0)
  95. {
  96. foreach (Program program in _notifiesList)
  97. {
  98. // Spidy - switching now, so switch near program start time
  99. //if (preNotifySecs > program.StartTime)
  100. if (System.DateTime.Now.AddSeconds(90) > program.StartTime)
  101. {
  102. Log.Info("Notify {0} on {1} start {2}", program.Title, program.ReferencedChannel().DisplayName,
  103. program.StartTime);
  104. program.Notify = false;
  105. program.Persist();
  106. TVProgramDescription tvProg = new TVProgramDescription();
  107. tvProg.Channel = program.ReferencedChannel();
  108. tvProg.Title = program.Title;
  109. tvProg.Description = program.Description;
  110. tvProg.Genre = program.Genre;
  111. tvProg.StartTime = program.StartTime;
  112. tvProg.EndTime = program.EndTime;
  113.  
  114. _notifiesList.Remove(program);
  115.  
  116. //Channel channel = tvProg.Channel;
  117. //if (channel.IsTv)
  118. //{
  119. // //MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TV);
  120. // TVHome.ViewChannel(channel);
  121. // g_Player.ShowFullScreenWindow();
  122. //}
  123. //else if (channel.IsRadio)
  124. //{
  125. // MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);
  126. // Radio.CurrentChannel = channel;
  127. // Radio.Play();
  128. //}
  129.  
  130. if (NotifyChannelChange(tvProg, 30))
  131. {
  132. Channel channel = tvProg.Channel;
  133. if (channel.IsTv)
  134. {
  135. MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TVFULLSCREEN);
  136. if (g_Player.Paused)
  137. {
  138. GUIWaitCursor.Show();
  139. int oldVolume = g_Player.Volume;
  140. g_Player.Volume = 0;
  141. TVHome.ViewChannel(channel);
  142. g_Player.ShowFullScreenWindowTVDefault();
  143.  
  144. PausePlaybackDelayed(3000);
  145.  
  146. g_Player.Volume = oldVolume;
  147. GUIWaitCursor.Hide();
  148. }
  149. else
  150. {
  151. TVHome.ViewChannel(channel);
  152. g_Player.ShowFullScreenWindow();
  153. }
  154. }
  155. else if (channel.IsRadio)
  156. {
  157. MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);
  158. Radio.CurrentChannel = channel;
  159. Radio.Play();
  160. }
  161.  
  162. //// Now set a bookmark to help those who are pausing or wishing to go back in the buffer
  163. GUIVideoFullscreen videoWindow = (GUIVideoFullscreen)GUIWindowManager.GetWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO);
  164. videoWindow.CreateBookmark();
  165. }
  166. return;
  167. }
  168. }
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement