-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds an "add library" action which adds a track to the library resolves #50
- Loading branch information
Showing
9 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {KeyUpEvent, SDOnActionEvent, StateType, WillAppearEvent, WillDisappearEvent} from 'streamdeck-typescript'; | ||
import {ActionTypes} from '../interfaces/enums'; | ||
import {YTMD} from '../ytmd'; | ||
import {DefaultAction} from './default.action'; | ||
import {distinctUntilChanged, map, takeUntil} from "rxjs/operators"; | ||
|
||
export class LibraryAction extends DefaultAction<LibraryAction> { | ||
private inLibrary: boolean = false; | ||
|
||
constructor(private plugin: YTMD, actionName: ActionTypes) { | ||
super(plugin, actionName) | ||
} | ||
|
||
@SDOnActionEvent('willAppear') | ||
onContextAppear(event: WillAppearEvent<any>): void { | ||
console.log("Started"); | ||
this.socket.onTick$ | ||
.pipe(map(value => value.track.inLibrary), distinctUntilChanged(), takeUntil(this.destroy$)) | ||
.subscribe((inLibrary) => { | ||
this.inLibrary = inLibrary; | ||
this.plugin.setState(inLibrary ? StateType.OFF : StateType.ON, event.context); | ||
}); | ||
} | ||
|
||
@SDOnActionEvent('keyUp') | ||
onKeypressUp(event: KeyUpEvent<any>): void { | ||
if (!this.inLibrary) { | ||
this.socket.playerAddLibrary(); | ||
} | ||
this.plugin.setState(this.inLibrary ? StateType.OFF : StateType.ON, event.context); | ||
} | ||
|
||
@SDOnActionEvent('willDisappear') | ||
onContextDisappear(event: WillDisappearEvent): void { | ||
this.destroy$.next(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters