diff --git a/packages/webamp-docs/docs/06_API/03_instance-methods.md b/packages/webamp-docs/docs/06_API/03_instance-methods.md index 1e2b7513..6dd79337 100644 --- a/packages/webamp-docs/docs/06_API/03_instance-methods.md +++ b/packages/webamp-docs/docs/06_API/03_instance-methods.md @@ -64,7 +64,7 @@ Play the next track. webamp.nextTrack(); ``` -### `seekForward(seconds): void` +### `seekForward(seconds: number): void` Seek forward n seconds in the current track. @@ -74,7 +74,7 @@ Seek forward n seconds in the current track. webamp.seekForward(10); ``` -### `seekBackward(seconds): void` +### `seekBackward(seconds: number): void` Seek backward n seconds in the current track. @@ -84,7 +84,7 @@ Seek backward n seconds in the current track. webamp.seekBackward(10); ``` -### `seekToTime(seconds)` +### `seekToTime(seconds: number): void` Seek to a given time within the current track. @@ -94,7 +94,7 @@ Seek to a given time within the current track. webamp.seekToTime(15.5); ``` -### `getMediaStatus()` +### `getMediaStatus(): MediaStatus | null` Get the current "playing" status. The return value is one of: `"PLAYING"`, `"STOPPED"`, or `"PAUSED"`. @@ -126,7 +126,7 @@ webamp.play(); ### `stop(): void` -Stop the currently playing audio. Equivilant to pressing the "stop" button. +Stop the currently playing audio. Equivalent to pressing the "stop" button. **Since** 1.4.0 @@ -146,7 +146,7 @@ webamp.setVolume(75); ### `setCurrentTrack(index: number): void` -Set the current track a specific track in the playlist by zero-based index. +Set the current track to a specific track in the playlist by zero-based index. Note: If Webamp is currently playing, the track will begin playing. If Webamp is not playing, the track will not start playing. You can use `webamp.pause()` before calling this method or `webamp.play()` after calling this method to control whether the track starts playing. @@ -233,7 +233,7 @@ A callback which will be called when a new track starts loading. This can happen Returns an "unsubscribe" function. -**Note:** If the user drags in a track, the URL may be an [ObjectURL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) +**Note:** If the user drags in a track, the URL may be an [ObjectURL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL). ```ts const unsubscribe = webamp.onTrackDidChange((track) => { @@ -278,7 +278,7 @@ unsubscribe(); ### `close(): void` -Equivalent to selection "Close" from Webamp's options menu. Once closed, you can open it again with `.reopen()`. +Equivalent to selecting "Close" from Webamp's options menu. Once closed, you can open it again with `.reopen()`. **Since** 1.4.1 @@ -304,7 +304,7 @@ A callback which will be called when Webamp is minimized. Returns an "unsubscrib ```ts const unsubscribe = webamp.onMinimize(() => { - console.log("Webamp closed"); + console.log("Webamp minimized"); }); // If at some point in the future you want to stop listening to these events: @@ -313,7 +313,7 @@ unsubscribe(); ### `setSkinFromUrl(url: string): void` -Updates the skin used by the webamp instance. Note that this does not happen immediately. If you want to be notified when the skin load is complete, use `.skinIsLoaded()`, which returns a promise which you can await. +Updates the skin used by the Webamp instance. Note that this does not happen immediately. If you want to be notified when the skin load is complete, use `.skinIsLoaded()`, which returns a promise which you can await. **Since** 1.4.1 diff --git a/packages/webamp/js/webampLazy.tsx b/packages/webamp/js/webampLazy.tsx index e27d9917..8a4326b2 100644 --- a/packages/webamp/js/webampLazy.tsx +++ b/packages/webamp/js/webampLazy.tsx @@ -105,7 +105,7 @@ class Webamp { enableMediaSession(this); } - // TODO: Make this much cleaner + // TODO: Make this much cleaner. let convertPreset = null; if (__butterchurnOptions != null) { const { importConvertPreset, presetConverterEndpoint } = @@ -122,7 +122,7 @@ class Webamp { } } - // TODO: Validate required options + // TODO: Validate required options. this.media = new (__customMediaClass || Media)(); this.store = getStore( @@ -134,7 +134,7 @@ class Webamp { requireJSZip, requireMusicMetadata, convertPreset, - // @ts-ignore Typescript is drunk + // @ts-ignore Typescript is drunk. handleTrackDropEvent, handleAddUrlEvent, handleLoadListEvent, @@ -208,56 +208,56 @@ class Webamp { } /** - * Play the current tack + * Play the current track. */ play(): void { this.store.dispatch(Actions.play()); } /** - * Pause the current tack + * Pause the current track. */ pause(): void { this.store.dispatch(Actions.pause()); } /** - * Stop the currently playing audio. Equivalent to pressing the "stop" button + * Stop the currently playing audio. Equivalent to pressing the "stop" button. */ stop(): void { this.store.dispatch(Actions.stop()); } /** - * Set volume from 0 - 100 + * Set volume from 0 - 100. */ setVolume(volume: number): void { this.store.dispatch(Actions.setVolume(volume)); } /** - * Seek backward n seconds in the current track + * Seek backward n seconds in the current track. */ seekBackward(seconds: number) { this.store.dispatch(Actions.seekBackward(seconds)); } /** - * Seek forward n seconds in the current track + * Seek forward n seconds in the current track. */ seekForward(seconds: number) { this.store.dispatch(Actions.seekForward(seconds)); } /** - * Seek to a given time within the current track + * Seek to a given time within the current track. */ seekToTime(seconds: number) { this.store.dispatch(Actions.seekToTime(seconds)); } /** - * Check if shuffle is enabled + * Check if shuffle is enabled. */ isShuffleEnabled(): boolean { return Selectors.getShuffle(this.store.getState()); @@ -271,7 +271,7 @@ class Webamp { } /** - * Check if repeat is enabled + * Check if repeat is enabled. */ isRepeatEnabled(): boolean { return Selectors.getRepeat(this.store.getState()); @@ -285,21 +285,21 @@ class Webamp { } /** - * Play the next track + * Play the next track. */ nextTrack(): void { this.store.dispatch(Actions.next()); } /** - * Play the previous track + * Play the previous track. */ previousTrack(): void { this.store.dispatch(Actions.previous()); } /** - * Set the current track a specific track in the playlist by zero-based index. + * Set the current track to a specific track in the playlist by zero-based index. * * Note: If Webamp is currently playing, the track will begin playing. If * Webamp is not playing, the track will not start playing. You can use @@ -364,7 +364,7 @@ class Webamp { } /** - * Equivalent to selection "Close" from Webamp's options menu. Once closed, + * Equivalent to selecting "Close" from Webamp's options menu. Once closed, * you can open it again with `.reopen()`. */ close(): void { @@ -393,7 +393,7 @@ class Webamp { */ onTrackDidChange(cb: (trackInfo: LoadedURLTrack | null) => void): () => void { let previousTrackId: number | null = null; - // TODO #leak + // TODO #leak. return this.store.subscribe(() => { const state = this.store.getState(); const trackId = Selectors.getCurrentlyPlayingTrackIdIfLoaded(state); @@ -432,7 +432,7 @@ class Webamp { */ async skinIsLoaded(): Promise { // Wait for the skin to load. - // TODO #leak + // TODO #leak. await storeHas(this.store, (state) => !state.display.loading); // We attempt to pre-resolve these promises before we declare the skin // loaded. That's because `` needs these in order to render fully. @@ -490,8 +490,8 @@ class Webamp { * attempt to clean itself up to avoid memory leaks. */ dispose(): void { - // TODO: Clean up store subscription in onTrackDidChange - // TODO: Every storeHas call represents a potential race condition + // TODO: Clean up store subscription in onTrackDidChange. + // TODO: Every storeHas call represents a potential race condition. this.media.dispose(); this._actionEmitter.dispose(); this._disposable.dispose(); @@ -506,7 +506,7 @@ class Webamp { } __onStateChange(cb: () => void): () => void { - // TODO #leak + // TODO #leak. return this.store.subscribe(cb); } @@ -519,7 +519,7 @@ class Webamp { } // Return a promise that resolves when the store matches a predicate. -// TODO #leak +// TODO #leak. const storeHas = ( store: Store, predicate: (state: AppState) => boolean