Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose window manipulation methods #1232

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions packages/webamp/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>`

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 `<body>` tag.
Expand Down Expand Up @@ -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.
Expand Down
36 changes: 36 additions & 0 deletions packages/webamp/js/webampLazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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.
*
Expand Down
Loading