mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Export VideoChangeCallback
This commit is contained in:
parent
49c9cd74e4
commit
226deff5c0
@ -1,6 +1,5 @@
|
|||||||
import { ComponentMetadata } from '@/components/types'
|
import { ComponentMetadata } from '@/components/types'
|
||||||
import { videoChange } from '@/core/observer'
|
import { videoChange, VideoChangeCallback } from '@/core/observer'
|
||||||
import { select } from '@/core/spin-query'
|
|
||||||
import { createHook, isBwpVideo } from '@/core/utils'
|
import { createHook, isBwpVideo } from '@/core/utils'
|
||||||
import { playerUrls } from '@/core/utils/urls'
|
import { playerUrls } from '@/core/utils/urls'
|
||||||
|
|
||||||
@ -12,8 +11,7 @@ const entry = async () => {
|
|||||||
removeCover()
|
removeCover()
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
const showCover = async () => {
|
const showCover: VideoChangeCallback = async ({ aid }) => {
|
||||||
const aid = await select(() => unsafeWindow.aid)
|
|
||||||
if (!aid) {
|
if (!aid) {
|
||||||
console.warn('[播放前显示封面] 未找到av号')
|
console.warn('[播放前显示封面] 未找到av号')
|
||||||
return
|
return
|
||||||
@ -25,9 +23,6 @@ const entry = async () => {
|
|||||||
const { VideoInfo } = await import('@/components/video/video-info')
|
const { VideoInfo } = await import('@/components/video/video-info')
|
||||||
const info = new VideoInfo(aid)
|
const info = new VideoInfo(aid)
|
||||||
await info.fetchInfo()
|
await info.fetchInfo()
|
||||||
// if (!(dq('video') as HTMLVideoElement).paused) {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
document.body.style.setProperty('--cover-url', `url('${info.coverUrl}')`)
|
document.body.style.setProperty('--cover-url', `url('${info.coverUrl}')`)
|
||||||
}
|
}
|
||||||
videoChange(showCover)
|
videoChange(showCover)
|
||||||
|
|||||||
@ -245,7 +245,7 @@ const selectCid = lodash.once(() => select(() => {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
let cidHooked = false
|
let cidHooked = false
|
||||||
type VideoChangeCallback = (id: { aid: string; cid: string }) => void
|
export type VideoChangeCallback = (id: { aid: string; cid: string }) => void
|
||||||
/**
|
/**
|
||||||
* 监听视频的变化, 等待视频加载并开始监听后 resolve
|
* 监听视频的变化, 等待视频加载并开始监听后 resolve
|
||||||
* @param callback 回调函数
|
* @param callback 回调函数
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user