Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 透传 video 标签 crossorigin #305

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/src/MP4Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const App = () => {
key={query.key}
autoplay={query.autoplay !== '0'}
sources={'hls' in query ? hlsSources : sources}
crossOrigin="anonymous"
localeConfig={{
'zh-Hans': {
'quality-ld': {
Expand Down
3 changes: 3 additions & 0 deletions packages/griffith/src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type InnerPlayerProps = {
hideCover?: boolean
noWriteDocTitle?: boolean
layerContent?: React.ReactNode
crossOrigin?: string | undefined
}

// 仅供 Provider 使用的属性
Expand Down Expand Up @@ -143,6 +144,7 @@ const InnerPlayer: React.FC<InnerPlayerProps> = ({
hideCover,
noWriteDocTitle,
layerContent,
crossOrigin,
}) => {
const {emitEvent, subscribeAction} = useContext(InternalMessageContext)
const {currentSrc, sources} = useContext(VideoSourceContext)
Expand Down Expand Up @@ -634,6 +636,7 @@ const InnerPlayer: React.FC<InnerPlayerProps> = ({
<div className={css(styles.video)}>
<Video
ref={videoRef}
crossOrigin={crossOrigin}
controls={ua.isMobile && isPlaybackStarted && !hideMobileControls}
paused={!isPlaying}
volume={volume}
Expand Down
2 changes: 2 additions & 0 deletions packages/griffith/src/components/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class Video extends Component<VideoProps> {
useMSE,
sources,
currentQuality,
crossOrigin,
} = this.props

const {VideoComponent} = selectVideo(format, useMSE)
Expand All @@ -355,6 +356,7 @@ class Video extends Component<VideoProps> {
className={css(styles.root)}
preload="metadata"
playsInline
crossOrigin={crossOrigin}
webkit-playsinline=""
x-webkit-airplay="deny"
muted={!volume}
Expand Down
Loading