Skip to content

Commit

Permalink
0.2: Bugfix: fix a indexOf typo
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yu committed Dec 2, 2014
1 parent 3317f35 commit ba5c904
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .npmignore
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
.DS_*
npm-debug.*
*.sublime*
thumb
thumb
41 changes: 25 additions & 16 deletions examples/add.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,49 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
__dirname + '/demo.mp3'
]);

player.play(function(err) {
console.log('all songs play end');
debug('all songs play end');
});

player.on('downloading', function(song) {
console.log('im downloading... ');
console.log(song);
debug('I\'m downloading... ');
debug(song);
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
console.log('add new song');
if (song._id === 0) {

debug('I\'m playing... ');
debug(song);
debug('Add new song');

if (song._id === 0)
player.add('http://node-player.qiniudn.com/demo2.mp3');
}
console.log('and I\'ll switch to next song in 3s:');

debug('Will switch to next song in 3s:');

setTimeout(function(){
console.log('switch now !');
debug('Switching...');

player.next(function(err, song){
if (!err) return console.log('switched !!');
return console.log(err);
if (!err)
return debug('Switched !!');

return debug(err);
});

}, 3000);
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('play done, switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
});
debug('Opps...!')
debug(err);
});
16 changes: 9 additions & 7 deletions examples/local.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
__dirname + '/demo.mp3',
__dirname + '/demo2.mp3'
]);

player.play(function(err) {
console.log('all songs play end');
debug('All songs play end');
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
debug('I\'m playing... ');
debug(song);
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('Play done, Switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
});
debug('Opps...!')
debug(err);
});
26 changes: 15 additions & 11 deletions examples/next.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
__dirname + '/demo.mp3',
Expand All @@ -10,27 +12,29 @@ var player = new Player([
]);

player.play(function(err) {
console.log('all songs play end');
debug('all songs play end');
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
console.log('and I\'ll switch to next song in 3s:');
debug('im playing... ');
debug(song);
debug('and I\'ll switch to next song in 3s:');

setTimeout(function(){
console.log('switch now !');
debug('switch now !');

player.next(function(err, song){
if (!err) return console.log('switched !!');
return console.log(err);
if (!err) return debug('switched !!');
return debug(err);
});
}, 3000);
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('play done, switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
});
debug('Opps...!')
debug(err);
});
18 changes: 10 additions & 8 deletions examples/online-proxy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
'http://node-player.qiniudn.com/demo.mp3',
Expand All @@ -8,24 +10,24 @@ var player = new Player([
});

player.play(function(err) {
console.log('all songs play end');
debug('all songs play end');
});

player.on('downloading', function(song) {
console.log('im downloading... ');
console.log(song);
debug('im downloading... ');
debug(song);
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
debug('im playing... ');
debug(song);
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('play done, switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
debug('Opps...!')
debug(err);
});
20 changes: 11 additions & 9 deletions examples/online.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
'http://node-player.qiniudn.com/demo.mp3',
'http://node-player.qiniudn.com/demo2.mp3'
]);

player.play(function(err) {
console.log('all songs play end');
debug('all songs play end');
});

player.on('downloading', function(song) {
console.log('im downloading... ');
console.log(song);
debug('im downloading... ');
debug(song);
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
debug('im playing... ');
debug(song);
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('play done, switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
});
debug('Opps...!')
debug(err);
});
14 changes: 8 additions & 6 deletions examples/playlist.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
__dirname + '/demo.mp3',
__dirname + '/demo2.mp3'
]);

console.log("Play List:" + player.playList());
debug("Play List:" + player.playList());

player.play(function(err) {
console.log('all songs play end');
console.log("Play List End:" + player.playList());
debug('all songs play end');
debug("Play List End:" + player.playList());
});

player.on('playend', function(song) {
console.log("Play List After Song Played:" + player.playList());
debug("Play List After Song Played:" + player.playList());
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
debug('Opps...!')
debug(err);
});
22 changes: 13 additions & 9 deletions examples/stop-at-last.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
__dirname + '/demo.mp3',
__dirname + '/demo2.mp3'
]);

player.play(function(err) {
console.log('all songs play end');
debug('all songs play end');
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
debug('im playing... ');
debug(song);

if (song._id > 0) {
console.log('and I\'ll stop in 5s:');
debug('and I\'ll stop in 5s:');

setTimeout(function(){
console.log('stopped now !');
debug('stopped now !');
player.stop();
}, 5000);
}
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('play done, switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
});
debug('Opps...!')
debug(err);
});
21 changes: 12 additions & 9 deletions examples/stop.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
var Player = require('../index');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player([
__dirname + '/demo.mp3',
__dirname + '/demo2.mp3'
]);

player.play(function(err) {
console.log('all songs play end');
debug('all songs play end');
});

player.on('playing', function(song) {
console.log('im playing... ');
console.log(song);
console.log('and I\'ll stop in 5s:');
debug('im playing... ');
debug(song);
debug('and I\'ll stop in 5s:');

setTimeout(function(){
console.log('stopped now !');
debug('stopped now !');
player.stop();
}, 5000)
});

player.on('playend', function(song) {
console.log('play done, switching to next one ...');
debug('play done, switching to next one ...');
});

player.on('error', function(err) {
console.log('Opps...!')
console.log(err);
});
debug('Opps...!')
debug(err);
});
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
* @Created: [2013/07/20]
*
**/
*

module.exports = require('./libs/player');
Loading

0 comments on commit ba5c904

Please sign in to comment.