Skip to content

Commit 1fdfacf

Browse files
author
dsward2
committed
In index.html startAudioPlayerAfterDelay() and bodyElementLoaded(), some additional calls to periodicUpdate() were added.
In WebServerConnection, a couple of methods needed to use dispatch_sync(dispatch_get_main_queue(), ...) to access AppKit UI objects.
1 parent 78c9ead commit 1fdfacf

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

LocalRadio/Web/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@
426426
audioPlayer.autoplay=true;
427427

428428
setTimeout(function(){periodicUpdate();}, 1000); // a one-shot call to periodicUpdate() for "Now Playing"
429+
setTimeout(function(){periodicUpdate();}, 5000); // a one-shot call to periodicUpdate() for "Now Playing"
430+
setTimeout(function(){periodicUpdate();}, 10000); // a one-shot call to periodicUpdate() for "Now Playing"
429431
}
430432
}
431433

@@ -441,6 +443,8 @@
441443
loadContent("index2.html");
442444

443445
window.addEventListener("message", function(){startAudioPlayer();}, false); // receive "startaudio" via postMessage()
446+
447+
setTimeout(function(){periodicUpdate();}, 1000); // a one-shot call to periodicUpdate() for "Now Playing"
444448
}
445449

446450

LocalRadio/WebServerConnection.m

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,15 @@ - (BOOL)expectsRequestBodyFromMethod:(NSString *)method atPath:(NSString *)path
678678

679679
if (categoryID != 0)
680680
{
681-
NSInteger nowScanningCategoryID = self.appDelegate.statusFrequencyIDTextField.integerValue;
682-
683-
if (categoryID == nowScanningCategoryID)
684-
{
685-
NSString * categoryIDString = [NSString stringWithFormat:@"%ld", categoryID];
686-
[self scannerListenButtonClickedForCategoryID:categoryIDString];
687-
}
681+
dispatch_sync(dispatch_get_main_queue(), ^{
682+
NSInteger nowScanningCategoryID = self.appDelegate.statusFrequencyIDTextField.integerValue;
683+
684+
if (categoryID == nowScanningCategoryID)
685+
{
686+
NSString * categoryIDString = [NSString stringWithFormat:@"%ld", categoryID];
687+
[self scannerListenButtonClickedForCategoryID:categoryIDString];
688+
}
689+
});
688690
}
689691
}
690692
}
@@ -887,13 +889,15 @@ - (BOOL)expectsRequestBodyFromMethod:(NSString *)method atPath:(NSString *)path
887889

888890
if (frequencyID != 0)
889891
{
890-
NSInteger nowPlayingFrequencyID = self.appDelegate.statusFrequencyIDTextField.integerValue;
891-
892-
if (frequencyID == nowPlayingFrequencyID)
893-
{
894-
NSString * frequencyIDString = [NSString stringWithFormat:@"%ld", frequencyID];
895-
[self listenButtonClickedForFrequencyID:frequencyIDString];
896-
}
892+
dispatch_sync(dispatch_get_main_queue(), ^{
893+
NSInteger nowPlayingFrequencyID = self.appDelegate.statusFrequencyIDTextField.integerValue;
894+
895+
if (frequencyID == nowPlayingFrequencyID)
896+
{
897+
NSString * frequencyIDString = [NSString stringWithFormat:@"%ld", frequencyID];
898+
[self listenButtonClickedForFrequencyID:frequencyIDString];
899+
}
900+
});
897901
}
898902
}
899903
}

0 commit comments

Comments
 (0)