Skip to content

Commit 658c145

Browse files
authored
feat: Added regions for break replacement (#159)
* Replace with interstitials * Removed interstitial logic in player * Migrated to hero ui * fix: Lint error * Linting error
1 parent 9560a8c commit 658c145

28 files changed

+262
-335
lines changed

bun.lockb

2.01 KB
Binary file not shown.

packages/app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
},
2323
"dependencies": {
2424
"@monaco-editor/react": "^4.6.0",
25-
"@nextui-org/react": "^2.4.8",
26-
"@nextui-org/use-infinite-scroll": "^2.1.5",
25+
"@heroui/react": "2.6.14",
26+
"@heroui/use-infinite-scroll": "2.2.3",
2727
"@superstreamer/api": "workspace:*",
2828
"@superstreamer/player": "workspace:*",
2929
"@tanstack/react-router": "^1.78.3",

packages/app/src/components/AutoRefresh.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Switch } from "@nextui-org/react";
1+
import { Switch } from "@heroui/react";
22
import { useRouter } from "@tanstack/react-router";
33
import { useEffect, useState } from "react";
44

@@ -34,7 +34,7 @@ export function AutoRefresh({
3434
}, [enabled, interval, time]);
3535

3636
return (
37-
<div className="flex items-center">
37+
<div className="flex items-center gap-2">
3838
<Switch
3939
size="sm"
4040
isSelected={enabled}

packages/app/src/components/FilePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Modal, ModalBody, ModalContent } from "@nextui-org/react";
1+
import { Modal, ModalBody, ModalContent } from "@heroui/react";
22
import useSWR from "swr";
33
import { DataView } from "./DataView";
44
import { useAuth } from "../auth";

packages/app/src/components/Form.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Button, Input } from "@nextui-org/react";
1+
import { Button, Input } from "@heroui/react";
22
import cn from "clsx";
33
import { useEffect } from "react";
44
import { useForm } from "react-hook-form";
55
import { Controller } from "react-hook-form";
6-
import type { InputProps } from "@nextui-org/input";
6+
import type { InputProps } from "@heroui/input";
77
import type { Control } from "react-hook-form";
88

99
interface FormProps<T extends FieldRecord> {

packages/app/src/components/FullTable.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { Pagination, Spinner } from "@nextui-org/react";
2-
import { Select, SelectItem } from "@nextui-org/select";
1+
import { Pagination, Spinner } from "@heroui/react";
2+
import { Select, SelectItem } from "@heroui/select";
33
import {
44
Table,
55
TableBody,
66
TableCell,
77
TableColumn,
88
TableHeader,
99
TableRow,
10-
} from "@nextui-org/table";
11-
import { useInfiniteScroll } from "@nextui-org/use-infinite-scroll";
10+
} from "@heroui/table";
11+
import { useInfiniteScroll } from "@heroui/use-infinite-scroll";
1212
import { useState } from "react";
13-
import type { SortDescriptor, TableProps } from "@nextui-org/table";
13+
import type { SortDescriptor, TableProps } from "@heroui/table";
1414
import type { ReactNode } from "@tanstack/react-router";
1515

