Skip to content

Commit

Permalink
doc: update
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Oct 31, 2023
1 parent 62d4a41 commit c0ec39c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
53 changes: 53 additions & 0 deletions packages/docs/src/pages/plugins/playlist.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,56 @@ Player.make('#player')
])
.create()
```
## methods

```ts
export default class PlaylistPlugin implements PlayerPlugin {
key: string;
name: string;
version: string;
static m3u8Parser: any;
player: Player<Ctx>;
currentIndex?: number;
$root: HTMLDivElement;
options: PartialRequired<PlaylistOptions, 'autoNext' | 'autoHide'>;
constructor(options?: PlaylistOptions);
apply(player: Player): this | undefined;
_init(): Promise<void>;
get isWaiting(): boolean;
changeSource(idx: number): Promise<void>;
changeSourceList(sources: PlaylistSource[]): void;
next(): void;
previous(): void;
showUI(): void;
hideUI(): void;
render(): void;
renderList(sources: PlaylistSource[]): void;
destroy(): void;
}

interface Segment {
uri: string;
timeline: number;
title: string;
}

export interface PlaylistOptions {
sources: PlaylistSource[];
customFetcher?: (source: PlaylistSource, index: number) => Promise<PlaylistSource> | PlaylistSource;
autoNext?: boolean;
autoHide?: boolean;
initialIndex?: number;
m3uList?: {
sourceFormat?: (info: Segment) => Source;
} | true;
}

export interface PlaylistSource extends Omit<Source, 'src'> {
src?: string;
duration?: string;
subtitles?: SubtitleSource[];
thumbnails?: Thumbnails;
highlights?: Highlight[];
}

```
2 changes: 1 addition & 1 deletion packages/docs/src/pages/plugins/vtt-thumbnails.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import Player from '@oplayer/react'
import ui from '@oplayer/ui'
import { vttThumbnails } from '@oplayer/plugins'

Player.make('#player').use([ui(), vttThumbnails]).create()
Player.make('#player').use([ui(), vttThumbnails({ src:'your-path' })]).create()
```
2 changes: 1 addition & 1 deletion packages/plugins/src/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export default class PlaylistPlugin implements PlayerPlugin {
const { src, poster, format, title, subtitles, thumbnails, highlights } = source

if (!src) return this.player.context.ui.notice('Empty Source')
this.currentIndex = idx

this.player
.changeSource({ src, poster, format, title })
Expand All @@ -140,7 +141,6 @@ export default class PlaylistPlugin implements PlayerPlugin {
this.player.context.ui.changHighlightSource(highlights)
}

this.currentIndex = idx
this.player.emit('playlistsourcechange', { source, id: idx })
this.$root.querySelector('.playlist-list-item.active')?.classList.remove('active')
this.$root.querySelector(`.playlist-list-item[data-index='${idx}']`)?.classList.add('active')
Expand Down

1 comment on commit c0ec39c

@vercel
Copy link

@vercel vercel bot commented on c0ec39c Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

oplayer – ./

oplayer-shiyiya.vercel.app
oplayer-git-main-shiyiya.vercel.app
oplayer.vercel.app

Please sign in to comment.