home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
Improvement Suggestions
4994: Automatically Change Channel on Program Reminder
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="vapourEyes" data-source="post: 1305481" data-attributes="member: 143065"><p>I found, eventually its best to introduce a Thread to handle the Pause and enable VideoBuffer to stay intact.</p><p></p><p>Its much more reliable and tested working here. Apologies again for not completing a PR and Merging that way.</p><p></p><p>The new thread code is below, within TvHome.cs:</p><p></p><p>[CODE=csharp] static void afterChannelChangePause()</p><p> {</p><p> Thread.Sleep(10000);</p><p> g_Player.Pause();</p><p> }[/CODE]</p><p></p><p></p><p></p><p></p><p>This is the code for the Notify() handler, within TvHome.cs</p><p></p><p>[CODE=csharp] case GUIMessage.MessageType.GUI_MSG_NOTIFY_TV_PROGRAM:</p><p> {</p><p> bool wasPaused = g_Player.Paused;</p><p> </p><p> TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO);</p><p></p><p> TVProgramDescription notify = message.Object as TVProgramDescription;</p><p> if (tvNotifyDlg == null || notify == null)</p><p> {</p><p> return;</p><p> }</p><p> int minUntilStart = _preNotifyConfig / 60;</p><p> if (notify.StartTime > DateTime.Now)</p><p> {</p><p> if (minUntilStart > 1)</p><p> {</p><p> tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1018), minUntilStart));</p><p> }</p><p> else</p><p> {</p><p> tvNotifyDlg.SetHeading(1019); // Program is about to begin</p><p> }</p><p> }</p><p> else</p><p> {</p><p> tvNotifyDlg.SetHeading(String.Format(GUILocalizeStrings.Get(1206), (DateTime.Now - notify.StartTime).Minutes.ToString()));</p><p> }</p><p> tvNotifyDlg.SetLine(1, notify.Title);</p><p> tvNotifyDlg.SetLine(2, notify.Description);</p><p> tvNotifyDlg.SetLine(4, String.Format(GUILocalizeStrings.Get(1207), notify.Channel.DisplayName));</p><p> Channel c = notify.Channel;</p><p> string strLogo = string.Empty;</p><p> if (c.IsTv)</p><p> {</p><p> strLogo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.TVChannel, c.DisplayName);</p><p> }</p><p> else if (c.IsRadio)</p><p> {</p><p> strLogo = MediaPortal.Util.Utils.GetCoverArt(Thumbs.Radio, c.DisplayName);</p><p> }</p><p></p><p> tvNotifyDlg.SetImage(strLogo);</p><p> tvNotifyDlg.TimeOut = _notifyTVTimeout;</p><p> if (_playNotifyBeep)</p><p> {</p><p> MediaPortal.Util.Utils.PlaySound("notify.wav", false, true);</p><p> }</p><p> tvNotifyDlg.SetDefaultToYes(_changeChannelOnNotifyTimeout);</p><p> tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow);</p><p></p><p> if (tvNotifyDlg.IsConfirmed)</p><p> {</p><p> try</p><p> {</p><p> //MediaPortal.Player.g_Player.Stop();</p><p></p><p> if (c.IsTv)</p><p> {</p><p> MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TV);</p><p> g_Player.ShowFullScreenWindow();</p><p> TVHome.ViewChannelAndCheck(c);</p><p> //if (TVHome.Card.IsTimeShifting && TVHome.Card.IdChannel == c.IdChannel)</p><p> //{</p><p> // g_Player.ShowFullScreenWindow();</p><p> //}</p><p> }</p><p> else if (c.IsRadio)</p><p> {</p><p> MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO);</p><p> Radio.CurrentChannel = c;</p><p> Radio.Play();</p><p> }</p><p></p><p> if (wasPaused)</p><p> {</p><p> Thread afterChannelChangePauseThread = new Thread(afterChannelChangePause);</p><p> afterChannelChangePauseThread.Start();</p><p> }</p><p> }</p><p></p><p> catch (Exception e)</p><p> {</p><p> Log.Error("TVHome: TVNotification: Error on starting channel {0} after notification: {1} {2} {3}", notify.Channel.DisplayName, e.Message, e.Source, e.StackTrace);</p><p> }</p><p></p><p> }</p><p> break;</p><p> }</p><p> }</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="vapourEyes, post: 1305481, member: 143065"] I found, eventually its best to introduce a Thread to handle the Pause and enable VideoBuffer to stay intact. Its much more reliable and tested working here. Apologies again for not completing a PR and Merging that way. The new thread code is below, within TvHome.cs: [CODE=csharp] static void afterChannelChangePause() { Thread.Sleep(10000); g_Player.Pause(); }[/CODE] This is the code for the Notify() handler, within TvHome.cs [CODE=csharp] case GUIMessage.MessageType.GUI_MSG_NOTIFY_TV_PROGRAM: { bool wasPaused = g_Player.Paused; TVNotifyYesNoDialog tvNotifyDlg = (TVNotifyYesNoDialog)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TVNOTIFYYESNO); TVProgramDescription notify = message.Object as TVProgramDescription; if (tvNotifyDlg == null || notify == null) { return; } 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.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 = _notifyTVTimeout; if (_playNotifyBeep) { MediaPortal.Util.Utils.PlaySound("notify.wav", false, true); } tvNotifyDlg.SetDefaultToYes(_changeChannelOnNotifyTimeout); tvNotifyDlg.DoModal(GUIWindowManager.ActiveWindow); if (tvNotifyDlg.IsConfirmed) { try { //MediaPortal.Player.g_Player.Stop(); if (c.IsTv) { MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_TV); g_Player.ShowFullScreenWindow(); TVHome.ViewChannelAndCheck(c); //if (TVHome.Card.IsTimeShifting && TVHome.Card.IdChannel == c.IdChannel) //{ // g_Player.ShowFullScreenWindow(); //} } else if (c.IsRadio) { MediaPortal.GUI.Library.GUIWindowManager.ActivateWindow((int)MediaPortal.GUI.Library.GUIWindow.Window.WINDOW_RADIO); Radio.CurrentChannel = c; Radio.Play(); } if (wasPaused) { Thread afterChannelChangePauseThread = new Thread(afterChannelChangePause); afterChannelChangePauseThread.Start(); } } catch (Exception e) { Log.Error("TVHome: TVNotification: Error on starting channel {0} after notification: {1} {2} {3}", notify.Channel.DisplayName, e.Message, e.Source, e.StackTrace); } } break; } } [/CODE] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
Improvement Suggestions
4994: Automatically Change Channel on Program Reminder
Contact us
RSS
Top
Bottom