mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-30 12:01:20 -08:00
refactor(mediabunny): [PKG-MB-08] checkpoint typed entry and compatible media declarations
This commit is contained in:
1 parent
8a2b56e829
commit
5e28dfee95
39 files changed
+3007
-287
No files matched your search
@@ -0,0 +1,6 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
import type { Option, Result } from './artplayer-proxy-mediabunny.js'
|
||||
|
||||
declare const artplayerProxyMediabunny: (option?: Option) => (art: Artplayer) => Result
|
||||
export default artplayerProxyMediabunny
|
||||
export type { HlsAudio, HlsLevel, HlsState, MediaBunnyCanvas, MediaBunnyPlayer, MediaBunnyShim, MediaListener, Option, Result, SyntheticFrameCallback, SyntheticFrameMetadata } from './artplayer-proxy-mediabunny.js'
|
||||
@@ -1,6 +1,6 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
|
||||
interface Option {
|
||||
export interface Option {
|
||||
m3u8?: {
|
||||
quality?: {
|
||||
control?: boolean
|
||||
@@ -101,7 +101,9 @@ interface Option {
|
||||
crossOrigin?: string
|
||||
}
|
||||
|
||||
type Result = HTMLCanvasElement
|
||||
export type Result = HTMLCanvasElement
|
||||
|
||||
export type { HlsAudio, HlsLevel, HlsState, MediaBunnyCanvas, MediaBunnyPlayer, MediaBunnyShim, MediaListener, SyntheticFrameCallback, SyntheticFrameMetadata } from './media'
|
||||
|
||||
declare const artplayerProxyMediabunny: (option?: Option) => (art: Artplayer) => Result
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import type Artplayer from 'artplayer'
|
||||
|
||||
export interface HlsLevel {
|
||||
id: number
|
||||
index: number
|
||||
name: string | null
|
||||
height: number
|
||||
bitrate: number
|
||||
/** SDK object; narrow with the SDK version used by your application. */
|
||||
track: unknown
|
||||
}
|
||||
|
||||
export interface HlsAudio {
|
||||
id: number
|
||||
index: number
|
||||
name: string | null
|
||||
lang: string
|
||||
language: string
|
||||
bitrate: number
|
||||
/** SDK object; narrow with the SDK version used by your application. */
|
||||
track: unknown
|
||||
}
|
||||
|
||||
export interface HlsState {
|
||||
levels: HlsLevel[]
|
||||
audios: HlsAudio[]
|
||||
currentLevel: HlsLevel | null
|
||||
currentAudio: HlsAudio | null
|
||||
videoMode: 'auto' | 'manual'
|
||||
audioMode: 'auto' | 'manual'
|
||||
}
|
||||
|
||||
/** Historical RAF estimates, not decoded-frame or network timing measurements. */
|
||||
export interface SyntheticFrameMetadata {
|
||||
/** Historical media time in seconds, unlike the native video API. */
|
||||
presentationTime: number
|
||||
expectedDisplayTime: number
|
||||
width: number
|
||||
height: number
|
||||
mediaTime: number
|
||||
presentedFrames: number
|
||||
processingDuration: number
|
||||
captureTime: number
|
||||
receiveTime: number
|
||||
rtpTimestamp: number
|
||||
}
|
||||
|
||||
export type SyntheticFrameCallback = (now: number, metadata: SyntheticFrameMetadata) => void
|
||||
export type MediaListener = (event: Event & { detail: unknown }) => unknown
|
||||
|
||||
/** Opt-in media surface of art.mediabunny; decoder internals are not part of this view. */
|
||||
export interface MediaBunnyShim {
|
||||
canvas: HTMLCanvasElement
|
||||
/** Runtime also accepts SDK sources; the default Option keeps its historical input union. */
|
||||
src: unknown
|
||||
readonly currentSrc: unknown
|
||||
currentTime: number
|
||||
readonly duration: number
|
||||
/** Synthetic full-duration/current-time ranges, not measured network buffers. */
|
||||
readonly buffered: TimeRanges
|
||||
readonly played: TimeRanges
|
||||
readonly seekable: TimeRanges
|
||||
readonly paused: boolean
|
||||
readonly playing: boolean
|
||||
readonly ended: boolean
|
||||
readonly seeking: boolean
|
||||
readonly readyState: number
|
||||
readonly networkState: number
|
||||
readonly error: { code: number, message: string } | null
|
||||
volume: number
|
||||
muted: boolean
|
||||
playbackRate: number
|
||||
readonly videoWidth: number
|
||||
readonly videoHeight: number
|
||||
poster: string
|
||||
/** The following setters are inert; use Option for autoplay/loop/crossOrigin. */
|
||||
autoplay: boolean
|
||||
loop: boolean
|
||||
controls: boolean
|
||||
playsInline: boolean
|
||||
crossOrigin: string
|
||||
preload: string
|
||||
defaultMuted: boolean
|
||||
defaultPlaybackRate: number
|
||||
play: () => Promise<void>
|
||||
pause: () => void
|
||||
load: () => void
|
||||
/** Always returns "maybe"; it does not probe codec/browser support. */
|
||||
canPlayType: (type: string) => 'maybe'
|
||||
getM3u8State: () => Promise<HlsState | null>
|
||||
switchM3u8Quality: (value: unknown) => Promise<void>
|
||||
switchM3u8Audio: (value: unknown) => Promise<void>
|
||||
createTimeRanges: (start: number, end: number) => TimeRanges
|
||||
requestVideoFrameCallback: (callback: SyntheticFrameCallback) => number
|
||||
cancelVideoFrameCallback: (id: number) => void
|
||||
addEventListener: (type: string, listener: MediaListener) => void
|
||||
removeEventListener: (type: string, listener: MediaListener) => void
|
||||
getBoundingClientRect: () => DOMRect
|
||||
setAttribute: (name: string, value: unknown) => void
|
||||
destroy: () => void
|
||||
}
|
||||
|
||||
/** Native Canvas methods win collisions, including DOM event and attribute methods. */
|
||||
export type MediaBunnyCanvas = HTMLCanvasElement & Omit<MediaBunnyShim, keyof HTMLCanvasElement>
|
||||
|
||||
/** The alias is installed by the proxy and removed on player destruction. */
|
||||
export type MediaBunnyPlayer = Artplayer & { mediabunny?: MediaBunnyShim }
|
||||
Reference in new issue
Block a user