Skip to content

Commit

Permalink
Player: change file
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed Mar 22, 2016
1 parent e72fb22 commit dc200ec
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function Player(filename) {
priv.set(this, state);

Object.defineProperties(this, {
file: {
get: () => state.filename,
},
currentTime: {
get: () => Number(state.currentTime.toFixed(3)),
},
Expand All @@ -77,7 +80,7 @@ Player.prototype.play = function(input, time) {
return this;
}

if (typeof time === 'undefined') {
if (typeof time === 'undefined' || input === 'undefined') {
time = 0;
}

Expand Down
25 changes: 25 additions & 0 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ exports['av.Player'] = {
test.done();
},

playMp3ImpliedAll: function(test) {
test.expect(4);
var player = new av.Player('foo.mp3');
player.play();

test.equal(player.isPlaying, true);
test.equal(this.spawn.callCount, 1);
test.equal(this.spawn.lastCall.args[0], 'madplay');
test.deepEqual(this.spawn.lastCall.args[1], ['foo.mp3', '-s', 0]);
test.done();
},

playMp3ImpliedStartAtZero: function(test) {
test.expect(4);
var player = new av.Player();
Expand Down Expand Up @@ -386,5 +398,18 @@ exports['av.Player'] = {
test.done();
},

playDifferentMp3: function(test) {
test.expect(5);
var player = new av.Player('foo.mp3');
player.play('bar.mp3');

test.equal(player.isPlaying, true);
test.equal(this.spawn.callCount, 1);
test.equal(this.spawn.lastCall.args[0], 'madplay');
test.deepEqual(this.spawn.lastCall.args[1], ['bar.mp3', '-s', 0]);
test.equal(player.file, 'bar.mp3');
test.done();
},

// To Do: more detailed tests for pause time updates
};

0 comments on commit dc200ec

Please sign in to comment.