This message was deleted.
# helpdesk
s
This message was deleted.
πŸ‘‹ 1
m
Hey @narrow-raincoat-54988, how are you publishing your camera tracks? Edit: Oh, I just saw same source. May I ask what your use case is for publishing the track twice β€” versus simply rendering it twice on the receiving end?
n
hey!! sure thing, my use case is a publisher showing multiple cameras, so each track is actually a different camera feed
maybe my comment is confusing, the actual physical source of each track is a different camera. But in the code, the SDK is tagging them with the source
camera
i followed the logic of how it gets there, and that's where i see the source being set as
camera
b
I could be wrong, but i think you could publish multiple tracks for 1 participant with a track souce "unknown" for camera 2,3, etc. This said you'd need to add some custom handling on the client side. Someone from the LK team might be able to confirm or correct me about this.
m
You can definitely publish multiple camera tracks. How are you publishing the camera now? Can you paste code pls?
n
so, the most basic code i'm using (after a lot of trial and error, and more
console.log
than i'd like to admit), is as follows:
Copy code
await LivekitClient.Room.getLocalDevices().then((devices) => {
        devices.forEach((device) => {
        if(device.kind == "videoinput"){
            room.localParticipant.setCameraEnabled(true, {deviceId: device.deviceId}).then((trackPub => {
            console.log(trackPub);
            document.getElementById("video1").appendChild(trackPub.track.attach());
            }));
        }
    });
this approach throws an error saying `trackPub`is undefined
however, I also tried an approach where I would enable and attach each camera through different actions:
Copy code
document.getElementById("cam1").addEventListener("click", function() {
        room.localParticipant.setCameraEnabled(true, {name: "Cam1", deviceId: "ylAVQ0tA4yyzQYPw/GOGgLClpGxgFoGVSo9M84zzNM0="}, {stream: "Test1"}).then(a => {
            document.getElementById("video1").appendChild(a.track.attach());
        });
    })

    document.getElementById("cam2").addEventListener("click", function() {
        room.localParticipant.setCameraEnabled(true, {name: "Cam2", deviceId: "qBRsmmiarD5rm/0XD/9MLky1kAGnMBEH6lkoJCPrWU0="}, {stream: "Test2"}).then(a => {
            document.getElementById("video1").appendChild(a.track.attach());
        });
    })
and with that, the behaviour is different, it republishes the track with whatever camera I enable last
d
setCameraEnabled is a shortcut and that only supports a single track. to publish multiple tracks of the same source, you should use LocalParticipant.publishTrack like documented here.
n
I've must have looked at the docs 200 times, yet it was right there
I got it running πŸ™‚
thank you very much for the swift response!!
d
awesome!! we should make that section more clear then! especially regarding the limitations of the shortcuts
n
that would help for sure, but I could've payed more attention and not get nearsighted on my approach
much obliged folks! I'm loving the platform so far!
❀️ 2
m
cc @acoustic-engineer-41666 for visibility
n
an extra note on this, everything works as expected, however a warning pops up on the browser debug console:
Copy code
"trace": "Error: publishing a second track with the same source: camera\n    at Co.<anonymous> (<https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js:7:280160>)\n    at Generator.next (<anonymous>)\n    at <https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js:7:58176>\n    at new Promise (<anonymous>)\n    at gt (<https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js:7:57921>)\n    at Co.publish (<https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js:7:279991>)\n    at Co.<anonymous> (<https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js:7:279799>)\n    at Generator.next (<anonymous>)\n    at o (<https://cdn.jsdelivr.net/npm/livekit-client/dist/livekit-client.umd.min.js:7:57978>)"
it still works, and it's not an error, despite the actual message, but it seems confusing
m
cc @polite-kilobyte-67570
πŸ™ 1
p
the wording of that warning is unfortunate (or rather wrong). We probably want to demote that to an info log and strip the β€œError” mention from that message.