Skip to content

Commit

Permalink
refactor(webapp): player detail
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Jan 15, 2024
1 parent 25a9447 commit dde5520
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 58 deletions.
27 changes: 27 additions & 0 deletions webapp/components/player/detail.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { UserStatus } from "../../store/atom"

export default function Detail(props: { streamId: string, userStatus: UserStatus, restart: () => void }) {
const { streamId, userStatus, restart } = props
return (
<details className='text-white mx-2 text-sm font-border' style={{ position: 'absolute' }}>
<summary className='text-center'>{userStatus.name}</summary>
<center>
<div className='flex flex-row flex-wrap justify-around'>
<p>name: <code>{userStatus.name}</code></p>
<p>state: <code>{String(userStatus.state)}</code></p>
</div>
<div className='flex flex-row flex-wrap justify-around'>
<p>audio: <code>{String(userStatus.audio)}</code></p>
<p>video: <code>{String(userStatus.video)}</code></p>
<p>screen: <code>{String(userStatus.screen)}</code></p>
</div>
<code>{streamId}</code>
</center>

<center className='text-white flex flex-row justify-around'>
<p className='rounded-xl p-2 b-1 hover:border-orange-300'>{userStatus.state}</p>
<button className='btn-primary' onClick={restart}>restart</button>
</center>
</details>
)
}
34 changes: 5 additions & 29 deletions webapp/components/player/whep-player.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useEffect, useRef } from 'react'
import useWhepClient from "../use/whep"
import Detail from './detail'
import Player from './player'

export default function WhepPlayer(props: { streamId: string, width: string }) {
Expand All @@ -14,34 +15,9 @@ export default function WhepPlayer(props: { streamId: string, width: string }) {
}, [])

return (
<div className='flex flex-col'>
<center>
<Player stream={stream} muted={false} width={props.width} display="auto" />
</center>

<details className='text-white mx-2 text-sm font-border' style={{
position: 'absolute',
}}>
<summary className='text-center'>{userStatus.name}</summary>
<center>
<div className='flex flex-row flex-wrap justify-around'>
<p>name: <code>{userStatus.name}</code></p>
<p>state: <code>{String(userStatus.state)}</code></p>
</div>
<div className='flex flex-row flex-wrap justify-around'>
<p>audio: <code>{String(userStatus.audio)}</code></p>
<p>video: <code>{String(userStatus.video)}</code></p>
<p>screen: <code>{String(userStatus.screen)}</code></p>
</div>

<code>{props.streamId}</code>
</center>

<center className='text-white flex flex-row justify-around'>
<p className='rounded-xl p-2 b-1 hover:border-orange-300'>{userStatus.state}</p>
<button className='btn-primary' onClick={() => restart()}>restart</button>
</center>
</details>
</div>
<center className='flex flex-col'>
<Player stream={stream} muted={false} width={props.width} display="auto" />
<Detail streamId={props.streamId} userStatus={userStatus} restart={restart} />
</center>
)
}
34 changes: 5 additions & 29 deletions webapp/components/player/whip-player.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
import useWhipClient from "../use/whip"
import Detail from './detail'
import Player from './player'

export default function WhipPlayer(props: { streamId: string, width: string }) {
const { stream, userStatus, restart } = useWhipClient(props.streamId)
return (
<div className='flex flex-col'>
<center>
<Player stream={stream} muted={true} width={props.width} display="auto" />
</center>

<details className='text-white mx-2 text-sm font-border' style={{
position: 'absolute',
}}>
<summary className='text-center'>{userStatus.name}</summary>
<center>
<div className='flex flex-row flex-wrap justify-around'>
<p>name: <code>{userStatus.name}</code></p>
<p>state: <code>{String(userStatus.state)}</code></p>
</div>
<div className='flex flex-row flex-wrap justify-around'>
<p>audio: <code>{String(userStatus.audio)}</code></p>
<p>video: <code>{String(userStatus.video)}</code></p>
<p>screen: <code>{String(userStatus.screen)}</code></p>
</div>

<code>{props.streamId}</code>
</center>

<center className='text-white flex flex-row justify-around'>
<p className='rounded-xl p-2 b-1 hover:border-orange-300'>{userStatus.state}</p>
<button className='btn-primary' onClick={() => restart()}>restart</button>
</center>
</details>
</div>
<center className='flex flex-col'>
<Player stream={stream} muted={true} width={props.width} display="auto" />
<Detail streamId={props.streamId} userStatus={userStatus} restart={restart} />
</center>
)
}

0 comments on commit dde5520

Please sign in to comment.