-
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
Add getVideoPlaybackQuality API #4286
Changes from 3 commits
a78e351
4ac211e
43a7914
bf5d881
c7f7b45
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 |
---|---|---|
|
@@ -341,6 +341,29 @@ class Flash extends Tech { | |
return false; | ||
} | ||
|
||
/** | ||
* Gets available media playback quality metrics as specified by the W3C's Media | ||
* Playback Quality API. | ||
* | ||
* @see https://wicg.github.io/media-playback-quality/ | ||
* | ||
* @return {Object} | ||
* An object with supported media playback quality metrics | ||
*/ | ||
getVideoPlaybackQuality() { | ||
const videoPlaybackQuality = this.el_.vjs_getProperty('getVideoPlaybackQuality'); | ||
|
||
if (window.performance && typeof window.performance.now === 'function') { | ||
videoPlaybackQuality.creationTime = window.performance.now(); | ||
} else if (window.performance && | ||
window.performance.timing && | ||
typeof window.performance.timing.navigationStart === 'number') { | ||
videoPlaybackQuality.creationTime = | ||
window.Date.now() - window.performance.timing.navigationStart; | ||
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. did we decide to have no value for 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. By looking at the tests, I guess the answer is yes. |
||
} | ||
|
||
return videoPlaybackQuality; | ||
} | ||
} | ||
|
||
// Create setters and getters for attributes | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -794,6 +794,40 @@ class Html5 extends Tech { | |
} | ||
} | ||
} | ||
|
||
/** | ||
* Gets available media playback quality metrics as specified by the W3C's Media | ||
* Playback Quality API. | ||
* | ||
* @see https://wicg.github.io/media-playback-quality/ | ||
* | ||
* @return {Object} | ||
* An object with supported media playback quality metrics | ||
*/ | ||
getVideoPlaybackQuality() { | ||
if (typeof this.el().getVideoPlaybackQuality === 'function') { | ||
return this.el().getVideoPlaybackQuality(); | ||
} | ||
|
||
const videoPlaybackQuality = {}; | ||
|
||
if (typeof this.el().webkitDroppedFrameCount !== 'undefined' && | ||
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. is it possible for only one to be available but not the other? 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. Judging by https://bugs.webkit.org/attachment.cgi?id=80515&action=diff (which I think is the right patch), the webkit prefixed properties were added at the same time. As for the mozilla prefixed properties, there do seem to be some: |
||
typeof this.el().webkitDecodedFrameCount !== 'undefined') { | ||
videoPlaybackQuality.droppedVideoFrames = this.el().webkitDroppedFrameCount; | ||
videoPlaybackQuality.totalVideoFrames = this.el().webkitDecodedFrameCount; | ||
} | ||
|
||
if (window.performance && typeof window.performance.now === 'function') { | ||
videoPlaybackQuality.creationTime = window.performance.now(); | ||
} else if (window.performance && | ||
window.performance.timing && | ||
typeof window.performance.timing.navigationStart === 'number') { | ||
videoPlaybackQuality.creationTime = | ||
window.Date.now() - window.performance.timing.navigationStart; | ||
} | ||
|
||
return videoPlaybackQuality; | ||
} | ||
} | ||
|
||
/* HTML5 Support Testing ---------------------------------------------------- */ | ||
|
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.
elsewhere we use something like:
And in the other comments.