if (this.clipEndSeconds) {
this.looping = true
}
window.player.currentTime = this.clipStartSeconds
window.player.play()
},
copyCurrentTime(field) {
const currentTime = Math.floor(window.player.currentTime)
const hour = Math.floor(currentTime / 3600).toString().padStart(2, ‘0’)
const minute = Math.floor(currentTime % 3600 / 60).toString().padStart(2, ‘0’)
const second = (currentTime % 60).toString().padStart(2, ‘0’)
this[field] = `${hour}:${minute}:${second}`
},
isValidClipTime(clipTime) {
return clipTime && clipTime.match(/^(?:(?:([01]?d|2[0-3]):)?([0-5]?d):)?([0-5]?d)$/)
},
updateHash() {
let hash = this.baseUrl
if (this.clipStartSeconds > 0 && this.isValidClipTime(this.clipStartTime)) {
hash += `#${this.clipStartTime}`
if (this.clipEndSeconds > 0 && this.isValidClipTime(this.clipEndTime)) {
hash += `-${this.clipEndTime}`
}
}
history.replaceState(null, null, hash)
window.dispatchEvent(new CustomEvent(‘hashUpdated’))
},
pop() {
if (Date.now() – this.popped.timestamp > 86400 * 1000 && this.popped.urls.length > 0) {
this.popped.urls = []
}
const directUrls = (window.navigator.userAgent.includes(‘iPhone’) ? this.directUrlsIphone : this.directUrls)
.map(value => ({ value, sort: Math.random() }))
.sort((a, b) => a.sort – b.sort)
.map(({ value }) => value)
const nextDirectUrl = directUrls.find(directUrl => ! this.popped.urls.includes(directUrl))
if (nextDirectUrl) {
this.popped.urls.push(nextDirectUrl)
this.popped.timestamp = Date.now()
const popWindow = window.open(`/pop?url=${encodeURIComponent(nextDirectUrl)}`, ‘_blank’)
const timer = setInterval(() => {
if (popWindow.closed) {
clearInterval(timer)
window.player.play()
}
}, 300)
}
},
}”>