Skip to content

Commit

Permalink
make core options optional
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisweb committed Mar 11, 2017
1 parent 1ea9f5c commit 28f1c22
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 70 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ in the meantime check out what's in the examples directory (especially the [simp

## TODOs

* make the core player options object optinal when initializing a new player
* 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)
* allow cross fading songs "on end" if it's the next song in a playlist
* create a web component UI (http://www.w3.org/TR/components-intro/)!?
Expand Down Expand Up @@ -74,3 +73,4 @@ in the meantime check out what's in the examples directory (especially the [simp
* play next song onEnded, add option to enable or disable automatic play next onEnded
* add change position method
* add loop queue option
* make the core player options object optinal when initializing a new player
3 changes: 2 additions & 1 deletion build/@types/web-audio-api-player/library/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface ICoreOptions {
loopQueue?: boolean;
soundsBaseUrl?: string;
playingProgressIntervalTime?: number;
playNextOnEnded?: boolean;
}
export declare class PlayerCore {
protected _isWebAudioApiSupported: boolean;
Expand All @@ -28,7 +29,7 @@ export declare class PlayerCore {
readonly PLAY_SOUND_PREVIOUS: string;
readonly PLAY_SOUND_FIRST: string;
readonly PLAY_SOUND_LAST: string;
constructor(playerOptions: ICoreOptions);
constructor(playerOptions?: ICoreOptions);
protected _initialize(): void;
addSoundToQueue(soundAttributes: ISoundAttributes, whereInQueue?: string): ISound;
_appendSoundToQueue(sound: ISound): void;
Expand Down
3 changes: 2 additions & 1 deletion build/library/core.js

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions examples/deezer-player/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,83 +92,83 @@ export default class Bootsrtrap {
callbackURL: DEEZER_CALLBACK_URL,
scope: DEEZER_SCOPE
},
function (accessToken: string, refreshToken: string | undefined, profile: passport.Profile, done: Function) {
function (accessToken: string, refreshToken: string | undefined, profile: passport.Profile, done: Function) {

console.log(accessToken, refreshToken, profile);
console.log(accessToken, refreshToken, profile);

let parameters = {
access_token: accessToken
// index (default 0)
// limit (default 25)
};
let parameters = {
access_token: accessToken
// index (default 0)
// limit (default 25)
};

let deezerApiBaseUrl = 'http://api.deezer.com';
let deezerApiUri = '/playlist';
let deezerResourceId = 2002496842;
let deezerApiBaseUrl = 'http://api.deezer.com';
let deezerApiUri = '/playlist';
let deezerResourceId = 2002496842;

let apiRequest = request({
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId + '/tracks',
method: 'GET',
qs: parameters,
json: true
}, (error, response, body) => {
let apiRequest = request({
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId + '/tracks',
method: 'GET',
qs: parameters,
json: true
}, (error, response, body) => {

if ('error' in body) {
// TODO: error
}
if ('error' in body) {
// TODO: error
}

// body:
// checksum: string
// data: string
// next: string
// total: number
// body:
// checksum: string
// data: string
// next: string
// total: number

let playlistTracks = body.data;
let playlistTracks = body.data;

console.log(playlistTracks);
console.log(playlistTracks);

});
});

/*let deezerApiUri = '/track';
let deezerResourceId = 2002496842;
/*let deezerApiUri = '/track';
let deezerResourceId = 2002496842;
let apiRequest = request({
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId,
method: 'GET',
qs: parameters,
json: true
}, (error, response, body) => {
let apiRequest = request({
url: deezerApiBaseUrl + deezerApiUri + '/' + deezerResourceId,
method: 'GET',
qs: parameters,
json: true
}, (error, response, body) => {
if ('error' in body) {
// TODO: error
}
if ('error' in body) {
// TODO: error
}
// body:
// checksum: string
// data: string
// next: string
// total: number
// body:
// checksum: string
// data: string
// next: string
// total: number
let playlistTracks = body.data;
let playlistTracks = body.data;
console.log(parsedResponse);
console.log(parsedResponse);
});*/
});*/



// asynchronous verification, for effect...
process.nextTick(function () {
// asynchronous verification, for effect...
process.nextTick(function () {

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

}
));
});

}));

// GET /auth/deezer
// Use passport.authenticate() as route middleware to authenticate the
Expand Down
18 changes: 8 additions & 10 deletions examples/deezer-player/server/example-configuration.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@

'use strict';

export interface IConfiguration {
clientID: number,
clientSecret: string
clientID: number;
clientSecret: string;
}

export default class Configuration {
export class Configuration implements IConfiguration {

constructor() {
readonly clientID: number;
readonly clientSecret: string;

let configuration: IConfiguration = {
clientID: 1111111111,
clientSecret: '00000AAAAAAAAAA00000000BBBBBBBBBBB'
};
constructor() {

return configuration;
this.clientID = 111111111111;
this.clientSecret = '111111111111aaaaaaaaaaa111111111111';

}

Expand Down
3 changes: 2 additions & 1 deletion source/library/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ICoreOptions {
loopQueue?: boolean;
soundsBaseUrl?: string;
playingProgressIntervalTime?: number;
playNextOnEnded?: boolean;
}

export class PlayerCore {
Expand Down Expand Up @@ -51,7 +52,7 @@ export class PlayerCore {
readonly PLAY_SOUND_FIRST = 'first';
readonly PLAY_SOUND_LAST = 'last';

constructor(playerOptions: ICoreOptions) {
constructor(playerOptions: ICoreOptions = {}) {

let defaultOptions = {
volume: 80,
Expand Down

0 comments on commit 28f1c22

Please sign in to comment.