Explorar o código

Less flashing when the media is down

Zachary Kotlarek %!s(int64=11) %!d(string=hai) anos
pai
achega
28ec4e33c9
Modificáronse 2 ficheiros con 19 adicións e 20 borrados
  1. 0 9
      dmx/launchd/com.uberzach.qt_player.plist
  2. 19 11
      dmx/qt_player.pl

+ 0 - 9
dmx/launchd/com.uberzach.qt_player.plist

@@ -4,15 +4,6 @@
 <dict>
 <dict>
 	<key>LimitLoadToSessionType</key>
 	<key>LimitLoadToSessionType</key>
 	<string>Aqua</string>
 	<string>Aqua</string>
-	<key>LimitLoadToHosts</key>
-	<array>
-		<string>Loki.local</string>
-		<string>loki.uberzach.com</string>
-		<string>Heady.local</string>
-		<string>heady.uberzach.com</string>
-		<string>Beddy.local</string>
-		<string>beddy.uberzach.com</string>
-	</array>
 	<key>RunAtLoad</key>
 	<key>RunAtLoad</key>
 	<true/>
 	<true/>
 	<key>Label</key>
 	<key>Label</key>

+ 19 - 11
dmx/qt_player.pl

@@ -14,7 +14,17 @@ use Audio;
 
 
 # User config
 # User config
 my $MEDIA_PATH = `~/bin/video/mediaPath`;
 my $MEDIA_PATH = `~/bin/video/mediaPath`;
-my %FILES      = ();
+
+# App config
+my $DATA_DIR     = DMX::dataDir();
+my $STATE_SOCK   = 'QT_PLAYER';
+my $OUTPUT_FILE  = $DATA_DIR . $STATE_SOCK;
+my $DELAY        = 5;
+my $MAX_CMD_LEN  = 16384;
+my $TIMEOUT_OPEN = 10;
+
+# Globals
+my %FILES = ();
 
 
 # Prototypes
 # Prototypes
 sub init();
 sub init();
@@ -25,20 +35,18 @@ sub printFiles();
 sub cmdApp($$);
 sub cmdApp($$);
 sub openQT($);
 sub openQT($);
 
 
-# App config
-my $DATA_DIR     = DMX::dataDir();
-my $STATE_SOCK   = 'QT_PLAYER';
-my $OUTPUT_FILE  = $DATA_DIR . $STATE_SOCK;
-my $DELAY        = 5;
-my $MAX_CMD_LEN  = 16384;
-my $TIMEOUT_OPEN = 10;
-
 # Debug
 # Debug
 my $DEBUG = 0;
 my $DEBUG = 0;
 if ($ENV{'DEBUG'}) {
 if ($ENV{'DEBUG'}) {
 	$DEBUG = 1;
 	$DEBUG = 1;
 }
 }
 
 
+# Ensure the media is ready before we do anything else
+if (!$MEDIA_PATH || !-d $MEDIA_PATH) {
+	sleep($TIMEOUT_OPEN);
+	exit(0);
+}
+
 # Clear our output file
 # Clear our output file
 if (-e $OUTPUT_FILE) {
 if (-e $OUTPUT_FILE) {
 	unlink($OUTPUT_FILE);
 	unlink($OUTPUT_FILE);
@@ -251,13 +259,13 @@ sub cmdApp($$) {
 # It would be nice to use AS here to get a more definitive document name, but the open() call is QT player is borked
 # It would be nice to use AS here to get a more definitive document name, but the open() call is QT player is borked
 sub openQT($) {
 sub openQT($) {
 	my ($doc) = @_;
 	my ($doc) = @_;
-	
+
 	# Build the open command
 	# Build the open command
 	my @cmd = ('open', '-a', 'QuickTime Player');
 	my @cmd = ('open', '-a', 'QuickTime Player');
 	if ($doc) {
 	if ($doc) {
 		push(@cmd, $doc);
 		push(@cmd, $doc);
 	}
 	}
-	
+
 	# Execute, dying on timeout
 	# Execute, dying on timeout
 	timeout $TIMEOUT_OPEN => sub {
 	timeout $TIMEOUT_OPEN => sub {
 		IPC::System::Simple::system(@cmd);
 		IPC::System::Simple::system(@cmd);