mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 00:31:20 -08:00
test(chapter): PKG-CHAPTER-02 cover behavior and optional factory types
This commit is contained in:
1 parent
701749520b
commit
12b047f9a6
17 files changed
+624
-15
No files matched your search
@@ -6,6 +6,36 @@ chapter plugin for ArtPlayer
|
||||
|
||||
[https://artplayer.org](https://artplayer.org/?libs=./uncompiled/artplayer-plugin-chapter/index.js&example=chapter)
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
import artplayerPluginChapter from 'artplayer-plugin-chapter'
|
||||
|
||||
const plugin = artplayerPluginChapter({
|
||||
chapters: [{ start: 0, end: Infinity, title: 'Introduction' }],
|
||||
})
|
||||
// Pass plugin to Artplayer's plugins array. Options may also be omitted.
|
||||
```
|
||||
|
||||
The registered name is `artplayerPluginChapter`. After metadata loads, use
|
||||
`art.plugins.artplayerPluginChapter.update({ chapters })` to replace the chapters, or
|
||||
`update({})` to clear them. Update is synchronous and requires an options object.
|
||||
Chapter times are seconds; ranges must not overlap. `Infinity` as an end value uses the current duration.
|
||||
|
||||
The existing implementation sorts and fills the supplied array in place and replaces its Infinity end
|
||||
values. Pass a fresh array when you need to retain the original configuration. After switching media,
|
||||
call update with chapters appropriate to the new duration; initialization listens to metadata once.
|
||||
|
||||
## Maintenance
|
||||
|
||||
The implementation is currently in `src/index.js`, styles in `src/style.less`, and public declarations
|
||||
in `types/artplayer-plugin-chapter.d.ts`. Its migration contracts and known defects are recorded in
|
||||
[the chapter contract](../../refactor/baselines/chapter-contract.md).
|
||||
|
||||
Run `yarn test:browser chapter.spec.js` for published/current plugin behavior on the published core.
|
||||
Run `yarn typecheck` and `yarn test:baseline` for strict consumer checks, including optional factory
|
||||
arguments and invalid data. `yarn build:ts` regenerates the online editor declarations.
|
||||
|
||||
## License
|
||||
|
||||
MIT © Harvey Zhao
|
||||
@@ -15,6 +15,6 @@ interface Result {
|
||||
update: (option: Option) => void
|
||||
}
|
||||
|
||||
declare const artplayerPluginChapter: (option: Option) => (art: Artplayer) => Result
|
||||
declare const artplayerPluginChapter: (option?: Option) => (art: Artplayer) => Result
|
||||
|
||||
export default artplayerPluginChapter
|
||||
Reference in new issue
Block a user