Jon Taylor commited on
Commit
fc610e2
·
1 Parent(s): 1e8ff3b

added ui elements

Browse files
Files changed (2) hide show
  1. frontend/app/components/Call.js +12 -3
  2. server.py +2 -2
frontend/app/components/Call.js CHANGED
@@ -1,6 +1,5 @@
1
  "use client";
2
 
3
- import Link from "next/link";
4
  import { useCallback, useEffect, useState } from "react";
5
  import Card from "../components/Card";
6
  import { VideoCameraIcon, PaintBrushIcon } from "@heroicons/react/24/outline";
@@ -8,7 +7,11 @@ import Avatar from "../components/Avatar";
8
  import CreateRoom from "../components/CreateRoom";
9
  import { apiUrl } from "../utils";
10
  import Join from "../components/Joining";
11
- import { DailyVideo, useLocalSessionId } from "@daily-co/daily-react";
 
 
 
 
12
 
13
  const STATE_IDLE = "idle";
14
  const STATE_JOINING = "joining";
@@ -22,6 +25,7 @@ export default function Call() {
22
  const [roomUrl, setRoomUrl] = useState();
23
  const [botState, setBotState] = useState(BOT_STATE_STARTING);
24
  const localSessionId = useLocalSessionId();
 
25
 
26
  const start = useCallback(async () => {
27
  const resp = await fetch(`${apiUrl}/start`, {
@@ -61,6 +65,7 @@ export default function Call() {
61
  // Main call loop
62
  return (
63
  <main className="container py-24">
 
64
  <div className="grid grid-cols-2 grid-flow-col gap-4">
65
  <div>
66
  <Card headerText="Local Webcam" HeaderIcon={VideoCameraIcon}>
@@ -76,7 +81,11 @@ export default function Call() {
76
  <Card headerText="Inference" HeaderIcon={PaintBrushIcon}>
77
  <div className="overflow-hidden bg-gray-50 sm:rounded-lg">
78
  <div className="aspect-video flex items-center justify-center">
79
- <Avatar />
 
 
 
 
80
  </div>
81
  </div>
82
  </Card>
 
1
  "use client";
2
 
 
3
  import { useCallback, useEffect, useState } from "react";
4
  import Card from "../components/Card";
5
  import { VideoCameraIcon, PaintBrushIcon } from "@heroicons/react/24/outline";
 
7
  import CreateRoom from "../components/CreateRoom";
8
  import { apiUrl } from "../utils";
9
  import Join from "../components/Joining";
10
+ import {
11
+ DailyVideo,
12
+ useLocalSessionId,
13
+ useParticipantIds,
14
+ } from "@daily-co/daily-react";
15
 
16
  const STATE_IDLE = "idle";
17
  const STATE_JOINING = "joining";
 
25
  const [roomUrl, setRoomUrl] = useState();
26
  const [botState, setBotState] = useState(BOT_STATE_STARTING);
27
  const localSessionId = useLocalSessionId();
28
+ const participantIds = useParticipantIds({ filter: "remote" });
29
 
30
  const start = useCallback(async () => {
31
  const resp = await fetch(`${apiUrl}/start`, {
 
65
  // Main call loop
66
  return (
67
  <main className="container py-24">
68
+ {roomUrl}
69
  <div className="grid grid-cols-2 grid-flow-col gap-4">
70
  <div>
71
  <Card headerText="Local Webcam" HeaderIcon={VideoCameraIcon}>
 
81
  <Card headerText="Inference" HeaderIcon={PaintBrushIcon}>
82
  <div className="overflow-hidden bg-gray-50 sm:rounded-lg">
83
  <div className="aspect-video flex items-center justify-center">
84
+ {participantIds.length ? (
85
+ <DailyVideo sessionId={participantIds[0]} />
86
+ ) : (
87
+ <Avatar />
88
+ )}
89
  </div>
90
  </div>
91
  </Card>
server.py CHANGED
@@ -68,7 +68,7 @@ def _start_bot(bot_path, room_url, args=None):
68
  daily_api_key = os.getenv("DAILY_API_KEY")
69
 
70
  #@TODO error handling here
71
-
72
  if args:
73
  extra_args = " ".join([f'-{x[0]} "{x[1]}"' for x in args])
74
  else:
@@ -101,7 +101,7 @@ def _start_bot(bot_path, room_url, args=None):
101
  @app.post("/start")
102
  async def start(request: Request):
103
  data = await request.json()
104
- return _start_bot("./app/bot.py", data.room_url)
105
 
106
  @app.post("/create")
107
  async def create():
 
68
  daily_api_key = os.getenv("DAILY_API_KEY")
69
 
70
  #@TODO error handling here
71
+
72
  if args:
73
  extra_args = " ".join([f'-{x[0]} "{x[1]}"' for x in args])
74
  else:
 
101
  @app.post("/start")
102
  async def start(request: Request):
103
  data = await request.json()
104
+ return _start_bot("./app/bot.py",data['room_url'])
105
 
106
  @app.post("/create")
107
  async def create():