Windows power saving has turned off my monitors and TV while I'm in the middle of watching a video. I suggest, and have tested, the following patch. I ask that you please implement it or a variant to let windows know that something is happening, so it doesn't stop the system.
Thanks
Index: g_player.cs
===================================================================
--- g_player.cs (revision 25174)
+++ g_player.cs (working copy)
@@ -24,6 +24,7 @@
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using MediaPortal.Configuration;
@@ -39,8 +40,27 @@
{
public class g_Player
{
+ [DllImport("Kernel32.DLL", CharSet = CharSet.Auto, SetLastError = true)]
+ private extern static EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
+
#region enums
+ [FlagsAttribute]
+ public enum EXECUTION_STATE : uint
+ {
+ ES_SYSTEM_REQUIRED = 0x00000001,
+ ES_DISPLAY_REQUIRED = 0x00000002,
+ // Legacy flag, should not be used.
+ // ES_USER_PRESENT = 0x00000004,
+ ES_CONTINUOUS = 0x80000000,
+ }
+
+ public enum SPI : uint
+ {
+ SPI_GETPOWEROFFACTIVE = 0x0054,
+ SPI_SETPOWEROFFACTIVE = 0x0056
+ }
+
public enum MediaType
{
Video,
@@ -484,6 +504,7 @@
currentFileName = String.Empty;
_mediaInfo = null;
}
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
}
@@ -499,6 +520,7 @@
RefreshRateChanger.AdaptRefreshRate();
currentFileName = String.Empty;
_mediaInfo = null;
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
}
@@ -538,6 +560,13 @@
{
PlayBackStarted(_currentMedia, _currentFilePlaying);
}
+
+ // If we have Video of some sort
+ if(HasVideo || HasViz)
+ {
+ // Disable the screensaver/powersaving
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED);
+ }
}
}
MediaPortal Version: 1.1 rc1
MediaPortal Skin: Blue Wide
Windows Version: 7
CPU Type: Intel i7
HDD: 2
Memory: 12 gb
Motherboard: dont remember
Video Card: nVidia
Video Card Driver: nVidia
Sound Card: built into motherboard
Sound Card AC3: no idea
Sound Card Driver: no idea
1. TV Card: none
1. TV Card Type:
1. TV Card Driver:
2. TV Card:
2. TV Card Type:
2. TV Card Driver:
3. TV Card:
3. TV Card Type:
3. TV Card Driver:
4. TV Card:
4. TV Card Type:
4. TV Card Driver:
MPEG2 Video Codec: ffmpg
MPEG2 Audio Codec: ffmpg
h.264 Video Codec: ffmpg
Satelite/CableTV Provider: none
HTPC Case:
Cooling: yes?
Power Supply: yes?
Remote: usbuirt
TV: none
TV - HTPC Connection: none
Thanks
Index: g_player.cs
===================================================================
--- g_player.cs (revision 25174)
+++ g_player.cs (working copy)
@@ -24,6 +24,7 @@
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using MediaPortal.Configuration;
@@ -39,8 +40,27 @@
{
public class g_Player
{
+ [DllImport("Kernel32.DLL", CharSet = CharSet.Auto, SetLastError = true)]
+ private extern static EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
+
#region enums
+ [FlagsAttribute]
+ public enum EXECUTION_STATE : uint
+ {
+ ES_SYSTEM_REQUIRED = 0x00000001,
+ ES_DISPLAY_REQUIRED = 0x00000002,
+ // Legacy flag, should not be used.
+ // ES_USER_PRESENT = 0x00000004,
+ ES_CONTINUOUS = 0x80000000,
+ }
+
+ public enum SPI : uint
+ {
+ SPI_GETPOWEROFFACTIVE = 0x0054,
+ SPI_SETPOWEROFFACTIVE = 0x0056
+ }
+
public enum MediaType
{
Video,
@@ -484,6 +504,7 @@
currentFileName = String.Empty;
_mediaInfo = null;
}
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
}
@@ -499,6 +520,7 @@
RefreshRateChanger.AdaptRefreshRate();
currentFileName = String.Empty;
_mediaInfo = null;
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
}
}
@@ -538,6 +560,13 @@
{
PlayBackStarted(_currentMedia, _currentFilePlaying);
}
+
+ // If we have Video of some sort
+ if(HasVideo || HasViz)
+ {
+ // Disable the screensaver/powersaving
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED);
+ }
}
}
MediaPortal Version: 1.1 rc1
MediaPortal Skin: Blue Wide
Windows Version: 7
CPU Type: Intel i7
HDD: 2
Memory: 12 gb
Motherboard: dont remember
Video Card: nVidia
Video Card Driver: nVidia
Sound Card: built into motherboard
Sound Card AC3: no idea
Sound Card Driver: no idea
1. TV Card: none
1. TV Card Type:
1. TV Card Driver:
2. TV Card:
2. TV Card Type:
2. TV Card Driver:
3. TV Card:
3. TV Card Type:
3. TV Card Driver:
4. TV Card:
4. TV Card Type:
4. TV Card Driver:
MPEG2 Video Codec: ffmpg
MPEG2 Audio Codec: ffmpg
h.264 Video Codec: ffmpg
Satelite/CableTV Provider: none
HTPC Case:
Cooling: yes?
Power Supply: yes?
Remote: usbuirt
TV: none
TV - HTPC Connection: none