Skip to content

Commit 76136db

Browse files
authored
Merge pull request #25 from htdguide/testing
Some design fixes and step back for the wallpaper
2 parents ff5af59 + 8f6462e commit 76136db

File tree

3 files changed

+16
-101
lines changed

3 files changed

+16
-101
lines changed
Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,10 @@
1-
import React, {
2-
useState,
3-
useRef,
4-
useEffect,
5-
forwardRef,
6-
useImperativeHandle,
7-
} from 'react';
1+
import React, { useState } from 'react';
82
import './Wallpaper.css';
93
import SequoiaSunriseImage from '../../media/wallpaper/SequoiaSunrise.jpg';
10-
import { FocusWrapper } from '../../interactions/FocusControl/FocusControl.jsx';
4+
import { FocusWrapper } from '../../interactions/FocusControl/FocusControl.jsx'; // Import FocusWrapper
115

12-
const Wallpaper = forwardRef((props, ref) => {
6+
function Wallpaper() {
137
const [isVideoLoaded, setIsVideoLoaded] = useState(false);
14-
const videoRef = useRef(null);
15-
const segmentTimer = useRef(null);
16-
// Prevent overlapping segment triggers
17-
const segmentInProgress = useRef(false);
18-
19-
// Configurable parameters:
20-
const speedUpDuration = 1; // seconds: video speeds up from 0 to 1
21-
const normalDuration = 4; // seconds: video plays at normal speed (1×)
22-
const slowDownDuration = 1; // seconds: video slows down from 1 to 0
23-
const segmentDuration = speedUpDuration + normalDuration + slowDownDuration; // Total segment duration (default: 10 seconds)
24-
25-
// Function to trigger a segment: speed-up, normal playback, and then slow-down.
26-
const playSegment = () => {
27-
if (!videoRef.current || segmentInProgress.current) return;
28-
segmentInProgress.current = true;
29-
30-
// Start playing from current position.
31-
videoRef.current.play().catch((err) => {
32-
console.error('Error playing video:', err);
33-
});
34-
35-
const startTime = Date.now();
36-
37-
// Clear any existing timer.
38-
if (segmentTimer.current) {
39-
clearInterval(segmentTimer.current);
40-
}
41-
42-
segmentTimer.current = setInterval(() => {
43-
const elapsed = (Date.now() - startTime) / 1000;
44-
45-
if (elapsed < speedUpDuration) {
46-
// Speed Up Phase: Increase playback rate linearly from 0 to 1.
47-
const t = elapsed / speedUpDuration;
48-
videoRef.current.playbackRate = t;
49-
} else if (elapsed < speedUpDuration + normalDuration) {
50-
// Normal Playback Phase: Maintain a playback rate of 1.
51-
videoRef.current.playbackRate = 1;
52-
} else if (elapsed < segmentDuration) {
53-
// Slow Down Phase: Decrease playback rate linearly from 1 to 0.
54-
const slowdownElapsed = elapsed - (speedUpDuration + normalDuration);
55-
videoRef.current.playbackRate = 1 * (1 - slowdownElapsed / slowDownDuration);
56-
} else {
57-
// End of the segment: pause the video and reset the playback rate.
58-
videoRef.current.playbackRate = 0;
59-
videoRef.current.pause();
60-
clearInterval(segmentTimer.current);
61-
segmentTimer.current = null;
62-
segmentInProgress.current = false;
63-
}
64-
}, 100); // update every 100ms
65-
};
66-
67-
// Expose playSegment so that parent components can trigger the next segment.
68-
useImperativeHandle(ref, () => ({
69-
playSegment,
70-
}));
71-
72-
// Automatically trigger the initial segment once the video is loaded.
73-
useEffect(() => {
74-
if (isVideoLoaded) {
75-
playSegment();
76-
}
77-
// Cleanup on unmount.
78-
return () => {
79-
if (segmentTimer.current) {
80-
clearInterval(segmentTimer.current);
81-
}
82-
};
83-
}, [isVideoLoaded]);
848

859
return (
8610
<FocusWrapper name="Wallpaper">
@@ -94,23 +18,22 @@ const Wallpaper = forwardRef((props, ref) => {
9418

9519
{/* Background video */}
9620
<video
97-
ref={videoRef}
98-
className="wallpaper-video"
21+
className={isVideoLoaded ? 'wallpaper-video' : 'wallpaper-video hidden'}
22+
autoPlay
9923
muted
100-
loop={false}
24+
loop
10125
playsInline
10226
onLoadedData={() => setIsVideoLoaded(true)}
103-
onError={(e) => console.error('Video failed to load:', e)}
27+
onError={(e) => {
28+
console.error('Video failed to load:', e);
29+
}}
10430
>
105-
<source
106-
src="/WebintoshHD/Wallpapers/SequoiaSunrise.mp4"
107-
type="video/mp4"
108-
/>
31+
<source src="/WebintoshHD/Wallpapers/SequoiaSunrise.mp4" type="video/mp4" />
10932
Your browser does not support the video tag.
11033
</video>
11134
</div>
11235
</FocusWrapper>
11336
);
114-
});
37+
}
11538

116-
export default Wallpaper;
39+
export default Wallpaper;

src/configs/DockConfig/DockConfig.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const DOCK_CONFIG = {
3838

3939
// Vertical orientation overrides (for devices in portrait mode).
4040
vertical: {
41-
ICON_SIZE: 56,
41+
ICON_SIZE: 50,
4242
ICON_MARGIN: 8,
4343
ADDITIONAL_MARGIN: 12,
4444
DOCK_SPREAD: 120,

src/services/AppsContext/AppsContext.jsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,6 @@ const initialAppsList = [
6060
priority: 3,
6161
indock: false,
6262
},
63-
{
64-
id: 'psx',
65-
name: 'PSX',
66-
icon: psxIcon,
67-
component: null,
68-
priority: 6,
69-
indock: false,
70-
},
7163
{
7264
id: 'finder',
7365
name: 'Finder',
@@ -101,9 +93,9 @@ const initialAppsList = [
10193
indock: true,
10294
},
10395
{
104-
id: 'testapp1',
105-
name: 'TestApp1',
106-
icon: defaultIcon,
96+
id: 'psx',
97+
name: 'PSX',
98+
icon: psxIcon,
10799
component: null,
108100
priority: 6,
109101
indock: true,

0 commit comments

Comments
 (0)