瀏覽代碼

macosx/framework: Delay sleeping during playback.

Pierre d'Herbemont 16 年之前
父節點
當前提交
da47b54b30
共有 1 個文件被更改,包括 12 次插入0 次删除
  1. 12 0
      Sources/VLCMediaPlayer.m

+ 12 - 0
Sources/VLCMediaPlayer.m

@@ -32,6 +32,9 @@
 # include "config.h"
 # include "config.h"
 #endif
 #endif
 
 
+/* prevent system sleep */
+#import <CoreServices/CoreServices.h>
+
 #include <vlc/vlc.h>
 #include <vlc/vlc.h>
 
 
 /* Notification Messages */
 /* Notification Messages */
@@ -651,8 +654,16 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     [self didChangeValueForKey:@"time"];
     [self didChangeValueForKey:@"time"];
 }
 }
 
 
+- (void)delaySleep
+{
+    UpdateSystemActivity(UsrActivity);
+}
+
 - (void)mediaPlayerPositionChanged:(NSNumber *)newPosition
 - (void)mediaPlayerPositionChanged:(NSNumber *)newPosition
 {
 {
+    // This seems to be the most relevant place to delay sleeping and screen saver.
+    [self delaySleep];
+
     [self willChangeValueForKey:@"position"];
     [self willChangeValueForKey:@"position"];
     position = [newPosition floatValue];
     position = [newPosition floatValue];
     [self didChangeValueForKey:@"position"];
     [self didChangeValueForKey:@"position"];
@@ -664,4 +675,5 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
     cachedState = [newState intValue];
     cachedState = [newState intValue];
     [self didChangeValueForKey:@"state"];
     [self didChangeValueForKey:@"state"];
 }
 }
+
 @end
 @end