Skip to content

Commit

Permalink
HLS.js wrapper package (#16)
Browse files Browse the repository at this point in the history
* Added hlsjs wrapper package

* Added Basic UI

* Visibility effect on controls

* Seekbar delta calculation in order not to jump back to previously seeked offset for a brief amount of time
  • Loading branch information
matvp91 authored Sep 5, 2024
1 parent 62eed4d commit e2aea7d
Show file tree
Hide file tree
Showing 49 changed files with 39,579 additions and 91 deletions.
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/OpenApiReference.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiReferenceReact } from "@scalar/api-reference-react";
import { tsr } from "@/tsr";
import "@scalar/api-reference-react/style.css";
import { useEffect } from "react";
import "@scalar/api-reference-react/style.css";

type OpenApiReferenceProps = {
url: string;
Expand Down
13 changes: 4 additions & 9 deletions packages/dashboard/src/hooks/useJob.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import { tsr } from "@/tsr";
import { useEffect, useRef } from "react";
import type { JobDto } from "@/tsr";

export function useJob(id: string) {
const lastResultRef = useRef<JobDto>();

const { data } = tsr.getJob.useQuery({
queryKey: ["jobsFromRoot", id],
queryData: { params: { id }, query: { fromRoot: true } },
refetchInterval: 2000,
});

useEffect(() => {
if (data) {
lastResultRef.current = data.body;
}
}, [data]);
const rootJob = data?.body;

const rootJob = data?.body ?? lastResultRef.current;
if (!rootJob) {
return null;
}

const job = findJob(rootJob, id);
if (!job) {
throw new Error("Job not found in tree");
}

return { job, rootJob };
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/pages/JobPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function JobPage() {
const { job, rootJob } = result;

return (
<div className="min-h-full flex flex-col grow bg-white">
<div className="min-h-full flex flex-col grow">
<div className="p-2 border-b border-border">
<Button asChild variant="ghost">
<Link to="/jobs">Jobs</Link>
Expand Down
28 changes: 13 additions & 15 deletions packages/dashboard/src/pages/JobsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@ export function JobsPage() {
const filteredJobs = filterJobs(data.body, filter);

return (
<div className="min-h-full bg-[#fafafa]">
<Container className="py-4 min-h-full">
<h1 className="text-lg font-medium">Jobs</h1>
<div className="my-4 flex items-center">
<JobsStats jobs={filteredJobs} />
<div className="ml-auto">
<JobsFilter
allJobs={data.body}
filter={filter}
onChange={setFilter}
/>
</div>
<Container className="py-4">
<h1 className="text-lg font-medium">Jobs</h1>
<div className="my-4 flex items-center">
<JobsStats jobs={filteredJobs} />
<div className="ml-auto">
<JobsFilter
allJobs={data.body}
filter={filter}
onChange={setFilter}
/>
</div>
<JobsList jobs={filteredJobs} />
</Container>
</div>
</div>
<JobsList jobs={filteredJobs} />
</Container>
);
}
24 changes: 24 additions & 0 deletions packages/hlsjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
9 changes: 9 additions & 0 deletions packages/hlsjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# hls.js wrapper

Using https://www.svgrepo.com/collection/solar-broken-line-icons for icons.

## Bugs

- When we have a preroll interstitial and we select the subtitle, it will only respect the first selected subtitle. Changing subtitle afterwards has no effect.

- When interstitials startTime is beyond the end of the content duration, there are stalls sometimes and content stops buffering. This can be replicated manually when setting interstitials further away.
Loading

0 comments on commit e2aea7d

Please sign in to comment.