Skip to content

Commit

Permalink
feat: auto refresh play url for aliyundrive
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Dec 4, 2023
1 parent 753e582 commit f6a910d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/pages/home/previews/aliyun_video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,40 @@ const Preview = () => {
player.subtitle.url = proxyLink(subtitle, true)
})
}
interval = window.setInterval(resetPlayUrl, 1000 * 60 * 14)
})
})
let interval: number
let curSeek: number
async function resetPlayUrl() {
const resp = await post()
handleResp(resp, async (data) => {
const list =
data.video_preview_play_info.live_transcoding_task_list.filter(
(l) => l.url,
)
if (list.length === 0) {
notify.error("No transcoding video found")
return
}
const quality = list.map((item, i) => {
return {
html: item.template_id,
url: item.url,
default: i === list.length - 1,
}
})
player.quality = quality
curSeek = player.currentTime
await player.switchUrl(quality[quality.length - 1].url)
setTimeout(() => {
player.seek = curSeek
}, 1000)
})
}
onCleanup(() => {
player?.destroy()
window.clearInterval(interval)
})
const [autoNext, setAutoNext] = createSignal()
return (
Expand Down

0 comments on commit f6a910d

Please sign in to comment.