Skip to content

Instantly share code, notes, and snippets.

@marcelbeumer
Created August 7, 2019 12:53
Show Gist options
  • Save marcelbeumer/e6a881ff9b40d83d3a04827b0068f87f to your computer and use it in GitHub Desktop.
Save marcelbeumer/e6a881ff9b40d83d3a04827b0068f87f to your computer and use it in GitHub Desktop.
this.player.on('timeupdate', function() {
// PATCHED BY [email protected]:
// - fix errors when HLS does not have resolution info
var a = this
clearTimeout(n),
(s = !1),
Date.now(),
i.eventCallback(l.Event.TIMECHANGED, { currentTime: this.currentTime() })
var r = this.tech_.hls.playlists.media()
if (r) {
var o = r.attributes,
E = o.BANDWIDTH,
c = (o.RESOLUTION || {}).width, // PATCHED
u = (o.RESOLUTION || {}).height // PATCHED
if (t !== E) {
var d = { width: c, height: u, bitrate: E, currentTime: this.currentTime() }
i.eventCallback(l.Event.VIDEO_CHANGE, d), (t = E)
}
if (
((n = window.setTimeout(function() {
;((!a.paused() && !a.ended()) || s) &&
i.eventCallback(l.Event.START_BUFFERING, { currentTime: a.currentTime() })
}, e.BUFFERING_TIMECHANGED_TIMEOUT)),
this.tech({ IWillNotUseThisInPlugins: !0 }).hls)
) {
var h = this.tech_.hls
if (!h.playlists || 'function' != typeof h.playlists.media) return
var m = h.playlists.media()
if (!m) return
var p = m.attributes,
A = p.BANDWIDTH,
f = (p.RESOLUTION || {}).width, // PATCHED
v = (p.RESOLUTION || {}).height // PATCHED
if (isNaN(t) || t !== A) {
d = { width: f, height: v, bitrate: A, currentTime: this.currentTime() }
i.eventCallback(l.Event.VIDEO_CHANGE, d), (t = A)
}
}
}
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment