diff --git a/packages/webamp/docs/usage.md b/packages/webamp/docs/usage.md index 958a7b41ca..4f8151abbc 100644 --- a/packages/webamp/docs/usage.md +++ b/packages/webamp/docs/usage.md @@ -319,6 +319,16 @@ Stop the currently playing audio. Equivilant to pressing the "stop" button. webamp.stop(); ``` +### `setVolume(volume): void` + +Sets the volume from 0 - 100. + +**Since** unreleased + +```JavaScript +webamp.setVolume(50); +``` + ### `renderWhenReady(domNode: HTMLElement): Promise` Webamp will wait until it has fetched the skin and fully parsed it, and then render itself into a new DOM node at the end of the `` tag. @@ -401,6 +411,46 @@ webamp.onClose(() => { }) ``` +### `toggleEqualizer(): void` + +Toggles the visibility of the Equalizer window. + +**Since** unreleased + +```JavaScript +webamp.toggleEqualizer() +``` + +### `togglePlaylist(): void` + +Toggles the visibility of the Playlist window. + +**Since** unreleased + +```JavaScript +webamp.togglePlaylist() +``` + +### `stackWindows(): void` + +Updates Webamp window positions by vertically stacking visible windows, setting origin to 0,0 in browser view. + +**Since** unreleased + +```JavaScript +webamp.stackWindows() +``` + +### `centerWindowsInView(): void` + +Centers Webamp windows in current browser view by scroll position. + +**Since** unreleased + +```JavaScript +webamp.centerWindowsInView() +``` + ### `onMinimize(cb: () => void): () => void` A callback which will be called when Webamp is minimized. Returns an "unsubscribe" function. diff --git a/packages/webamp/js/webampLazy.tsx b/packages/webamp/js/webampLazy.tsx index 14447614f8..b2ee2411d7 100644 --- a/packages/webamp/js/webampLazy.tsx +++ b/packages/webamp/js/webampLazy.tsx @@ -219,6 +219,13 @@ class Webamp { this.store.dispatch(Actions.stop()); } + /** + * Set volume from 0 - 100 + */ + setVolume(volume: number): void { + this.store.dispatch(Actions.setVolume(volume)); + } + /** * Seek backward n seconds in the curent track */ @@ -315,6 +322,35 @@ class Webamp { this.store.dispatch(Actions.open()); } + /** + * Toggles the visibility of the equalizer + */ + toggleEqualizer(): void { + this.store.dispatch(Actions.toggleWindow("equalizer")); + } + + /** + * Toggles the visibility of the playlist + */ + togglePlaylist(): void { + this.store.dispatch(Actions.toggleWindow("playlist")); + } + + /** + * Updates Webamp window positions by vertically stacking visible windows, + * setting origin to 0,0 in browser view + */ + stackWindows(): void { + this.store.dispatch(Actions.stackWindows()); + } + + /** + * Centers Webamp windows in current browser view by scroll position + */ + centerWindowsInView(): void { + this.store.dispatch(Actions.centerWindowsInView()); + } + /** * A callback which will be called when a new track starts loading. *