Skip to content

Commit

Permalink
Merge pull request #34 from danmason/loop-state-in-java
Browse files Browse the repository at this point in the history
Only handle state of `loop` within Java
  • Loading branch information
danmason authored Feb 9, 2022
2 parents d134416 + 6b3bf39 commit c3a4847
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions java-src/cljukebox/AudioTrackScheduler.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public boolean skip() {
}
}

public boolean setLoop(boolean shouldLoop) {
this.loop = shouldLoop;
public boolean switchLoop() {
loop = !loop;
return loop;
}

Expand Down
7 changes: 2 additions & 5 deletions src/cljukebox/handlers/loop.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
(:require [cljukebox.player :as player]
[cljukebox.util :as util]))

(def !loop (atom false))

(defn loop-scheduler [{:keys [message-channel]} {:keys [scheduler]}]
(let [should-loop (swap! !loop not)]
(.setLoop scheduler should-loop)
(if should-loop
(let [loop-active? (.switchLoop scheduler)]
(if loop-active?
(util/send-message message-channel ":repeat: **Loop enabled!**")
(util/send-message message-channel ":repeat: **Loop disabled!**"))))

Expand Down

0 comments on commit c3a4847

Please sign in to comment.