Skip to content

Commit

Permalink
Merge pull request #1272 from gagansuie/dev
Browse files Browse the repository at this point in the history
Feat: added horizontal vods list to channel page
  • Loading branch information
gagansuie authored May 27, 2024
2 parents d81b398 + fadebc7 commit 8104303
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/lib/components/Channel/Stream/StreamContainer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { is_feature_premium_enabled } from '$lib/stores/remoteConfigStore'
import DropdownSponsors from '$lib/components/Channel/Stream/DropdownSponsors.svelte'
import IconChatSponsor from '$lib/assets/icons/chat/IconChatSponsor.svelte'
import VodList from './VodList.svelte'
const dispatch = createEventDispatcher()
export let userCount: number = 1,
Expand Down Expand Up @@ -160,6 +161,7 @@
{#if channel && nextchannel?._id === parseInt($page.params.channelId)}
<VideoGrid bind:channel />
{/if}
<VodList channelId={channel._id} />
</div>
</div>
{/each}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/Channel/Stream/StreamControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
trackType,
liveInput: {
meta: {
name: `${$page.params.channelId}-${$page.data.user?.userId}-webrtc-${trackType}`
name: $page.params.channelId
},
recording: { mode: 'off' }
}
Expand Down Expand Up @@ -124,7 +124,7 @@
trackType: 'rtmps',
liveInput: {
meta: {
name: `${$page.params.channelId}-${$page.data.user?.userId}-rtmps`
name: $page.params.channelId
},
recording: { mode: 'automatic' }
}
Expand Down
30 changes: 30 additions & 0 deletions src/lib/components/Channel/Stream/VodList.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script lang="ts">
import { get } from '$lib/api'
import { getTimeFormat } from '$lib/utils'
import { onMount } from 'svelte'
export let channelId: number
let vods: any = []
onMount(async () => {
vods = await get(`vods?channelId=${channelId}`)
console.log('got here----vods', vods)
})
</script>

{#if vods.length}
<div class="flex space-x-1 bg-base-200 rounded-box overflow-x-auto h-52 overflow-y-hidden">
{#each vods as vod}
<a class="carousel-item p-4 cursor-pointer relative" href={vod.url} target="_blank">
<!-- <iframe src={vod.url} class="rounded-box"></iframe> -->
<img src={vod.thumbnail} class="rounded-box" />
<div
class="badge badge-md text-ghost rounded-md font-semibold border-none absolute bottom-4 right-4 m-1">
{getTimeFormat(vod.duration)}
</div>
</a>
{/each}
</div>
{:else}
<p>No VODs available</p>
{/if}
10 changes: 10 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,13 @@ export const updateVideoItems = (videoItems: any, liveInputs: any[]) => {
}
return vidItems
}

export const getTimeFormat = (duration: number) => {
const hours = Math.floor(duration / 3600)
const minutes = Math.floor((duration % 3600) / 60)
const seconds = Math.floor(duration % 60)

const secondsFormat = seconds < 10 ? `0${seconds}` : seconds

return hours > 0 ? `${hours}:${minutes}:${secondsFormat}` : `${minutes}:${secondsFormat}`
}

0 comments on commit 8104303

Please sign in to comment.