Avoid using daily credits when someone is alone in a session?
Hi there – I'm hoping a Daily Pro Dev can help me out with my app's architecture! We're building a live multiplayer website where people can join shared Daily rooms with audio and video. While I've been developing the website, I've already blown through our 10,000 free daily minutes this month 😂
I'm hoping to rearchitect our app so that if you're alone in a daily room, it uses your local video instead of streaming via Daily, to help us save some $ as a small startup. Any ideas on how this can be done?
@caroline thank you got the additional context!
You should still be able to call
startCamera()to use Daily to initialize a user's input devices, which can then be shown locally to a user without joining the call. The advantage here is that Daily is then aware of the correct devices and tracks to use, and it will also handle any device errors that occur.
Assuming this user's tracks are only needed locally while they remain alone in a session, for the case that you described, a user could load the pre-join UI, set up their devices, then transition to a "waiting" state where they have not joined the call but have exited the "pre-join" UI. Once a second user joins, they would both be notified to leave the "waiting" state and join the session.
You can use the
/presenceAPI to facilitate determining when to join the session, or use something like an external websocket server to pass along notifications:
As for your last question: Billing is only calculated for the duration that a user is "joined", so the pre-call lobby where media is only available locally does not constitute participant minute usage.0
The best method for handling the "single user waiting in a room" case depends on your use case.
If you're only looking to allow a user to preview their camera prior to actually "joining" a session, you can use the
startCamera()methods to build a "pre-join UI", as detailed in this blog post: https://www.daily.co/blog/add-a-prejoin-ui-to-a-custom-video-app-with-the-daily-react-hooks-library-part-2/
startCamera()method is useful for grabbing audio and video devices for a local preview, or building a device test/selector screen. Since the user has not joined the call yet, there is no usage cost associated. However, they won't be able to use any methods the require a user to be joined to a call, or receive events emitted by the API.
If you have a more advanced use case and can share more context, we can suggest alternatives.0
Hi @daily_joey – Thank you for your response.
Our use case may be a bit unique, and is distinct from "pre-join".
We're building a live multiplayer website with video built in (think Figma or Google Docs, but with video chat). We'd like for people to see their own video, as well as change their camera and microphone, even when they're the only person in the room. This is because you may be doing things alone, creating things, and playing around (like with Figma or Google Docs) – but the video "mirror" is an important part of the experience, even when you're alone.
In this case, they wouldn't need to "stream" video and audio to the call, but would still need to see their own camera feed and have access to the camera controls. If they choose to invite a friend by sharing the call link, then the video would begin to be streamed. Is this possible?0
Here's a little code snippet in case it's helpful of what we're returning:
Would it work to put streams outside of the DailyProvider? I worry that may not work if we're updating camera and mic inputs.
return callObject && (
One last question @daily_joey – in the "pre-join" case, does that still bill daily credits? Or is it only once that person joins the call?0
Hi @daily_joey – this worked fantastically, thank you very much! startCamera was exactly what we needed. We have a separate websockets server set up for the multiplayer, so I just used that to track the number of participants, and only call join() when there's at least 1 other person. The prejoin example code was quite helpful as well. I appreciate your quick responses 🎉1