1616
export interface Column {
@@ -51,7 +51,7 @@ export function FullTable<T, F extends Filter>({
5151
totalPages,
5252
}: FullTableProps<T, F>) {
5353
const [sortDescriptor, setSortDescriptor] = useState<SortDescriptor>({
54-
column: filter?.sortKey,
54+
column: filter?.sortKey ?? "",
5555
direction: filter?.sortDir === "asc" ? "ascending" : "descending",
5656
});
5757

packages/app/src/components/JobPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Card, CardBody, CardHeader } from "@nextui-org/react";
1+
import { Card, CardBody, CardHeader } from "@heroui/react";
22
import { DataView } from "./DataView";
33
import { Format } from "./Format";
44
import { Logs } from "./Logs";

packages/app/src/components/Logs.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ interface LogsProps {
66
}
77

88
export function Logs({ lines }: LogsProps) {
9+
if (!lines.length) {
10+
return <div className="text-xs">No logs available</div>;
11+
}
912
return (
1013
<ul className="flex flex-col gap-2">
1114
{lines.map((line, index) => (

packages/app/src/components/PlayerControls.tsx

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button } from "@nextui-org/react";
1+
import { Button } from "@heroui/react";
22
import { Events } from "@superstreamer/player";
33
import cn from "clsx";
44
import { useEffect, useRef, useState } from "react";
@@ -41,7 +41,7 @@ function PlayButton() {
4141
function Seekbar() {
4242
const { player } = usePlayer();
4343
const seekableStart = usePlayerSelector((player) => player.seekableStart);
44-
const time = usePlayerSelector((player) => player.time);
44+
const currentTime = usePlayerSelector((player) => player.currentTime);
4545
const duration = usePlayerSelector((player) => player.duration);
4646
const seekTo = usePlayerSelector((player) => player.seekTo);
4747

@@ -51,9 +51,8 @@ function Seekbar() {
5151
min: seekableStart,
5252
max: duration,
5353
onSeeked: (time) => {
54-
if (seekTo(time)) {
55-
setLastSeekTime(time);
56-
}
54+
seekTo(time);
55+
setLastSeekTime(time);
5756
},
5857
});
5958

@@ -62,19 +61,22 @@ function Seekbar() {
6261
return;
6362
}
6463

65-
const onSeekingChange = () => {
66-
if (!player.seeking) {
64+
const onTimeChange = () => {
65+
if (player.seeking || lastSeekTime == null) {
66+
return;
67+
}
68+
if (player.currentTime > lastSeekTime) {
6769
setLastSeekTime(null);
6870
}
6971
};
7072

71-
player.on(Events.SEEKING_CHANGE, onSeekingChange);
73+
player.on(Events.TIME_CHANGE, onTimeChange);
7274
return () => {
73-
player.off(Events.SEEKING_CHANGE, onSeekingChange);
75+
player.off(Events.TIME_CHANGE, onTimeChange);
7476
};
75-
}, [player]);
77+
}, [player, lastSeekTime]);
7678

77-
const fakeTime = lastSeekTime ?? time;
79+
const fakeTime = lastSeekTime ?? currentTime;
7880
let percentage = getPercentage(fakeTime, duration, seekableStart);
7981
if (seekbar.seeking) {
8082
percentage = seekbar.x;
@@ -166,16 +168,31 @@ function CuePoints() {
166168
return (
167169
<div className="relative h-4">
168170
{cuePoints.map((cuePoint) => {
171+
const left =
172+
(cuePoint.time - seekableStart) / (duration - seekableStart);
173+
174+
let width = 0;
175+
if (cuePoint.duration) {
176+
const right =
177+
(cuePoint.time + cuePoint.duration - seekableStart) /
178+
(duration - seekableStart);
179+
width = right - left;
180+
}
181+
169182
return (
170183
<div
171-
key={cuePoint}
184+
key={cuePoint.time}
172185
style={{
173-
left: `${((cuePoint - seekableStart) / (duration - seekableStart)) * 100}%`,
186+
left: `${((cuePoint.time - seekableStart) / (duration - seekableStart)) * 100}%`,
187+
width: width ? `${width * 100}%` : undefined,
174188
}}
175-
className="absolute -translate-x-1/2 flex items-center flex-col"
189+
className="absolute"
176190
>
177-
<div className="w-[2px] h-2 bg-yellow-500" />
178-
<div className="w-2 h-2 rounded-full bg-yellow-500" />
191+
<div className="absolute left-0 -translate-x-1/2 flex items-center flex-col">
192+
<div className="w-[2px] h-2 bg-yellow-500" />
193+
<div className="w-2 h-2 rounded-full bg-yellow-500" />
194+
</div>
195+
<div className="absolute w-full h-[2px] top-3 bg-yellow-500" />
179196
</div>
180197
);
181198
})}
@@ -184,14 +201,14 @@ function CuePoints() {
184201
}
185202

186203
function Time() {
187-
const time = usePlayerSelector((player) => player.time);
204+
const currentTime = usePlayerSelector((player) => player.currentTime);
188205
const seekableStart = usePlayerSelector((player) => player.seekableStart);
189206
const duration = usePlayerSelector((player) => player.duration);
190207
const live = usePlayerSelector((player) => player.live);
191208

192209
return (
193210
<div className="flex text-sm mb-2">
194-
{hms(time)}
211+
{hms(currentTime)}
195212
<div className="grow" />
196213
{live ? `${hms(seekableStart)} - ${hms(duration)}` : `${hms(duration)}`}
197214
</div>
@@ -260,10 +277,7 @@ function Qualities() {
260277
}
261278

262279
function hms(seconds: number) {
263-
return (
264-
new Date(seconds * 1000).toUTCString().match(/(\d\d:\d\d:\d\d)/)?.[0] ??
265-
"00:00:00"
266-
);
280+
return (new Date(seconds * 1000).toUTCString().match(/(\d\d:\d\d:\d\d)/)?.[0] ?? "00:00:00");
267281
}
268282

269283
function getPercentage(time: number, duration: number, seekableStart: number) {

packages/app/src/components/ScrollCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Card } from "@nextui-org/react";
1+
import { Card } from "@heroui/react";
22
import type { ReactNode } from "react";
33

44
interface ScrollCardProps {

0 commit comments

Comments
 (0)