Skip to content

Commit

Permalink
feat: add quitITunes function
Browse files Browse the repository at this point in the history
  • Loading branch information
N0chteil committed Jan 6, 2023
1 parent 6247228 commit 20a68bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchITunes } from "./win32";
import { fetchITunes, quitITunes } from "./win32";
import { fetchApp } from "./darwin";

import { TimeChangeListener } from "./managers/timeChangeListener";
Expand Down Expand Up @@ -129,3 +129,5 @@ export class AppleBridge {
AppleBridge.getInstance().once(event, service, callback);
}
}

export { fetchITunes, quitITunes };
6 changes: 6 additions & 0 deletions src/win32/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ export function getPlayerState(): PlayerState {
return fetchITunes()?.playerState;
}

export function quitITunes() {
fetchAllInterval.unref();

setTimeout(() => execSync(`taskkill /F /IM "iTunes.exe"`), 1000);
}

export function fetchITunes(type = "currentTrack"): TrackData {
if (process.platform !== "win32") return;
if (!AppleBridge.getInstance().isMusicInstalled) return;
Expand Down

0 comments on commit 20a68bb

Please sign in to comment.