File tree Expand file tree Collapse file tree
src/main/java/dev/codeman/smtc4j Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,7 +84,14 @@ public static synchronized void startUpdateScheduler(long intervalMillis) {
8484 checkIsLoaded ();
8585
8686 ScheduledExecutorService exec = getScheduler ();
87- exec .scheduleAtFixedRate (SMTC4J ::updateCache , 0 , intervalMillis , TimeUnit .MILLISECONDS );
87+ exec .scheduleAtFixedRate (() -> {
88+ try {
89+ updateCache ();
90+ } catch (Exception e ) {
91+ System .err .println ("Error updating SMTC4J cache: " + e .getMessage ());
92+ e .printStackTrace (System .err );
93+ }
94+ }, 0 , intervalMillis , TimeUnit .MILLISECONDS );
8895 }
8996
9097 public static MediaInfo parsedMediaInfo () {
@@ -130,7 +137,14 @@ public static void pressKey(MediaKey key) {
130137 public static void scheduleKeyPress (MediaKey key ) {
131138 checkIsLoaded ();
132139
133- getScheduler ().execute (() -> pressKey (key ));
140+ getScheduler ().execute (() -> {
141+ try {
142+ pressKey (key );
143+ } catch (Exception e ) {
144+ System .err .println ("Error pressing media key: " + e .getMessage ());
145+ e .printStackTrace (System .err );
146+ }
147+ });
134148 }
135149
136150 private static void checkIsLoaded () {
You can’t perform that action at this time.
0 commit comments