Open dmke opened 7 months ago
I think whether or not this is desired behaviour would greatly depend on the use case. I'm not sure whether the library (components) is the right place for this. I guess adding a wakelock to github.com/livekit-examples/meet might make sense
That's fine with me :)
I'll try to hook into <PreJoin onSubmit/>
and report back.
I've added use-stay-awake
[^1] and called preventSleeping
in the <PreJoin onSubmit/>
callback, and allowSleeping
to <LiveKitRoom onDisconnect/>
:
export function JoinRoom(props: { token: string, url: string }) {
const screen = useStayAwake()
function onJoin(choices: LocalUserChoices) {
screen.preventSleeping()
}
function onLeave() {
screen.allowSleeping()
}
if (preJoinChoices === null) {
return <PreJoin onSubmit={onJoin} />
}
return <LiveKitRoom onDisconnected={onLeave}>
<VideoConference chatMessageFormatter={formatChatMessageLinks} />
</LiveKitRoom>
}
AFAICT, this seems to work.
(Here, I've omitted handling of LocalUserOptions
and transforming it into RoomOptions
and a new Room
instance, before passing it to the <LiveKitRoom/>
.)
[^1]: The NPM package depends on React v16, but the source code can easily be vendored.
I'll withdraw my previous comment: While the background media inserted by use-stay-awake
does indeed play, it doesn't prevent the screen from blanking. I suspect the <PreJoin onSubmit />
callback isn't detected properly as a user-initiated action - maybe this needs to be implemented closer to the click handler of the "Join" button? :thinking:
With Firefox 124 (scheduled for release mid-March) to enable the Screen Wake Lock API by default, would you accept a PR which adds that to the <PreJoin />
component directly (maybe even behind an off-by-default switch)?
Have you confirmed that it's working in isolation?
If we were to add screen lock wake, then the livekit/client-sdk-js repo would be the best place for it. However, I'm not sure if this is the right approach. It's unexpected that your screen blanks in the first place while video is being played back.
I don't have hard evidence, just some observations when screen blanking does not occur on my machine:
dom.screenwakelock.enabled
in about:config
on Firefox 123), and testing it on https://react-screen-wake-lock.vercel.app/I do however have quite an old installation of Debian 11/Gnome 3.38.5 which might play into this (upgrading is a problem of finding a bit of time to do so :)).
Describe the problem
On my machine, the screen blanks (and actually locks) after 5min of inactivity (i.e. no mouse or keyboard input). For company policy reasons, I cannot disable that behaviour.
It is a bit of an annoyance, when my monitor goes into sleep mode in the middle of a sentence, as it takes a moment to recover from that...
Describe the proposed solution
Browsers usually prevent screensavers from activating, when they play media (and NoSleep.js promises to provide such a functionality).
I'm not sure why the video/audio tracks of LiveKit itself don't count towards this behaviour.
Speculation
I presume this is because the tracks don't actually originate from a user input event, such as a button click? For example, the local video track already exists in the `There's also the Screen Wake Lock API, but Firefox support is missing:
Alternatives considered
No response
Importance
nice to have
Additional Information
No response