-
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 2 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,26 @@ class Player extends Component { | |
return this; | ||
} | ||
|
||
/** | ||
* Returns the current source objects. | ||
* | ||
* @return {Object[]} The current source objects | ||
* @method currentSources | ||
*/ | ||
currentSources() { | ||
return this.cache_.sources || [this.currentSource()]; | ||
} | ||
|
||
/** | ||
* 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 |
||
return this.cache_.source || { src: this.currentSrc() }; | ||
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. if 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. That sounds fine to me. 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. My initial thought is to throw away all the code for Atm, I think it makes sense to translate that across those methods. currentSrc() === undefined
currentSource() === undefined
currentSources() === undefined
vs.
currentSrc() === undefined
currentSource() === { src: undefined } or {}
currentSources() === [{ src: undefined }] or [] So I would recommend 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 lean toward all three methods returning My second preference would be 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. Unfortunately, document.createElement('video').currentSrc
// "" As for the others, returning an empty object and empty array would make it consistent. Though, would be a bit annoying to check for whether it's empty or not. 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. Oh! I thought 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. Having |
||
} | ||
|
||
/** | ||
* 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''