Advertisement
Guest User

Untitled

a guest
Jul 1st, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 KB | None | 0 0
  1. private bool NotifyChannelChange(TVProgramDescription tvProg)
  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 = 30;
  44. //if (_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 void ProcessNotifies(DateTime preNotifySecs)
  62. {
  63. if (_notifiesListChanged)
  64. {
  65. LoadNotifies();
  66. _notifiesListChanged = false;
  67. }
  68. if (_notifiesList != null && _notifiesList.Count > 0)
  69. {
  70. foreach (Program program in _notifiesList)
  71. {
  72. // switching now, so switch at program start time
  73. //if (preNotifySecs > program.StartTime)
  74. if (System.DateTime.Now.AddSeconds(60) > program.StartTime)
  75. {
  76. Log.Info("Notify {0} on {1} start {2}", program.Title, program.ReferencedChannel().DisplayName,
  77. program.StartTime);
  78. program.Notify = false;
  79. program.Persist();
  80. TVProgramDescription tvProg = new TVProgramDescription();
  81. tvProg.Channel = program.ReferencedChannel();
  82. tvProg.Title = program.Title;
  83. tvProg.Description = program.Description;
  84. tvProg.Genre = program.Genre;
  85. tvProg.StartTime = program.StartTime;
  86. tvProg.EndTime = program.EndTime;
  87.  
  88. _notifiesList.Remove(program);
  89.  
  90. ////message = null;
  91. //MediaPortal.Util.Utils.PlaySound("notify.wav", false, true);
  92. //GUIDialogNotify dlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)TVHome.Window.WINDOW_DIALOG_NOTIFY);
  93. //dlgNotify.Reset();
  94. //dlgNotify.SetHeading("Changing Channel");
  95. //dlgNotify.SetText("Changing to: " + tvProg.Channel.DisplayName);
  96. //dlgNotify.TimeOut = 10;
  97. //dlgNotify.DoModal(GUIWindowManager.ActiveWindow);
  98.  
  99. //Channel channel = tvProg.Channel;
  100. //if (channel.IsTv)
  101. //{
  102. // //MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TV);
  103. // TVHome.ViewChannel(channel);
  104. // g_Player.ShowFullScreenWindow();
  105. //}
  106. //else if (channel.IsRadio)
  107. //{
  108. // MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);
  109. // Radio.CurrentChannel = channel;
  110. // Radio.Play();
  111. //}
  112.  
  113. if (NotifyChannelChange(tvProg))
  114. {
  115. Channel channel = tvProg.Channel;
  116. if (channel.IsTv)
  117. {
  118. MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TVFULLSCREEN);
  119. if (g_Player.Paused)
  120. {
  121. TVHome.ViewChannel(channel);
  122. g_Player.ShowFullScreenWindow();
  123. int tickCount = 0;
  124. while (!g_Player.Paused)
  125. {
  126. Thread.Sleep(10);
  127. // if after 10 seconds and every second thereafter...
  128. if ((tickCount > 100) && ((tickCount % 100) == 0))
  129. {
  130. g_Player.Pause();
  131. // sleep to give the pause a chance to complete...
  132. Thread.Sleep(250);
  133. }
  134. tickCount++;
  135. }
  136. }
  137. else
  138. {
  139. TVHome.ViewChannel(channel);
  140. g_Player.ShowFullScreenWindow();
  141. }
  142. }
  143. else if (channel.IsRadio)
  144. {
  145. MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);
  146. Radio.CurrentChannel = channel;
  147. Radio.Play();
  148. }
  149. }
  150. return;
  151. }
  152. }
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement