Skip to content

Commit 6feea63

Browse files
committed
chore: remove chromecast support
1 parent 9576aef commit 6feea63

File tree

14 files changed

+26
-591
lines changed

14 files changed

+26
-591
lines changed

index.html

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
2929
/>
3030

31-
<!-- Google Cast SDK -->
32-
<script
33-
type="text/javascript"
34-
src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"
35-
></script>
36-
3731
<script>
3832
tailwind.config = {
3933
darkMode: "class",

src/components/Player/PlayerActions.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,20 @@ import { Episode } from "../../types";
33

44
interface PlayerActionsProps {
55
hasQueue: boolean;
6-
isCastAvailable: boolean;
7-
isCasting: boolean;
86
playbackRate: number;
97
speeds: number[];
108
onShare: () => void;
119
onToggleQueue: () => void;
12-
onToggleCast: () => void;
1310
onChangeSpeed: () => void;
1411
onClose: () => void;
1512
}
1613

1714
export const PlayerActions: React.FC<PlayerActionsProps> = ({
1815
hasQueue,
19-
isCastAvailable,
20-
isCasting,
2116
playbackRate,
2217
speeds,
2318
onShare,
2419
onToggleQueue,
25-
onToggleCast,
2620
onChangeSpeed,
2721
onClose,
2822
}) => {
@@ -46,20 +40,6 @@ export const PlayerActions: React.FC<PlayerActionsProps> = ({
4640
</button>
4741
)}
4842

49-
{isCastAvailable && (
50-
<button
51-
onClick={onToggleCast}
52-
className={`w-9 h-9 rounded-full transition flex items-center justify-center ${
53-
isCasting
54-
? "bg-indigo-600 text-white"
55-
: "bg-zinc-100 dark:bg-zinc-800 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-200 dark:hover:bg-zinc-700"
56-
}`}
57-
title="Cast"
58-
>
59-
<i className="fa-solid fa-tv text-xs"></i>
60-
</button>
61-
)}
62-
6343
<button
6444
onClick={onChangeSpeed}
6545
className="w-9 h-9 rounded-full bg-zinc-100 dark:bg-zinc-800 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-200 dark:hover:bg-zinc-700 transition flex items-center justify-center text-[10px] font-black"

src/components/Player/PlayerContainer.tsx

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, { useState, useEffect, useRef, useCallback } from 'react';
22
import { Episode, Podcast } from '../../types';
33
import { storageService } from '../../services/storageService';
4-
import { castService } from '../../services/castService';
5-
import { APP_CONFIG } from '../../config';
64
import { PlayerPresentation } from './PlayerPresentation';
75

86
export interface PlayerContainerProps {
@@ -39,10 +37,6 @@ export const PlayerContainer: React.FC<PlayerContainerProps> = ({
3937
const [duration, setDuration] = useState(0);
4038
const [playbackRate, setPlaybackRate] = useState(1);
4139

42-
// Cast state
43-
const [isCasting, setIsCasting] = useState(false);
44-
const [castDeviceName, setCastDeviceName] = useState<string | undefined>(undefined);
45-
4640
// UI state
4741
const [showQueue, setShowQueue] = useState(false);
4842
const [showSpeedMenu, setShowSpeedMenu] = useState(false);
@@ -147,32 +141,9 @@ export const PlayerContainer: React.FC<PlayerContainerProps> = ({
147141
};
148142
}, [episode.id, episode.audioUrl, autoPlay, onNext, onReady]);
149143

150-
// Initialize cast service
151-
useEffect(() => {
152-
castService.setEnabled(APP_CONFIG.cast.enabled);
153-
castService.initialize();
154-
155-
const unsubscribeState = castService.onStateChange((connected, deviceName) => {
156-
setIsCasting(connected);
157-
setCastDeviceName(deviceName);
158-
});
159-
160-
const unsubscribeMedia = castService.onMediaStatus((status) => {
161-
if (status) {
162-
setIsPlaying(status.isPlaying);
163-
setCurrentTime(status.currentTime);
164-
}
165-
});
166-
167-
return () => {
168-
unsubscribeState();
169-
unsubscribeMedia();
170-
};
171-
}, []);
172-
173144
// Start progress save interval when playing
174145
useEffect(() => {
175-
if (isPlaying && !isCasting) {
146+
if (isPlaying) {
176147
saveIntervalRef.current = setInterval(() => {
177148
if (audioRef.current) {
178149
saveProgress(audioRef.current.currentTime, audioRef.current.duration);
@@ -190,7 +161,7 @@ export const PlayerContainer: React.FC<PlayerContainerProps> = ({
190161
clearInterval(saveIntervalRef.current);
191162
}
192163
};
193-
}, [isPlaying, isCasting]);
164+
}, [isPlaying]);
194165

195166
// Keyboard shortcuts
196167
useEffect(() => {
@@ -230,48 +201,30 @@ export const PlayerContainer: React.FC<PlayerContainerProps> = ({
230201
const togglePlay = useCallback(() => {
231202
if (!audioRef.current) return;
232203

233-
if (isCasting) {
234-
if (isPlaying) {
235-
castService.pause();
236-
} else {
237-
castService.play();
238-
}
204+
if (isPlaying) {
205+
audioRef.current.pause();
206+
saveProgress(audioRef.current.currentTime, audioRef.current.duration);
239207
} else {
240-
if (isPlaying) {
241-
audioRef.current.pause();
242-
saveProgress(audioRef.current.currentTime, audioRef.current.duration);
243-
} else {
244-
audioRef.current.play().catch((error) => {
245-
setErrorMessage('Playback failed: ' + error.message);
246-
});
247-
}
208+
audioRef.current.play().catch((error) => {
209+
setErrorMessage('Playback failed: ' + error.message);
210+
});
248211
}
249-
}, [isCasting, isPlaying, saveProgress]);
212+
}, [isPlaying, saveProgress]);
250213

251214
// Skip forward/backward
252215
const skipSeconds = useCallback((seconds: number) => {
253216
if (!audioRef.current) return;
254217

255-
if (isCasting) {
256-
const newTime = Math.max(0, Math.min(duration, currentTime + seconds));
257-
castService.seek(newTime);
258-
} else {
259-
audioRef.current.currentTime = Math.max(0, Math.min(duration, audioRef.current.currentTime + seconds));
260-
}
261-
}, [isCasting, currentTime, duration]);
218+
audioRef.current.currentTime = Math.max(0, Math.min(duration, audioRef.current.currentTime + seconds));
219+
}, [duration]);
262220

263221
// Seek to percentage
264222
const seekToPercentage = useCallback((percentage: number) => {
265223
if (!audioRef.current) return;
266224

267225
const newTime = (percentage / 100) * duration;
268-
269-
if (isCasting) {
270-
castService.seek(newTime);
271-
} else {
272-
audioRef.current.currentTime = newTime;
273-
}
274-
}, [duration, isCasting]);
226+
audioRef.current.currentTime = newTime;
227+
}, [duration]);
275228

276229
// Change playback speed
277230
const changePlaybackRate = useCallback((rate: number) => {
@@ -282,23 +235,13 @@ export const PlayerContainer: React.FC<PlayerContainerProps> = ({
282235
setShowSpeedMenu(false);
283236
}, []);
284237

285-
// Cast episode
286-
const handleCast = useCallback(() => {
287-
// Cast functionality - would need to be implemented in castService
288-
// For now, this is a placeholder
289-
console.log('Cast functionality not yet implemented');
290-
}, []);
291-
292238
return (
293239
<PlayerPresentation
294240
episode={episode}
295241
podcast={podcast}
296242
queue={queue}
297243
isPlaying={isPlaying}
298244
isBuffering={isBuffering}
299-
isCasting={isCasting}
300-
isCastAvailable={false}
301-
castDeviceName={castDeviceName}
302245
currentTime={currentTime}
303246
duration={duration}
304247
playbackRate={playbackRate}
@@ -311,7 +254,6 @@ export const PlayerContainer: React.FC<PlayerContainerProps> = ({
311254
onSeek={seekToPercentage}
312255
onChangeSpeed={() => setShowSpeedMenu(!showSpeedMenu)}
313256
onToggleQueue={() => setShowQueue(!showQueue)}
314-
onToggleCast={handleCast}
315257
onShare={onShare}
316258
onClose={onClose}
317259
onRemoveFromQueue={onRemoveFromQueue}

src/components/Player/PlayerInfo.tsx

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ interface PlayerInfoProps {
55
episode: Episode;
66
podcast: Podcast;
77
isBuffering: boolean;
8-
isCasting: boolean;
9-
castDeviceName?: string;
108
}
119

1210
export const PlayerInfo: React.FC<PlayerInfoProps> = ({
1311
episode,
1412
podcast,
1513
isBuffering,
16-
isCasting,
17-
castDeviceName,
1814
}) => {
1915
return (
2016
<div className="flex items-center gap-4 flex-1 min-w-0 w-full">
@@ -35,14 +31,7 @@ export const PlayerInfo: React.FC<PlayerInfoProps> = ({
3531
{episode.title}
3632
</h4>
3733
<p className="text-xs text-zinc-500 dark:text-zinc-400 truncate font-medium">
38-
{isCasting ? (
39-
<span className="flex items-center gap-1.5">
40-
<i className="fa-solid fa-tv text-indigo-600"></i>
41-
Casting to {castDeviceName || "Device"}
42-
</span>
43-
) : (
44-
podcast.title
45-
)}
34+
{podcast.title}
4635
</p>
4736
</div>
4837
</div>

src/components/Player/PlayerPresentation.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ export interface PlayerPresentationProps {
2222
playbackRate: number;
2323
speeds: number[];
2424

25-
// Cast state
26-
isCasting: boolean;
27-
isCastAvailable: boolean;
28-
castDeviceName?: string;
29-
3025
// UI state
3126
showQueue: boolean;
3227

@@ -38,7 +33,6 @@ export interface PlayerPresentationProps {
3833
onSeek: (percent: number) => void;
3934
onShare: () => void;
4035
onToggleQueue: () => void;
41-
onToggleCast: () => void;
4236
onChangeSpeed: () => void;
4337
onClose: () => void;
4438
onRemoveFromQueue: (id: string) => void;
@@ -68,9 +62,6 @@ export const PlayerPresentation: React.FC<PlayerPresentationProps> = ({
6862
queue,
6963
isPlaying,
7064
isBuffering,
71-
isCasting,
72-
isCastAvailable,
73-
castDeviceName,
7465
currentTime,
7566
duration,
7667
playbackRate,
@@ -83,7 +74,6 @@ export const PlayerPresentation: React.FC<PlayerPresentationProps> = ({
8374
onSeek,
8475
onShare,
8576
onToggleQueue,
86-
onToggleCast,
8777
onChangeSpeed,
8878
onClose,
8979
onRemoveFromQueue,
@@ -98,8 +88,6 @@ export const PlayerPresentation: React.FC<PlayerPresentationProps> = ({
9888
episode={episode}
9989
podcast={podcast}
10090
isBuffering={isBuffering}
101-
isCasting={isCasting}
102-
castDeviceName={castDeviceName}
10391
/>
10492

10593
<div className="flex flex-col items-center gap-2 flex-[2] w-full">
@@ -120,13 +108,10 @@ export const PlayerPresentation: React.FC<PlayerPresentationProps> = ({
120108

121109
<PlayerActions
122110
hasQueue={queue.length > 0}
123-
isCastAvailable={isCastAvailable}
124-
isCasting={isCasting}
125111
playbackRate={playbackRate}
126112
speeds={speeds}
127113
onShare={onShare}
128114
onToggleQueue={onToggleQueue}
129-
onToggleCast={onToggleCast}
130115
onChangeSpeed={onChangeSpeed}
131116
onClose={onClose}
132117
/>

src/components/Player/__tests__/PlayerContainer.test.tsx

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import { act } from '@testing-library/react';
44
import { PlayerContainer } from '../PlayerContainer';
55
import { createMockEpisode, createMockPodcast } from '../../../test-utils';
66
import * as storageService from '../../../services/storageService';
7-
import * as castService from '../../../services/castService';
87

98
// Mock services
109
vi.mock('../../../services/storageService');
11-
vi.mock('../../../services/castService');
1210

1311
// Mock Audio API
1412
class MockAudio {
@@ -86,13 +84,6 @@ describe('PlayerContainer', () => {
8684
// Setup default storage service mocks
8785
vi.spyOn(storageService.storageService, 'getHistory').mockReturnValue({});
8886
vi.spyOn(storageService.storageService, 'updatePlayback').mockImplementation(() => {});
89-
90-
// Setup default cast service mocks
91-
vi.spyOn(castService.castService, 'setEnabled').mockImplementation(() => {});
92-
vi.spyOn(castService.castService, 'initialize').mockResolvedValue(false);
93-
vi.spyOn(castService.castService, 'onStateChange').mockReturnValue(() => {});
94-
vi.spyOn(castService.castService, 'onMediaStatus').mockReturnValue(() => {});
95-
vi.spyOn(castService.castService, 'isPlaying').mockReturnValue(false);
9687
});
9788

9889
afterEach(() => {
@@ -239,28 +230,6 @@ describe('PlayerContainer', () => {
239230
expect(storageService.storageService.getHistory).toHaveBeenCalled();
240231
});
241232

242-
it('initializes cast service on mount', () => {
243-
const setEnabledSpy = vi.spyOn(castService.castService, 'setEnabled');
244-
const initializeSpy = vi.spyOn(castService.castService, 'initialize');
245-
246-
render(<PlayerContainer {...defaultProps} />);
247-
248-
expect(setEnabledSpy).toHaveBeenCalled();
249-
expect(initializeSpy).toHaveBeenCalled();
250-
});
251-
252-
it('cleans up cast service listeners on unmount', () => {
253-
const unsubscribe = vi.fn();
254-
vi.spyOn(castService.castService, 'onStateChange').mockReturnValue(unsubscribe);
255-
vi.spyOn(castService.castService, 'onMediaStatus').mockReturnValue(unsubscribe);
256-
257-
const { unmount } = render(<PlayerContainer {...defaultProps} />);
258-
259-
unmount();
260-
261-
expect(unsubscribe).toHaveBeenCalledTimes(2);
262-
});
263-
264233
it('calls onProgress callback when provided', async () => {
265234
const user = userEvent.setup();
266235
const onProgress = vi.fn();

0 commit comments

Comments
 (0)