Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/current source #2678

Merged
merged 3 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,15 @@ class Player extends Component {
* @method currentSources
*/
currentSources() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to return [] when src is ''

return this.cache_.sources || [this.currentSource()];
const source = this.currentSource();
const sources = [];

// assume `{}` or `{ src }`
if (Object.keys(source).length !== 0) {
Copy link
Member Author

@chemoish chemoish Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seemed like a fine isEmpty check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I don't know if it's merged yet, but I introduced utils/obj in a PR recently. An isEmpty could be useful there. If not, this is fine, I think.

sources.push(source);
}

return this.cache_.sources || sources;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do the work of setting up the sources variable if we're just going to return this.cache_.sources?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know off the top of your head that sources will never get called because this.cache_ will always be present?

I most likely implemented this to follow suit of the original implementation—thinking that there will be a difference between <source> and src, but since the PR been open for some time I have no idea anymore.

I can investigate further if unknown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is a big concern. It's fine to leave as is and we can always profile and increase performance in the future.

}

/**
Expand All @@ -2086,7 +2094,14 @@ class Player extends Component {
* @method currentSource
*/
currentSource() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to return {} when src is ''

return this.cache_.source || { src: this.currentSrc() };
const source = {};
const src = this.currentSrc();

if (src) {
source.src = src;
}

return this.cache_.source || source;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question here.

}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ QUnit.test('should get current source from src set', function(assert) {
player.loadTech_('Html5');

// check for matching undefined src
assert.ok(player.currentSource().src === player.currentSrc());
assert.deepEqual(player.currentSource(), {});

player.src('http://google.com');

Expand Down Expand Up @@ -216,7 +216,7 @@ QUnit.test('should get current sources from src set', function(assert) {
player.loadTech_('Html5');

// check for matching undefined src
assert.ok(player.currentSource().src === player.currentSrc());
assert.ok(player.currentSources(), []);

player.src([{
src: 'http://google.com'
Expand Down
3 changes: 3 additions & 0 deletions test/unit/tech/tech-faker.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class TechFaker extends Tech {
src() {
return 'movie.mp4';
}
currentSrc() {
return 'movie.mp4';
}
volume() {
return 0;
}
Expand Down