Skip to content

Commit

Permalink
Merge pull request #778 from AI4Bharat/reports2
Browse files Browse the repository at this point in the history
added toggle for youtube player
  • Loading branch information
aparna-aa authored Aug 2, 2024
2 parents 23bdd03 + 5774a25 commit 5eae876
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
15 changes: 15 additions & 0 deletions src/common/CustomMenuComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const CustomMenuComponent = ({
setShowSubtitles,
showTimeline,
setShowTimeline,
useYtdlp,
setUseYtdlp,
}) => {
const player = useSelector((state) => state.commonReducer.player);

Expand Down Expand Up @@ -109,6 +111,19 @@ const CustomMenuComponent = ({
<input type="checkbox" checked={showTimeline} onChange={() => {setShowTimeline(!showTimeline)}}/>
</div>
</MenuItem>
<MenuItem key="Youtube Player">
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
width: "100%",
}}
>
<span>Youtube Player</span>
<input type="checkbox" checked={!useYtdlp} onChange={() => {setUseYtdlp(!useYtdlp)}}/>
</div>
</MenuItem>
</Menu>

<Menu
Expand Down
5 changes: 5 additions & 0 deletions src/containers/Organization/Video/VideoLanding.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const VideoLanding = () => {
const [fontSize, setFontSize] = useState("large");
const [darkAndLightMode, setDarkAndLightMode] = useState("dark");
const [subtitlePlacement, setSubtitlePlacement] = useState("bottom");
const [useYtdlp, setUseYtdlp] = useState(true);

const taskDetails = useSelector((state) => state.getTaskDetails.data);
const transcriptPayload = useSelector(
Expand Down Expand Up @@ -285,11 +286,15 @@ const VideoLanding = () => {
setShowSubtitles={setShowSubtitles}
showTimeline={showTimeline}
setShowTimeline={setShowTimeline}
useYtdlp={useYtdlp}
setUseYtdlp={setUseYtdlp}
/>

<VideoPanel
setCurrentTime={setCurrentTime}
setPlaying={setPlaying}
useYtdlp={useYtdlp}
setUseYtdlp={setUseYtdlp}
/>

{currentSubs && showSubtitles && (
Expand Down
4 changes: 4 additions & 0 deletions src/containers/Organization/Video/components/VideoName.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const VideoName = ({
setShowSubtitles,
showTimeline,
setShowTimeline,
useYtdlp,
setUseYtdlp,
}) => {
const classes = VideoLandingStyle();

Expand Down Expand Up @@ -69,6 +71,8 @@ const VideoName = ({
setShowSubtitles={setShowSubtitles}
showTimeline={showTimeline}
setShowTimeline={setShowTimeline}
useYtdlp={useYtdlp}
setUseYtdlp={setUseYtdlp}
/>
</Box>
);
Expand Down
14 changes: 5 additions & 9 deletions src/containers/Organization/Video/components/VideoPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ import { VideoLandingStyle } from "styles";
//APIs
import { setPlayer } from "redux/actions";

const VideoPanel = memo(
({ setCurrentTime, setPlaying }) => {
const VideoPanel = ({ setCurrentTime, setPlaying, useYtdlp, setUseYtdlp }) => {
const classes = VideoLandingStyle();
const dispatch = useDispatch();
const $video = createRef();

const [poster, setPoster] = useState("play.png");
const [ytdlpError, setYtdlpError] = useState(false);

const videoDetails = useSelector((state) => state.getVideoDetails.data);
const taskData = useSelector((state) => state.getTaskDetails.data);
Expand Down Expand Up @@ -63,7 +61,7 @@ const VideoPanel = memo(

return (
<div className={classes.videoPlayerParent} style={{display: "flex", alignItems: "center", justifyContent: "center", height:"100%"}}>
{ ((videoDetails.length === 0 && taskData?.video_url?.includes("youtube")) || ytdlpError === true) ?
{ ((videoDetails.length === 0 && taskData?.video_url?.includes("youtube")) || useYtdlp === false) ?
<ReactPlayerYT
onReady={() => {dispatch(setPlayer($video.current.getInternalPlayer()))}}
ref={$video}
Expand All @@ -90,14 +88,12 @@ const VideoPanel = memo(
className={classes.videoPlayer}
controls={true}
controlsList="nodownload"
onReady={() => {dispatch(setPlayer($video.current.getInternalPlayer())); console.log($video.current.getInternalPlayer());}}
onError={() => {setYtdlpError(true);}}
onReady={() => {dispatch(setPlayer($video.current.getInternalPlayer()))}}
onError={() => {setUseYtdlp(false);}}
/>
}
</div>
);
},
() => true
);
};

export default VideoPanel;

0 comments on commit 5eae876

Please sign in to comment.