Updated player.js

This commit is contained in:
Bobby Wibowo 2020-11-04 00:21:55 +07:00
parent c16dac81ea
commit 5426c6f98d
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -61,7 +61,7 @@ page.reloadVideo = () => {
const src = `${page.uploadRoot}/${page.urlInput.value}` const src = `${page.uploadRoot}/${page.urlInput.value}`
axios.head(src).then(response => { axios.head(src).then(response => {
if (response.status !== 200 && response.status !== 304) { if (![200, 304].includes(response.status)) {
page.toggleReloadBtn(true) page.toggleReloadBtn(true)
return page.onAxiosError(response) return page.onAxiosError(response)
} }
@ -74,6 +74,8 @@ page.reloadVideo = () => {
return swal('An error occurred!', 'The requested upload does not appear to be a media file.', 'error') return swal('An error occurred!', 'The requested upload does not appear to be a media file.', 'error')
} }
page.urlIdentifier = page.urlInput.value
if (page.player) { if (page.player) {
page.player.dispose() page.player.dispose()
page.videoContainer.innerHTML = '' page.videoContainer.innerHTML = ''
@ -112,14 +114,14 @@ page.reloadVideo = () => {
page.player.seekButtons({ forward: 10, back: 10 }) page.player.seekButtons({ forward: 10, back: 10 })
if (page.titleFormat) { if (page.titleFormat) {
document.title = page.titleFormat.replace(/%identifier%/g, page.urlInput.value) document.title = page.titleFormat.replace(/%identifier%/g, page.urlIdentifier)
} }
if (page.downloadBtn) { if (page.downloadBtn) {
page.downloadBtn.setAttribute('href', src) page.downloadBtn.setAttribute('href', src)
} }
window.history.pushState(null, null, page.urlPrefix + page.urlInput.value) window.history.pushState(null, null, page.urlPrefix + page.urlIdentifier)
page.toggleReloadBtn(true) page.toggleReloadBtn(true)
}).catch(error => { }).catch(error => {
page.toggleReloadBtn(true) page.toggleReloadBtn(true)