Skip to content

Commit

Permalink
very basic video playback
Browse files Browse the repository at this point in the history
  • Loading branch information
Sejmou committed Mar 14, 2023
1 parent 36875ab commit 8fdcfd1
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ NEXTAUTH_URL="http://localhost:3000"

# Next Auth Discord Provider
DISCORD_CLIENT_ID=""
DISCORD_CLIENT_SECRET=""
DISCORD_CLIENT_SECRET=""
1 change: 0 additions & 1 deletion src/components/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { api } from "~/utils/api";
const Breadcrumbs = () => {
const router = useRouter();
const subpaths = getSubpaths(router);
console.log(subpaths);
const crumbs = useCrumbs(subpaths);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserAreaBaseLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Layout({ children }: Props) {
Logout
</Button>
</div>
<div className="flex-1">{children}</div>
<div className="flex-1 overflow-auto">{children}</div>
</Card>
</main>
</>
Expand Down
7 changes: 7 additions & 0 deletions src/components/VideoPlayer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const videoApiBaseURL = "http://localhost:4444/videos/";

type Props = { videoId: string };
const VideoPlayer = ({ videoId }: Props) => {
return <video src={`${videoApiBaseURL}${videoId}`} controls></video>;
};
export default VideoPlayer;
6 changes: 3 additions & 3 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const server = z.object({
// Since NextAuth.js automatically uses the VERCEL_URL if present.
(str) => process.env.VERCEL_URL ?? str,
// VERCEL_URL doesn't include `https` so it cant be validated as a URL
process.env.VERCEL ? z.string().min(1) : z.string().url(),
process.env.VERCEL ? z.string().min(1) : z.string().url()
),
// Add `.min(1) on ID and SECRET if you want to make sure they're not empty
DISCORD_CLIENT_ID: z.string(),
Expand Down Expand Up @@ -70,7 +70,7 @@ if (!!process.env.SKIP_ENV_VALIDATION == false) {
if (parsed.success === false) {
console.error(
"❌ Invalid environment variables:",
parsed.error.flatten().fieldErrors,
parsed.error.flatten().fieldErrors
);
throw new Error("Invalid environment variables");
}
Expand All @@ -84,7 +84,7 @@ if (!!process.env.SKIP_ENV_VALIDATION == false) {
throw new Error(
process.env.NODE_ENV === "production"
? "❌ Attempted to access a server-side environment variable on the client"
: `❌ Attempted to access server-side environment variable '${prop}' on the client`,
: `❌ Attempted to access server-side environment variable '${prop}' on the client`
);
return target[/** @type {keyof typeof target} */ (prop)];
},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/courses/[id]/[chapterId]/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Head from "next/head";
import { useRouter } from "next/router";
import { getLayout } from "~/components/UserAreaBaseLayout";
import VideoPlayer from "~/components/VideoPlayer";
import { api } from "~/utils/api";
import { getServerSideProps as getServerSidePropsRedirect } from "~/utils/unauthorized-redirect";
import { NextPageWithLayout } from "../../../_app";
Expand Down Expand Up @@ -35,6 +36,7 @@ const Videos: NextPageWithLayout = () => {
{videoData.videos.map((video) => (
<div key={video.id}>
<h3 className="text-lg font-semibold">{video.title}</h3>
<VideoPlayer videoId={video.id} />
</div>
))}
</div>
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"noUncheckedIndexedAccess": true,
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
"~/*": ["./src/*"],
"types": ["vidstack/globals"]
}
},
"include": [
Expand Down

0 comments on commit 8fdcfd1

Please sign in to comment.