-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Feature/current source #2678
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -614,10 +614,13 @@ class Player extends Component { | |
|
||
if (source) { | ||
this.currentType_ = source.type; | ||
|
||
if (source.src === this.cache_.src && this.cache_.currentTime > 0) { | ||
techOptions.startTime = this.cache_.currentTime; | ||
} | ||
|
||
this.cache_.sources = null; | ||
this.cache_.source = source; | ||
this.cache_.src = source.src; | ||
} | ||
|
||
|
@@ -1975,7 +1978,10 @@ class Player extends Component { | |
// the tech loop to check for a compatible technology | ||
this.sourceList_([source]); | ||
} else { | ||
this.cache_.sources = null; | ||
this.cache_.source = source; | ||
this.cache_.src = source.src; | ||
|
||
this.currentType_ = source.type || ''; | ||
|
||
// wait until the tech is ready to set the source | ||
|
@@ -2025,6 +2031,8 @@ class Player extends Component { | |
// load this technology with the chosen source | ||
this.loadTech_(sourceTech.tech, sourceTech.source); | ||
} | ||
|
||
this.cache_.sources = sources; | ||
} else { | ||
// We need to wrap this in a timeout to give folks a chance to add error event handlers | ||
this.setTimeout(function() { | ||
|
@@ -2061,6 +2069,41 @@ class Player extends Component { | |
return this; | ||
} | ||
|
||
/** | ||
* Returns the current source objects. | ||
* | ||
* @return {Object[]} The current source objects | ||
* @method currentSources | ||
*/ | ||
currentSources() { | ||
const source = this.currentSource(); | ||
const sources = []; | ||
|
||
// assume `{}` or `{ src }` | ||
if (Object.keys(source).length !== 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seemed like a fine There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
sources.push(source); | ||
} | ||
|
||
return this.cache_.sources || sources; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we do the work of setting up the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know off the top of your head that I most likely implemented this to follow suit of the original implementation—thinking that there will be a difference between I can investigate further if unknown. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
/** | ||
* Returns the current source object. | ||
* | ||
* @return {Object} The current source object | ||
* @method currentSource | ||
*/ | ||
currentSource() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated to return |
||
const source = {}; | ||
const src = this.currentSrc(); | ||
|
||
if (src) { | ||
source.src = src; | ||
} | ||
|
||
return this.cache_.source || source; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here. |
||
} | ||
|
||
/** | ||
* Returns the fully qualified URL of the current source value e.g. http://mysite.com/video.mp4 | ||
* Can be used in conjuction with `currentType` to assist in rebuilding the current source object. | ||
|
There was a problem hiding this comment.
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''