Skip to content

Commit

Permalink
v3 - Fixing monitor not turning off #5 #39
Browse files Browse the repository at this point in the history
  • Loading branch information
cDima committed Nov 21, 2015
1 parent 907d0b5 commit f802083
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 18 deletions.
Binary file modified .vs/ScreenSaver/v14/.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion ScreenSaver/ScreenSaver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Aerial</RootNamespace>
<AssemblyName>Aerial</AssemblyName>
<AssemblyName>Aerial %28v3%29</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
Expand Down
44 changes: 27 additions & 17 deletions ScreenSaver/ScreenSaverForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,45 +55,46 @@ private void ScreenSaverForm_Load(object sender, EventArgs e)
//TopMost = true;

LayoutPlayer();


System.Timers.Timer nextVideoTimer = new System.Timers.Timer();
nextVideoTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
nextVideoTimer.Interval = 5000;

var nextVideoTimer = new System.Windows.Forms.Timer();
nextVideoTimer.Tick += NextVideoTimer_Tick;
nextVideoTimer.Interval = 1000;
nextVideoTimer.Enabled = true;

if (ShowVideo)
{
//var list = axWindowsMediaPlayer1.playlistCollection.newPlaylist("Aerial");

Movies = new AerialContext().GetMovies();
/*

#if DEBUG
Movies = new List<Asset>
{
new Asset {url = @"http://blog.luxisinteractive.com/wp-content/uploads/2015/08/depth.mp4" },
new Asset {url = @"http://blog.luxisinteractive.com/wp-content/uploads/2015/08/depth.mp4" },
new Asset {url = @"http://blog.luxisinteractive.com/wp-content/uploads/2015/08/animation.mp4" },
};
*/
#endif

//this.axWindowsMediaPlayer1.URL = @"http://blog.luxisinteractive.com/wp-content/uploads/2015/08/depth.mp4";
SetNextVideo();

}
}

private void SetNextVideo()
{
Trace.WriteLine("SetNextVideo()");
axWindowsMediaPlayer1.URL = Movies[currentVideoIndex].url;
currentVideoIndex++;
if (currentVideoIndex >= Movies.Count)
currentVideoIndex = 0;
}

private void OnTimedEvent(object source, ElapsedEventArgs e)
private void NextVideoTimer_Tick(object sender, EventArgs e)
{
Console.WriteLine("Timer: " + this.axWindowsMediaPlayer1.playState);
if (this.axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsReady)
var state = this.axWindowsMediaPlayer1.playState;
Trace.WriteLine("Timer: " + state);
if (state == WMPLib.WMPPlayState.wmppsReady ||
state == WMPLib.WMPPlayState.wmppsUndefined ||
state == WMPLib.WMPPlayState.wmppsStopped)
{
SetNextVideo();
}
Expand All @@ -111,15 +112,24 @@ private void LayoutPlayer()
this.axWindowsMediaPlayer1.stretchToFit = true;
this.axWindowsMediaPlayer1.Top = 0;
this.axWindowsMediaPlayer1.Left = 0;
this.axWindowsMediaPlayer1.settings.setMode("loop", true);
//this.axWindowsMediaPlayer1.settings.setMode("loop", true);
this.axWindowsMediaPlayer1.MouseMoveEvent += AxWindowsMediaPlayer1_MouseMoveEvent;
this.axWindowsMediaPlayer1.KeyPressEvent += AxWindowsMediaPlayer1_KeyPressEvent;
this.axWindowsMediaPlayer1.PlayStateChange += AxWindowsMediaPlayer1_PlayStateChange;
}

private void AxWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
NativeMethods.EnableMonitorSleep(); // todo: doesn't do the trick.
NativeMethods.EnableMonitorSleep();

var state = this.axWindowsMediaPlayer1.playState;
Trace.WriteLine("OnPlayerChanged: " + state + ", new state: " + (WMPLib.WMPPlayState)e.newState);
if (//state == WMPLib.WMPPlayState.wmppsReady ||
state == WMPLib.WMPPlayState.wmppsUndefined ||
state == WMPLib.WMPPlayState.wmppsStopped)
{
SetNextVideo();
}
}

/// <summary>
Expand Down
Binary file modified install/aerial.scr
Binary file not shown.
Binary file modified install/aerial.scr.zip
Binary file not shown.
Binary file modified merge/Aerial.exe
Binary file not shown.
Binary file added merge/aerial-v3.scr
Binary file not shown.
Binary file removed merge/aerial.scr
Binary file not shown.

0 comments on commit f802083

Please sign in to comment.