1
0
Fork 0
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:
mansoor-roeen-glitch 2021-09-13 23:57:14 +05:30 committed by GitHub
parent 03246b0aa7
commit ada128c65d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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>
) )