Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix not diplaying video when audio is present #5

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/components/WebRTCView/WebRTCView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const WebRTCView = ({cameraName}: WebRTCViewProps) => {
const [isConnected, setIsConnected] = React.useState<boolean>(false);
const [retryAttempts, setRetryAttempts] = React.useState(0);
const [shouldRetry, setShouldRetry] = React.useState(false);
const [remoteStream, setRemoteStream] = React.useState<MediaStream | null>(
null,
const [remoteStream, setRemoteStream] = React.useState<MediaStream>(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't need to actually use the setRemoteStream function you can just prefix it with an underscore (_setRemoteStream) to prevent that linting error.

But the way this is working now looks like it should be fine. Will test in a bit, having some weird device issues at the moment lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good to know! No worries, hopefully all works okay.

new MediaStream(undefined),
);
const [localStream, setLocalStream] = React.useState<MediaStream | null>(
null,
Expand All @@ -63,9 +63,8 @@ export const WebRTCView = ({cameraName}: WebRTCViewProps) => {
const track = event?.track;
if (track) {
setIsConnected(true);
const remoteMediaStream = new MediaStream(undefined);
remoteMediaStream.addTrack(track);
setRemoteStream(remoteMediaStream);
remoteStream.addTrack(track);
setRemoteStream(remoteStream);
}
};

Expand Down Expand Up @@ -169,6 +168,7 @@ export const WebRTCView = ({cameraName}: WebRTCViewProps) => {
if (!isWsOpen) {
throw 'Websocket not open yet';
}

const pc = peerConnection;
const ws = wsRef.current;

Expand Down Expand Up @@ -200,6 +200,7 @@ export const WebRTCView = ({cameraName}: WebRTCViewProps) => {
throw new Error('Could not connect');
}
}

setRetryAttempts(0);

// we no longer want to listen to connected state change events
Expand Down Expand Up @@ -237,7 +238,7 @@ export const WebRTCView = ({cameraName}: WebRTCViewProps) => {
return (
<BaseView className="flex-1 mt-4 px-6">
<BaseText className="text-center mb-2 text-red-600 text-lg">
Unable to load streme for {cameraName}
Unable to load stream for {cameraName}
</BaseText>
<TouchableOpacity
className="self-center border border-red-700 p-3 px-6 rounded-md"
Expand Down