Skip to content

Commit 9460a5c

Browse files
committed
Add URL params for video id and baseline spm
1 parent 08bab7c commit 9460a5c

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ RowState is a web application that connects your rowing machine to YouTube video
1111
- **Heart Rate Monitoring** - Optional Bluetooth heart rate sensor support
1212
- **Real-time Metrics** - Live display of stroke rate, split time, distance, power, and heart rate
1313
- **YouTube Integration** - Row along to any YouTube video
14+
- **URL Parameters** - Share links with pre-configured videos and stroke rates
1415
- **Visual Metronome** - Animated vertical bar that moves with your rowing rhythm (drive/recovery phases)
1516
- **Video Volume Control** - Adjustable volume slider in the settings panel
1617

@@ -50,6 +51,18 @@ Bluetooth connections will not work in Firefox, Safari, or iOS browsers.
5051
4. Set your baseline stroke rate (default: 22 SPM = 1.0x speed)
5152
5. Start rowing - the video speed adjusts automatically
5253

54+
### URL Parameters
55+
56+
You can share RowState links with pre-configured videos and stroke rates using URL parameters:
57+
58+
```
59+
https://double-a-92.github.io/RowState/?v=VIDEO_ID&spm=STROKE_RATE
60+
```
61+
62+
**Parameters:**
63+
- `v` - YouTube video ID (11 characters)
64+
- `spm` - Baseline strokes per minute (10-40, default: 22)
65+
5366
## License
5467

5568
MIT

src/App.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,30 @@ import { useSmartPlaybackRate } from './hooks/useSmartPlaybackRate';
66
import { useMetronome, type MetronomePhase } from './hooks/useMetronome';
77
import { Overlay } from './components/Overlay';
88

9+
// Helper function to parse URL parameters
10+
const getUrlParams = () => {
11+
const params = new URLSearchParams(window.location.search);
12+
return {
13+
videoId: params.get('v'),
14+
spm: params.get('spm')
15+
};
16+
};
17+
918
function App() {
1019
const { status, metrics, connect, disconnect } = useRowingMetrics();
1120
const { status: hrStatus, heartRateData, connect: hrConnect, disconnect: hrDisconnect } = useHeartRate();
12-
// Default video
13-
const [videoUrl, setVideoUrl] = useState('https://www.youtube.com/watch?v=FljjSVANT9I');
14-
const [baselineSpm, setBaselineSpm] = useState(22);
21+
22+
// Parse URL parameters on initial load
23+
const urlParams = getUrlParams();
24+
const videoId = urlParams.videoId;
25+
const spmParam = urlParams.spm;
26+
27+
// Set initial video URL based on URL parameter or default
28+
const initialVideoUrl = videoId ? `https://www.youtube.com/watch?v=${videoId}` : 'https://www.youtube.com/watch?v=FljjSVANT9I';
29+
const initialSpm = spmParam ? parseInt(spmParam, 10) : 22;
30+
31+
const [videoUrl, setVideoUrl] = useState(initialVideoUrl);
32+
const [baselineSpm, setBaselineSpm] = useState(initialSpm);
1533
const [metronomeEnabled, setMetronomeEnabled] = useState(false);
1634
const [metronomePhase, setMetronomePhase] = useState<MetronomePhase>('recovery');
1735
const [isVideoPlaying, setIsVideoPlaying] = useState(false);

0 commit comments

Comments
 (0)