Skip to content

Commit

Permalink
Fix from test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-amal committed Jul 16, 2024
1 parent 9a496b2 commit d9546c3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/pages/robot/tsx/videostreams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class VideoStream extends React.Component<VideoStreamProps> {
className?: string;
outputVideoStream?: MediaStream;
aspectRatio: any;
started: boolean;

constructor(props: VideoStreamProps) {
super(props);
Expand All @@ -58,6 +59,7 @@ export class VideoStream extends React.Component<VideoStreamProps> {
this.video.setAttribute("width", this.width.toString());
this.video.setAttribute("height", this.height.toString());
this.outputVideoStream = new MediaStream();
this.started = false;

this.updateImage = this.updateImage.bind(this);
}
Expand Down Expand Up @@ -109,10 +111,13 @@ export class VideoStream extends React.Component<VideoStreamProps> {
}

start() {
if (!this.canvas.current) throw "Video stream canvas null";
this.outputVideoStream = this.canvas.current.captureStream(this.fps);
this.video.srcObject = this.outputVideoStream;
this.drawVideo();
if (!this.started) {
if (!this.canvas.current) throw "Video stream canvas null";
this.outputVideoStream = this.canvas.current.captureStream(this.fps);
this.video.srcObject = this.outputVideoStream;
this.drawVideo();
this.started = true;
}
}

render() {
Expand Down

0 comments on commit d9546c3

Please sign in to comment.