Skip to content

Commit

Permalink
Merge pull request #21 from whitershade/master
Browse files Browse the repository at this point in the history
added audio preloader type as argument for preload function
  • Loading branch information
voronianski authored Nov 15, 2017
2 parents c748f98 + 9e8a562 commit 1444f6a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,17 @@ Starts playing track if it's not playing right now. Accepts `options` object whe
- `streamUrl` - any audio streaming url string (e.g. SoundCloud track's `stream_url`), if it's passed it will be the main playing source.
- `playlistIndex` - number that specifies the position of the track to play in resolved SoundCloud playlist's `tracks` array.

#### `preload(streamUrl)`
#### `preload(streamUrl, preloadType)`

Preloads track data without playing it.

- `preloadType` - This attribute is intended to provide a hint to the browser about what the author thinks will lead to the best user experience. It may have one of the following values:
* 'none': indicates that the audio should not be preloaded;
* 'metadata': indicates that only audio metadata (e.g. length) is fetched;
* 'auto': indicates that the whole audio file could be downloaded, even if the user is not expected to use it;

See more at [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#Attributes)

#### `pause()`

Pause playing audio.
Expand Down
2 changes: 1 addition & 1 deletion dist/soundcloud-audio.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ SoundCloud.prototype.unbindAll = function () {
}
};

SoundCloud.prototype.preload = function (streamUrl) {
SoundCloud.prototype.preload = function (streamUrl, preloadType) {
this._track = {stream_url: streamUrl};
preloadType && (this.audio.preload = preloadType);
this.audio.src = this._clientId ?
_appendQueryParam(streamUrl, 'client_id', this._clientId) :
streamUrl;
Expand Down

0 comments on commit 1444f6a

Please sign in to comment.