Skip to content

Commit 28f1c22

Browse files
committed
make core options optional
1 parent 1ea9f5c commit 28f1c22

File tree

6 files changed

+71
-70
lines changed

6 files changed

+71
-70
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ in the meantime check out what's in the examples directory (especially the [simp
2626

2727
## TODOs
2828

29-
* make the core player options object optinal when initializing a new player
3029
* abort the loading of the sound if the user clicks play and then pause (or stop / next / previous) before the end of the buffering process (https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/abort)
3130
* allow cross fading songs "on end" if it's the next song in a playlist
3231
* create a web component UI (http://www.w3.org/TR/components-intro/)!?
@@ -74,3 +73,4 @@ in the meantime check out what's in the examples directory (especially the [simp
7473
* play next song onEnded, add option to enable or disable automatic play next onEnded
7574
* add change position method
7675
* add loop queue option
76+
* make the core player options object optinal when initializing a new player

build/@types/web-audio-api-player/library/core.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface ICoreOptions {
66
loopQueue?: boolean;
77
soundsBaseUrl?: string;
88
playingProgressIntervalTime?: number;
9+
playNextOnEnded?: boolean;
910
}
1011
export declare class PlayerCore {
1112
protected _isWebAudioApiSupported: boolean;
@@ -28,7 +29,7 @@ export declare class PlayerCore {
2829
readonly PLAY_SOUND_PREVIOUS: string;
2930
readonly PLAY_SOUND_FIRST: string;
3031
readonly PLAY_SOUND_LAST: string;
31-
constructor(playerOptions: ICoreOptions);
32+
constructor(playerOptions?: ICoreOptions);
3233
protected _initialize(): void;
3334
addSoundToQueue(soundAttributes: ISoundAttributes, whereInQueue?: string): ISound;
3435
_appendSoundToQueue(sound: ISound): void;

build/library/core.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/deezer-player/server/bootstrap.ts

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -92,83 +92,83 @@ export default class Bootsrtrap {
9292
callbackURL: DEEZER_CALLBACK_URL,
9393
scope: DEEZER_SCOPE
9494
},
95-
function (accessToken: string, refreshToken: string | undefined, profile: passport.Profile, done: Function) {
95+
function (accessToken: string, refreshToken: string | undefined, profile: passport.Profile, done: Function) {
9696

97-
console.log(accessToken, refreshToken, profile);
97+
console.log(accessToken, refreshToken, profile);
9898

99-
let parameters = {
100-
access_token: accessToken
101-
// index (default 0)
102-
// limit (default 25)
103-
};
99+
let parameters = {
100+
access_token: accessToken
101+
// index (default 0)
102+
// limit (default 25)
103+
};
104104

105-
let deezerApiBaseUrl = 'http://api.deezer.com';
106-
let deezerApiUri = '/playlist';
107-
let deezerResourceId = 2002496842;
105+
let deezerApiBaseUrl = 'http://api.deezer.com';
106+
let deezerApiUri = '/playlist';
107+
let deezerResourceId = 2002496842;
108108

109-
let apiRequest = request({
110-
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId + '/tracks',
111-
method: 'GET',
112-
qs: parameters,
113-
json: true
114-
}, (error, response, body) => {
109+
let apiRequest = request({
110+
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId + '/tracks',
111+
method: 'GET',
112+
qs: parameters,
113+
json: true
114+
}, (error, response, body) => {
115115

116-
if ('error' in body) {
117-
// TODO: error
118-
}
116+
if ('error' in body) {
117+
// TODO: error
118+
}
119119

120-
// body:
121-
// checksum: string
122-
// data: string
123-
// next: string
124-
// total: number
120+
// body:
121+
// checksum: string
122+
// data: string
123+
// next: string
124+
// total: number
125125

126-
let playlistTracks = body.data;
126+
let playlistTracks = body.data;
127127

128-
console.log(playlistTracks);
128+
console.log(playlistTracks);
129129

130-
});
130+
});
131131

132-
/*let deezerApiUri = '/track';
133-
let deezerResourceId = 2002496842;
132+
/*let deezerApiUri = '/track';
133+
let deezerResourceId = 2002496842;
134134
135-
let apiRequest = request({
136-
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId,
137-
method: 'GET',
138-
qs: parameters,
139-
json: true
140-
}, (error, response, body) => {
135+
let apiRequest = request({
136+
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId,
137+
method: 'GET',
138+
qs: parameters,
139+
json: true
140+
}, (error, response, body) => {
141141
142-
if ('error' in body) {
143-
// TODO: error
144-
}
142+
if ('error' in body) {
143+
// TODO: error
144+
}
145145
146-
// body:
147-
// checksum: string
148-
// data: string
149-
// next: string
150-
// total: number
146+
// body:
147+
// checksum: string
148+
// data: string
149+
// next: string
150+
// total: number
151151
152-
let playlistTracks = body.data;
152+
let playlistTracks = body.data;
153153
154-
console.log(parsedResponse);
154+
console.log(parsedResponse);
155155
156-
});*/
156+
});*/
157157

158158

159159

160-
// asynchronous verification, for effect...
161-
process.nextTick(function () {
160+
// asynchronous verification, for effect...
161+
process.nextTick(function () {
162162

163-
// To keep the example simple, the user's Deezer profile is returned to
164-
// represent the logged-in user. In a typical application, you would want
165-
// to associate the Deezer account with a user record in your database,
166-
// and return that user instead.
167-
return done(null, profile);
168-
});
163+
// To keep the example simple, the user's Deezer profile is returned to
164+
// represent the logged-in user. In a typical application, you would want
165+
// to associate the Deezer account with a user record in your database,
166+
// and return that user instead.
167+
return done(null, profile);
169168

170-
}
171-
));
169+
});
170+
171+
}));
172172

173173
// GET /auth/deezer
174174
// Use passport.authenticate() as route middleware to authenticate the

examples/deezer-player/server/example-configuration.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
21
'use strict';
32

43
export interface IConfiguration {
5-
clientID: number,
6-
clientSecret: string
4+
clientID: number;
5+
clientSecret: string;
76
}
87

9-
export default class Configuration {
8+
export class Configuration implements IConfiguration {
109

11-
constructor() {
10+
readonly clientID: number;
11+
readonly clientSecret: string;
1212

13-
let configuration: IConfiguration = {
14-
clientID: 1111111111,
15-
clientSecret: '00000AAAAAAAAAA00000000BBBBBBBBBBB'
16-
};
13+
constructor() {
1714

18-
return configuration;
15+
this.clientID = 111111111111;
16+
this.clientSecret = '111111111111aaaaaaaaaaa111111111111';
1917

2018
}
2119

source/library/core.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface ICoreOptions {
1111
loopQueue?: boolean;
1212
soundsBaseUrl?: string;
1313
playingProgressIntervalTime?: number;
14+
playNextOnEnded?: boolean;
1415
}
1516

1617
export class PlayerCore {
@@ -51,7 +52,7 @@ export class PlayerCore {
5152
readonly PLAY_SOUND_FIRST = 'first';
5253
readonly PLAY_SOUND_LAST = 'last';
5354

54-
constructor(playerOptions: ICoreOptions) {
55+
constructor(playerOptions: ICoreOptions = {}) {
5556

5657
let defaultOptions = {
5758
volume: 80,

0 commit comments

Comments
 (0)