mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Added captions support
This commit is contained in:
parent
03246b0aa7
commit
ada128c65d
1 changed files with 6 additions and 3 deletions
|
@ -9,7 +9,7 @@ import './VideoElement.css'
|
||||||
// setProgress: (event: NativeEvent) => void
|
// setProgress: (event: NativeEvent) => void
|
||||||
// videoRef: useRef
|
// videoRef: useRef
|
||||||
// startTime: number
|
// startTime: number
|
||||||
export function VideoElement({ streamUrl, loading, setProgress, videoRef, startTime }) {
|
export function VideoElement({ streamUrl, loading, setProgress, videoRef, startTime, streamData }) {
|
||||||
const [error, setError] = React.useState(false);
|
const [error, setError] = React.useState(false);
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
|
@ -48,11 +48,14 @@ export function VideoElement({ streamUrl, loading, setProgress, videoRef, startT
|
||||||
|
|
||||||
if (!streamUrl.endsWith('.mp4')) {
|
if (!streamUrl.endsWith('.mp4')) {
|
||||||
return (
|
return (
|
||||||
<video className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad} />
|
<video crossorigin="anonymous" className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
|
||||||
|
{streamData.subtitles && streamData.subtitles.map((sub, index) => {return <track key={index} kind="captions" label={sub.language} src={`${process.env.REACT_APP_CORS_PROXY_URL}https://lookmovie.io${sub.file}` }></track>})}
|
||||||
|
</video>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<video className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
|
<video crossorigin="anonymous" className="videoElement" ref={videoRef} controls autoPlay onProgress={setProgress} onLoadedData={onLoad}>
|
||||||
|
{streamData.subtitles && streamData.subtitles.map((sub, index) => {return <track key={index} kind="captions" label={sub.language} src={`${process.env.REACT_APP_CORS_PROXY_URL}https://lookmovie.io${sub.file}` }></track>})}
|
||||||
<source src={streamUrl} type="video/mp4" />
|
<source src={streamUrl} type="video/mp4" />
|
||||||
</video>
|
</video>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue