steep-balloon-41261
04/26/2023, 8:02 AMpolite-kilobyte-67570
04/26/2023, 9:30 AMconnect
from your import list and you should be fine!
• sure, you can use Vue 3 with LiveKit. We are currently building a higher level components framework on top of the client-sdk-js that might eventually also get Vue 3 support (right now we only support react directly)
• AFAIK there’s currently no dedicated Vue example, but many examples with react and there’s also an “example” folder in the client-sdk-js
• see abovebusy-lawyer-20958
04/26/2023, 9:48 AMawait room.connect('<ws://localhost:7800>', token);
So I can't use components framework.
Still the examples are with react only.
So there is no way to implement with Vue 3?
Really difficult to understand the docs.
The closest I found is this: https://github.com/livekit/client-sdk-js/tree/main/example
And even that is not applicable to livekit-client because it imports everthing from index.ts not from the library.
Can't Livekit supply a simple Vue 3 app example? If possible it shouldn't take much time.polite-kilobyte-67570
04/26/2023, 9:54 AMCopy codeawait room.connect('<ws://localhost:7800>', token);
connect
is being called as a method on room
const room = new Room()
await room.connect(...)
for the example you linked, just replace ./index.ts
with livekit-client
it has the same imports.
is there anything in particular that you have trouble understanding in the docs?busy-lawyer-20958
04/26/2023, 10:22 AM./index.ts
with livekit-client
but it gave me type errors just like connect. There are 4 imports that don't exist in livekit-client.busy-lawyer-20958
04/26/2023, 10:24 AMSyntaxError: The requested module '/node_modules/.vite/deps/livekit-client.js?v=263c77b9' does not provide an export named ...
busy-lawyer-20958
04/26/2023, 10:29 AMfunction handleTrackSubscribed(
track: RemoteTrack,
publication: RemoteTrackPublication,
participant: RemoteParticipant
) {
if (track.kind === Track.Kind.Video || track.kind === Track.Kind.Audio) {
// attach it to a new HTMLVideoElement or HTMLAudioElement
const element = track.attach();
parentElement.appendChild(element);
}
}
What is parentElement here? It doesn't say anywhere here: https://github.com/livekit/client-sdk-js
It is very difficult to understand the docs.thankful-rain-7893
04/26/2023, 2:28 PM<script setup>
import {
Room,
RoomEvent,
} from 'livekit-client'
import { ref, onMounted } from 'vue'
const token1 = 'user1 token'
const token2 = 'user2 token'
const room = new Room()
const localVideoContainer = ref()
const remoteVideoContainer = ref()
onMounted(async () => {
await room.prepareConnection('<wss://live-dev-k5mhurx4.livekit.cloud>')
room
// publish local video and display it to localVideoContainer
.on(RoomEvent.LocalTrackPublished, function (publication) {
const track = publication.track.attach()
localVideoContainer.value.appendChild(track)
})
// subscribe remote video and display it to remoteVideoContainer
.on(RoomEvent.TrackSubscribed, function (remoteTrack) {
const track = remoteTrack.attach()
remoteVideoContainer.value.appendChild(track)
})
await room.connect('<wss://live-dev-k5mhurx4.livekit.cloud>', token1)
await room.localParticipant.enableCameraAndMicrophone()
})
</script>
<template>
<div ref='localVideoContainer'></div>
<div ref='remoteVideoContainer'></div>
</template>
thankful-rain-7893
04/26/2023, 2:28 PMlivekit-cli create-token \
--api-key apikey --api-secret apisecret \
--join --room room1 --identity user1 \
--valid-for 720h
livekit-cli create-token \
--api-key apikey --api-secret apisecret \
--join --room room1 --identity user2 \
--valid-for 720h