Preload notification audio and add AudioPreloader component
Added an AudioPreloader React component to preload the /hohoho.mp3 audio file for notifications, and included it in the app layout. Also updated _document.tsx to add a preload link for the audio file. Added yt-dlp.exe binary to the repository.
This commit is contained in:
@@ -3,7 +3,9 @@ import { Html, Head, Main, NextScript } from "next/document";
|
||||
export default function Document() {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head />
|
||||
<Head>
|
||||
<link rel="preload" href="/hohoho.mp3" as="audio" type="audio/mpeg" />
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Metadata, Viewport } from "next"
|
||||
import KeepOnlineWrapper from "@/components/layout/KeepOnlineWrapper"
|
||||
import { ChristmasDecorations } from "@/components/christmas-decorations"
|
||||
import { isDecember } from "@/lib/utils/christmas"
|
||||
import { AudioPreloader } from "@/components/audio-preloader"
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] })
|
||||
|
||||
@@ -77,6 +78,7 @@ export default function RootLayout({
|
||||
<html lang="en" suppressHydrationWarning className={isDec ? "christmas-theme" : ""}>
|
||||
<body className={inter.className}>
|
||||
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
|
||||
<AudioPreloader />
|
||||
<NotificationProvider>
|
||||
{isDec && <ChristmasDecorations />}
|
||||
<Toaster
|
||||
|
||||
27
components/audio-preloader.tsx
Normal file
27
components/audio-preloader.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect } from "react"
|
||||
|
||||
/**
|
||||
* Preloads the notification audio file to ensure it's ready when needed
|
||||
*/
|
||||
export function AudioPreloader() {
|
||||
useEffect(() => {
|
||||
// Preload the audio file
|
||||
const audio = new Audio('/hohoho.mp3')
|
||||
audio.preload = 'auto'
|
||||
|
||||
// Try to load it immediately
|
||||
audio.load().catch(err => {
|
||||
console.log('Audio preload failed (non-critical):', err)
|
||||
})
|
||||
|
||||
return () => {
|
||||
// Cleanup
|
||||
audio.src = ''
|
||||
}
|
||||
}, [])
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
BIN
yt-dlp.exe
Normal file
BIN
yt-dlp.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user