2016-08-16 04:00:56 +00:00
|
|
|
window.GoogleDrivePlayer = class GoogleDrivePlayer extends VideoJSPlayer
|
|
|
|
constructor: (data) ->
|
|
|
|
if not (this instanceof GoogleDrivePlayer)
|
|
|
|
return new GoogleDrivePlayer(data)
|
|
|
|
|
|
|
|
super(data)
|
2016-08-20 17:59:20 +00:00
|
|
|
|
|
|
|
load: (data) ->
|
2017-03-04 07:39:38 +00:00
|
|
|
if not window.hasDriveUserscript
|
2016-10-08 17:33:18 +00:00
|
|
|
window.promptToInstallDriveUserscript()
|
|
|
|
else if window.hasDriveUserscript
|
|
|
|
window.maybePromptToUpgradeUserscript()
|
2016-08-20 17:59:20 +00:00
|
|
|
if typeof window.getGoogleDriveMetadata is 'function'
|
2016-10-08 17:33:18 +00:00
|
|
|
setTimeout(=>
|
|
|
|
backoffRetry((cb) ->
|
|
|
|
window.getGoogleDriveMetadata(data.id, cb)
|
|
|
|
, (error, metadata) =>
|
|
|
|
if error
|
|
|
|
console.error(error)
|
|
|
|
alertBox = window.document.createElement('div')
|
|
|
|
alertBox.className = 'alert alert-danger'
|
|
|
|
alertBox.textContent = error
|
|
|
|
document.getElementById('ytapiplayer').appendChild(alertBox)
|
|
|
|
else
|
|
|
|
data.meta.direct = metadata.videoMap
|
|
|
|
super(data)
|
|
|
|
, {
|
|
|
|
maxTries: 3
|
|
|
|
delay: 1000
|
|
|
|
factor: 1.2
|
|
|
|
jitter: 500
|
|
|
|
})
|
|
|
|
, Math.random() * 1000)
|