-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
not working in nextjs14 #269
Labels
question
Further information is requested
Comments
oh i got this resolved by using this concept instead of useEffect "use client";
import React, { useRef, useEffect, useState } from "react";
import { loadPlayer } from "rtsp-relay/browser";
const DaylightStream = () => {
const [player, setPlayer] = useState(null);
const [isPaused, setPaused] = useState(false);
const canvas = useRef(null);
const handleStartStreamClick = async () => {
if (!canvas.current) throw new Error("Ref is null");
const Player = await loadPlayer({
url: "ws://localhost:2000/api/stream/camera3",
canvas: canvas.current,
});
setPlayer(Player);
};
const handlePauseStreamClick = () => {
player.pause();
setPaused(true);
};
const handleResumeStreamClick = () => {
player.play();
setPaused(false);
console.log(player);
};
return (
<div>
<h1>Daylight Stream</h1>
<div className="border-8 border-black">
<canvas ref={canvas} />
</div>
<div>
<button
className="btn"
onClick={handleStartStreamClick}
disabled={player}
>
Start Stream
</button>
<button
className="btn"
onClick={handlePauseStreamClick}
disabled={!player || isPaused}
>
Pause Stream
</button>
<button
className="btn"
onClick={handleResumeStreamClick}
disabled={!player || !isPaused}
>
Resume Stream
</button>
</div>
</div>
);
};
export default DaylightStream; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i been using it in node express where its been working perfectly fine with that loadPlayer of rtsp
but when i read the docs and try implementing in frontend with nextjs nothing is showing, but in network tab its visble the websockets are working perfectly but player is not working
Kindly provide me a fix for this
my code
my network tab for help
Also the console is clean nothing is showing .
The text was updated successfully, but these errors were encountered: