Skip to content
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

Fix: removed id from videoItem #632

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions src/lib/components/Channel/Stream/VideoItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
video._id !== $page.data.user?.userId &&
role !== '🤖 AI'

$: if (isMounted && (video.screen !== prevScreen)) {
$: if (isMounted && video.screen !== prevScreen) {
handleScreenChanges()
}

Expand Down Expand Up @@ -96,20 +96,16 @@
}

const toggleClient = ({ trackType }: { trackType: string }) => {

if ($page.data.user?.userId === video._id) {

switch (trackType) {
case 'screen':
if (video.screen && $is_sharing_screen) {
const key = video.screen.webRTCPlayback.url+"-"+video._id
const key = video.screen.webRTCPlayback.url + '-' + video._id
const existed = getScreen(key)
screenWhip = existed || new WHIPClient(
video.screen.webRTC.url,
screenElement,
video.screen.trackType
)
if(existed){
screenWhip =
existed ||
new WHIPClient(video.screen.webRTC.url, screenElement, video.screen.trackType)
if (existed) {
existed.videoElement = screenElement
screenElement.srcObject = existed.localStream
$is_sharing_screen = true
Expand All @@ -122,9 +118,8 @@
removeScreen(key)
})
screenWhip.addEventListener(`isScreenLive`, (ev: any) => (isScreenLive = ev.detail))
}
else if(!video.screen){
if(screenElement){
} else if (!video.screen) {
if (screenElement) {
screenElement.srcObject = null
}
$is_sharing_screen = false
Expand All @@ -143,9 +138,8 @@
isWebcamLive = false
})
webcamWhip.addEventListener(`isWebcamLive`, (ev: any) => (isWebcamLive = ev.detail))
}
else if(!video.webcam){
if(webcamElement){
} else if (!video.webcam) {
if (webcamElement) {
webcamElement.srcObject = null
}
}
Expand All @@ -167,19 +161,17 @@
switch (trackType) {
case 'screen':
if (video.screen && screenElement) {
const key = video.screen.webRTCPlayback.url +"-"+video._id
const key = video.screen.webRTCPlayback.url + '-' + video._id
const existed = getScreen(key)
screenWhep = existed || new WHEPClient(
video.screen.webRTCPlayback.url,
screenElement,
video.screen.trackType
)
if(existed){
screenWhep =
existed ||
new WHEPClient(video.screen.webRTCPlayback.url, screenElement, video.screen.trackType)
if (existed) {
existed.videoElement = screenElement
screenElement.srcObject = existed.stream
isScreenLive = true
}

addScreen(key, screenWhep)
screenElement.muted = false
screenElement.play()
Expand Down Expand Up @@ -343,15 +335,13 @@
}, 1000)
}
}

</script>

<div
class={isScreenLive || isWebcamLive ? 'w-full h-full' : 'w-[500px] max-h-80'}
on:mouseenter={() => (isHoverVideo = true)}
on:mouseleave={() => (isHoverVideo = false)}>
<div class="bg-base-200 relative w-full h-full rounded-md">
{video._id}
<img
src={video.avatar}
alt=""
Expand Down