Skip to content

Commit

Permalink
Merge pull request #632 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Fix: removed id from videoItem
  • Loading branch information
gagansuie authored Jul 20, 2023
2 parents 4a2cfbb + 1d45f2a commit 8fd88b5
Showing 1 changed file with 16 additions and 26 deletions.
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

0 comments on commit 8fd88b5

Please sign in to comment.