1234567891011121314151617181920212223242526272829 |
- /**
- *
- * @param src 视频路径
- * @returns Promise - 视频的总长度
- */
- export const videoLodingNumFu = (src: string): Promise<number> => {
- return new Promise((resolve, reject) => {
- const req = new XMLHttpRequest()
- req.open('HEAD', src, true)
- req.onreadystatechange = function () {
- if (req.readyState === 4) {
- if (req.status === 200) {
- const contentLength = req.getResponseHeader('Content-Length')
- if (contentLength) {
- const videoLength = parseInt(contentLength, 10)
- resolve(videoLength)
- }
- }
- }
- }
- req.send()
- })
- }
- export const domDelOwnFu = (classNmae: string) => {
- const dom = document.querySelector(classNmae)
- if (dom) dom.remove()
- }
|