Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-timeago": "^8.3.0",
"react-use-cookie": "^1.6.1",
"redux": "^4.2.1",
"sonner": "^2.0.7",
"tailwind-merge": "^3.3.1",
"thenby": "^1.3.4",
"ua-parser-js": "^1.0.37",
Expand Down
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions public/gapless.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
onPlayPreviousTrack,
onStartNewTrack,
webAudioIsDisabled = false,
onError,
} = props;

this.props = {
Expand All @@ -50,6 +51,7 @@
onPlayNextTrack,
onPlayPreviousTrack,
onStartNewTrack,
onError,
};

this.state = {
Expand Down Expand Up @@ -209,6 +211,10 @@

this.tracks.map((track) => track.setVolume(nextVolume));
}

onError() {
if (this.props.onError) this.props.onError();
}
}

class Track {
Expand Down Expand Up @@ -485,6 +491,7 @@
// basic event handlers
audioOnError = (e) => {
this.debug('audioOnError', e);
this.queue.onError();
};

onEnded(from) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/(browse)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import NavBar from '@/components/NavBar';
import cn from '@/lib/cn';
import { getIsInIframe } from '@/lib/isInIframe';
import { ReactNode } from 'react';
import { Toaster } from 'sonner';

export default async function BrowseLayout({
children,
Expand All @@ -23,6 +24,7 @@ export default async function BrowseLayout({

return (
<Flex column className="h-screen">
<Toaster id="audio-error" position="top-center" richColors closeButton />
<NavBar />
<div
className={cn(
Expand Down
2 changes: 2 additions & 0 deletions src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import player from '../lib/player';
import { durationToHHMMSS, removeLeadingZero, splitShowDate } from '../lib/utils';
import Flex from './Flex';
import {
AlertCircle,
ChevronDown,
FastForwardIcon,
ListMusicIcon,
Expand All @@ -17,6 +18,7 @@ import {
RewindIcon,
Volume2Icon,
} from 'lucide-react';
import { Toaster } from 'sonner';

interface Props {
artistSlugsToName: Record<string, string | undefined>;
Expand Down
7 changes: 7 additions & 0 deletions src/lib/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { splitShowDate } from './utils';
import { scrobblePlay } from '../redux/modules/live';
import { updatePlayback } from '../redux/modules/playback';
import { ActiveTrack, GaplessMetadata } from '../types';
import { toast } from 'sonner';

declare global {
interface Window {
Expand Down Expand Up @@ -156,6 +157,12 @@ const player = new Gapless.Queue({
}
}
},
onError: () => {
toast.error('There was an error loading your audio', {
toasterId: 'audio-error',
duration: Infinity,
});
},
});

export function initGaplessPlayer(nextStore, changeURL) {
Expand Down