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

Feat: added vime lib for hls stream #683

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@
"tailwindcss": "^3.2.7",
"tslib": "^2.5.0",
"typescript": "^5.0.2",
"video.js": "^8.3.0",
"vite": "^4.1.4"
},
"dependencies": {
"@neodrag/svelte": "^2.0.3",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/typography": "^0.5.9",
"@vime/core": "^5.4.1",
"@vime/svelte": "^5.4.1",
"animate.css": "^4.1.1",
"daisyui": "^3.2.1",
"emoji-picker-element": "^1.18.1",
Expand Down
23 changes: 18 additions & 5 deletions src/lib/components/Channel/Stream/VideoItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { is_feature_stats_enabled, is_feature_obs_enabled } from '$lib/stores/remoteConfigStore'
import { addScreen, getScreen, removeScreen } from '$lib/stream-utils'
import IconDrawerVerification from '$lib/assets/icons/drawer/IconDrawerVerification.svelte'
import { Player, DefaultUi, Hls } from '@vime/svelte'

export let video: any, channel: any

Expand Down Expand Up @@ -51,6 +52,7 @@
// WHIP/WHEP variables that determine if stream is coming in
$: isScreenLive = false
$: isWebcamLive = false
$: hlsUrl = ''

$: if (channel) {
role = setRole({ userId: video._id, channel, currentUserId: $page.data.user?.userId })
Expand Down Expand Up @@ -120,7 +122,8 @@
if ($page.data.user?.userId === video._id) {
switch (trackType) {
case 'obs':
console.log('got here---- video.obs.playback?.hls', video.obs?.playback?.hls)
hlsUrl = video.obs?.playback?.hls
console.log('got here---- video.obs.playback?.hls', hlsUrl)
// if (video.obs && $is_sharing_obs) {
// const key = video.obs.webRTCPlayback.url + '-' + video._id
// const existed = getScreen(key)
Expand Down Expand Up @@ -210,7 +213,7 @@
switch (trackType) {
case 'obs':
if (video.obs && obsElement) {
obsElement.src = video.obs.rtmpsPlayback.url
obsElement.src = video.obs?.playback?.hls
obsElement.muted = false
obsElement.play()
} else {
Expand Down Expand Up @@ -415,6 +418,8 @@
}
</script>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@vime/core@^5/themes/default.css" />

<div
class={isScreenLive || isWebcamLive ? 'w-full h-full' : 'w-[500px] max-h-80'}
on:mouseenter={() => (isHoverVideo = true)}
Expand All @@ -436,16 +441,24 @@
</span>
{/if}
{#if $is_feature_obs_enabled}
<video-js
<!-- <video-js
bind:this={obsElement}
id={`obs-${video._id}`}
controls
autoplay
muted
preload="auto"
class="rounded-md w-full h-full">
<source src={video.obs?.playback?.hls} type="application/x-mpegURL" />
</video-js>
<source src={video.obs?.hlsPlayback} type="application/x-mpegURL" />
</video-js> -->

<Player theme="dark" style="--vm-player-theme: #e86c8b;">
<Hls crossOrigin>
<source data-src={hlsUrl} type="application/x-mpegURL" />
</Hls>

<DefaultUi />
</Player>
{/if}

<video
Expand Down
1 change: 1 addition & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@

<svelte:head>
<link rel="stylesheet" href="/fonts/montserrat.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@vime/core@^5/themes/default.css" />
{@html `<script>
const theme = localStorage.getItem('theme') || 'dark';
document.querySelector('html').dataset.theme = theme;
Expand Down