Skip to content

Commit

Permalink
Allow multiple sources for video (#258)
Browse files Browse the repository at this point in the history
Co-authored-by: Valentin Hervieu <valentin.hervieu@ricardo.ch>
  • Loading branch information
MatixYo and Valentin Hervieu committed Jun 1, 2021
1 parent c79050b commit aa808fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import normalizeWheel from 'normalize-wheel'
import { Area, MediaSize, Point, Size } from './types'
import { Area, MediaSize, Point, Size, VideoSrc } from './types'
import {
getCropSize,
restrictPosition,
Expand All @@ -15,7 +15,7 @@ import cssStyles from './styles.css'

export type CropperProps = {
image?: string
video?: string
video?: string | VideoSrc[]
transform?: string
crop: Point
zoom: number
Expand Down Expand Up @@ -538,7 +538,6 @@ class Cropper extends React.Component<CropperProps, State> {
mediaClassName
)}
{...mediaProps}
src={video}
ref={(el: HTMLVideoElement) => (this.videoRef = el)}
onLoadedMetadata={this.onMediaLoad}
style={{
Expand All @@ -547,7 +546,11 @@ class Cropper extends React.Component<CropperProps, State> {
transform || `translate(${x}px, ${y}px) rotate(${rotation}deg) scale(${zoom})`,
}}
controls={false}
/>
>
{(Array.isArray(video) ? video : [{ src: video }]).map((item) => (
<source {...item} />
))}
</video>
)
)}
{this.state.cropSize && (
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ export type Area = {
x: number
y: number
}

export type VideoSrc = {
src: string
type?: string
}

0 comments on commit aa808fa

Please sign in to comment.