|
@@ -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);
|