mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat: add native hls media + refactor (#1154)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
// Core
|
||||
export type { Delegate } from '@videojs/core';
|
||||
export { DelegateMixin } from '@videojs/core';
|
||||
export * from '@videojs/core/dom';
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { InferDelegateProps } from '@videojs/core';
|
||||
import { NativeHlsMedia, NativeHlsMediaDelegate } from '@videojs/core/dom/media/native-hls';
|
||||
import type { PropsWithChildren, VideoHTMLAttributes } from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
import { attachMediaElement } from '../../utils/attach-media-element';
|
||||
import { mediaProps } from '../../utils/media-props';
|
||||
import { useComposedRefs } from '../../utils/use-composed-refs';
|
||||
import { useMediaInstance } from '../../utils/use-media-instance';
|
||||
|
||||
export type NativeHlsVideoProps = PropsWithChildren<VideoHTMLAttributes<HTMLVideoElement>> &
|
||||
InferDelegateProps<typeof NativeHlsMediaDelegate>;
|
||||
|
||||
export const NativeHlsVideo = forwardRef<HTMLVideoElement, NativeHlsVideoProps>(({ children, ...props }, ref) => {
|
||||
const mediaApi = useMediaInstance(NativeHlsMedia);
|
||||
|
||||
const composedRef = useComposedRefs(attachMediaElement(mediaApi), ref);
|
||||
|
||||
return (
|
||||
<video ref={composedRef} {...mediaProps(mediaApi, NativeHlsMediaDelegate, props)}>
|
||||
{children}
|
||||
</video>
|
||||
);
|
||||
});
|
||||
|
||||
export default NativeHlsVideo;
|
||||
Reference in New Issue
Block a user