mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 23:51:20 -08:00
feat: enhance Artplayer type definitions and improve component interfaces
- Updated Artplayer class to specify environment as 'development' | 'production'. - Refined template query method to return specific element types. - Improved event proxy method to handle multiple event names. - Enhanced storage get method to support both key retrieval and full record retrieval. - Modified i18n interface to include language initialization and partial language records. - Adjusted notice interface to provide a getter for show state and a setter for messages. - Updated layers, controls, and contextmenu to allow undefined elements. - Enhanced subtitle interface with initialization method. - Refined hotkey methods to use KeyboardEvent instead of Event. - Updated setting methods to return updated settings instead of arrays. - Improved plugin method to return a promise. - Added new events for video handling and refined existing event parameters. - Enhanced option interface for proxy and plugins to support promises. - Updated player interface to include reset method. - Refined setting props to allow optional values. - Enhanced template interface with additional control elements. - Improved utils methods for querying and manipulating DOM elements. fix: update type definitions for notice and subtitle properties, and refine event types fix: remove unnecessary console warnings in event listener error handling fix: refactor event listener management to use Set for better performance and error handling
This commit is contained in:
1 parent
f5f3800449
commit
4681a8bc7a
16 files changed
+152
-94
No files matched your search
@@ -3,21 +3,30 @@ import { def } from '../utils'
|
||||
export default function switchMix(art) {
|
||||
function switchUrl(url, currentTime) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (url === art.url)
|
||||
if (url === art.url) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
const { playing, aspectRatio, playbackRate } = art
|
||||
|
||||
art.pause()
|
||||
art.url = url
|
||||
art.notice.show = ''
|
||||
|
||||
art.once('video:error', reject)
|
||||
const handlers = {}
|
||||
|
||||
art.once('video:loadedmetadata', () => {
|
||||
handlers.error = (error) => {
|
||||
art.off('video:canplay', handlers.canplay)
|
||||
art.off('video:loadedmetadata', handlers.metadata)
|
||||
reject(error)
|
||||
}
|
||||
|
||||
handlers.metadata = () => {
|
||||
art.currentTime = currentTime
|
||||
})
|
||||
}
|
||||
|
||||
art.once('video:canplay', async () => {
|
||||
handlers.canplay = async () => {
|
||||
art.off('video:error', handlers.error)
|
||||
art.playbackRate = playbackRate
|
||||
art.aspectRatio = aspectRatio
|
||||
|
||||
@@ -28,7 +37,11 @@ export default function switchMix(art) {
|
||||
art.notice.show = ''
|
||||
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
||||
art.once('video:error', handlers.error)
|
||||
art.once('video:loadedmetadata', handlers.metadata)
|
||||
art.once('video:canplay', handlers.canplay)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user