Commit Graph
23 Commits
Author SHA1 Message Date
Anıl Çalışkol 0f47e11d63 fix: silence unhandled play() rejections from internal callers
`art.play()` is an async wrapper around the native `video.play()` promise, which
rejects when a pending play request is interrupted (`pause()`, `load()`, a new
`src`, or the element being removed) and when autoplay is blocked.

Every internal caller fires it from an event handler and cannot await it, so the
rejection escapes as a global `unhandledrejection`. Error trackers report it as
an uncaught crash even though the player recovers on its own — for example
destroying the player right after mount, which is routine when the video sits in
a modal the user can close quickly.

Add a `silencePromise` util (the same approach video.js uses) and apply it to the
non-awaited internal call sites: mask, play control, mini player, loop restart,
autoPlayback jump, hotkey and click toggles.

`switchMix` is fixed too, for a second symptom: `await art.play()` inside the
async `video:canplay` handler both leaked the rejection and left the `switchUrl`
promise pending forever, since the throw never reached the enclosing executor's
`reject`. It now settles.

The public API is unchanged: `art.play()` and `art.toggle()` still return the
original promise, so applications that call them keep their own rejection to
handle. Only the internal, non-awaited copy is silenced.
2026-08-30 16:31:40 +03:00
Harvey Zack 8af6f7c322 feat: Refactor global event handling in ArtPlayer
- Introduced a new globalInit function to manage document and window events.
- Replaced direct event proxies with a unified bindGlobalEvents method.
- Updated event handling in various modules to utilize the new global event system.
- Removed the deprecated documentInit module.
- Bumped version to 5.2.6 in package.json.
2025-08-16 20:45:19 +08:00
Harvey Zack 35ad9883af build all
Refactor utility functions for improved readability and consistency

- Updated compatibility.js to use consistent line endings and formatting.
- Refactored component.js for better readability and structure, including consistent use of arrow functions and binding.
- Simplified dom.js functions with consistent formatting and improved readability.
- Enhanced emitter.js with consistent formatting and arrow function usage.
- Streamlined error.js for improved readability and consistency.
- Refactored file.js to use consistent formatting and improved readability.
- Improved format.js functions for better readability and consistency.
- Updated index.js to maintain consistent export formatting.
- Refactored property.js for improved readability and consistency.
- Enhanced subtitle.js with consistent formatting and improved readability.
- Refactored time.js for better readability and consistent formatting.

fix: update lint script to target only source files for consistency

Revert "fix: restore export statements for various plugins and update type definitions for better clarity"

This reverts commit b5e969d81ec765cd8a34b06e6ef4f232ef25087f.

fix: restore export statements for various plugins and update type definitions for better clarity

Refactor type definitions to use interfaces instead of type aliases for better extensibility and clarity across i18n, icons, option, player, quality, setting, subtitle, template, and utils modules.
2025-08-03 13:17:33 +08:00
Harvey Zack 1210eb8a98 Fix indentation in clickInit.js 2024-03-30 11:13:13 +08:00
WeidiDeng 8038397185 record click timestamps to calculate number of clicks (#728)
* record click timestamps to calculate number of clicks

* break after each case
2024-03-30 11:07:25 +08:00
Harvey Zack fb445bf669 add DBCLICK_FULLSCREEN 2023-04-19 11:43:50 +08:00
Harvey Zack 677c99aa38 update events.d.ts 2023-04-19 02:55:29 +08:00
Harvey 2c5ba00521 add art.isLock 2022-05-16 13:09:08 +08:00
Harvey Zack 2b934ab988 add art.isInput 2022-05-15 07:42:28 +08:00
Harvey fc3abd7d1d separate variable constants 2022-04-27 10:42:07 +08:00
Harvey 9697a61526 add dblclick event 2022-04-21 17:05:01 +08:00
Harvey be3d97bf75 优化自动隐藏controls 2021-05-20 09:37:14 +08:00
Harvey dd1ae0f499 分离includeFromEvent函数 2020-08-24 09:28:59 +08:00
Harvey beea013daf 优化手机端UI 2020-05-15 10:28:38 +08:00
Harvey ac4e5a9c94 Revert "优化focus事件"
This reverts commit df424ec3ac.
2020-04-16 14:57:33 +08:00
Harvey df424ec3ac 优化focus事件 2020-04-16 12:18:26 +08:00
Harvey 51bde726ae 优化blur事件 2020-04-16 11:38:19 +08:00
zhw2590582 c7a351bc55 fix event.composedPath 2020-02-29 22:18:11 +08:00
Harvey 0cf455ced3 压缩字符 2019-11-28 10:56:53 +08:00
Harvey Zack 487e865017 优化整体结构 2019-04-30 13:06:24 +08:00
Harvey Zack 3fb41eedf7 分离template 2018-11-28 12:15:33 +08:00
Harvey Zack 203ad0d3a0 格式化 2018-11-21 19:45:44 +08:00
Harvey Zack 1d40d1c46b 分离事件中心 2018-11-09 12:17:19 +08:00