My daughter is three. She likes songs that come with motions: “Teddy Bear, Teddy Bear, turn around,” “Wheels on the Bus,” “Hokey Pokey.” The problem is that I don’t remember the motions. I know the tune, but I don’t know what the hands do in the second line.

The Need: The Parent Has to Learn the Dance First

My daughter’s player is built on one rule: pictures only, no video. She hears the song and sees a cover image. That keeps her away from screens and from the “next video” habit.

But a motion song is half sound and half movement. If I only play the audio, I cannot show her the movement. Before I teach her, I need to watch someone do it once or twice. I used to search for the video on my phone in the middle of the living room, with a child pulling my sleeve.

So the need was small and specific: let a parent watch the dance, without giving the child a video player.

The Proof: A Small Hand Icon on the Song

Every song that has a dance video now shows a small 🖐️ icon on its row. Songs without a video show nothing.

  1. I tap the hand.
  2. The app asks for a parent password. It asks every time, the same screen the video tab already uses.
  3. A full-screen player opens with the dance. I close it and the song list is still where I left it.

Now there are 35 dance videos, about 410 MB in total, each at 720p. The icon appears in seven places: the POP and KPOP tabs, the Tulip tab, the family-songs tab, the My tab, the Mother Goose tab, and the English tab. It is the same code in all seven.

This is the first message I sent about it, translated from Korean and shortened. I included a long list of motion songs in English and Korean after it:

💬 Prompt that worked “I’m thinking about what to do with songs that have dance motions. I want to attach the dance video to the song, so a parent can enter a password, watch it and teach her. Should I mark songs that have a video with a small hand icon, and let the parent tap it and enter the password? Or should I only show the hand and put the videos in the video tab? The app is image-only by default, and I’m not sure whether it’s right to let a parent play video inside the song list.”

I did not ask for code. I asked for a decision, and I got two options with trade-offs. I picked the hand icon with a shared dance/ folder.

The Story: Why Not Just Use the Video Tab?

The video tab was the other choice, and I think it is a fair one. I decided against it for three reasons.

  • The song and the dance belong together. If the dance is in another tab, I have to remember a name and search for it. With the icon, the dance is where I already am.
  • The child sees only pictures. The video does not play unless a parent types the password. A three-year-old can tap the hand, but she cannot get past the password screen.
  • One folder is simpler. A video tab would need its own list, its own thumbnails, and its own idea of which video belongs to which song.

The work was not only code. About half of it was cleaning up videos:

  • I first attached 43 videos. Eight of them turned out to have no real dance in them. They were just the song with some animation. I deleted those, and I also removed one whole song that had been added only for its video.
  • Most of the rest started with a channel intro, a logo, or a title card. A parent should not wait 8 seconds for a logo while a child waits for the song. I trimmed the first seconds off 23 videos.
  • Two bugs came with the new tabs. I’ll describe the one that mattered in the next section.

I have not trimmed the ending cards yet. Some videos still end with a few seconds of “subscribe” screen. It is harmless, so it stays on my list.

The How: A Folder, an Index, and an Observer

The whole feature is one folder, one JSON file, two server routes and about 150 lines of browser code. There is no database.

1. The folder and the index. Videos live in media/dance/, one file per song, named with a short ASCII id (teddy.mp4, wheels.mp4). A file index.json lists them:

[{ "id": "teddy", "title": "Teddy Bear", "aliases": ["teddybear", "teddybearteddybear"], "file": "teddy.mp4" }]

To add a new dance, I drop a video in the folder and add one line. No code change.

2. Two server routes. GET /api/dance/list returns the index, but only entries whose file exists. GET /api/dance/file/:name streams the video with HTTP Range support, and accepts only names that match /^[a-z0-9_-]+\.mp4$/i. That is the whole path-safety check.

3. Matching songs to videos by name. Song titles in my library are messy: 03 Teddy Bear (Live).mp3, Hokey Pokey - Kids. I wrote a small function that makes a title comparable:

  • lowercase it
  • remove leading numbers, anything in parentheses, and .mp3
  • keep only a-z, 0-9 and Korean letters
  • drop a leading “the”

The result is compared with each video’s aliases. If a title contains " - “, I also try the part before and after it. In a quick test over every title in the app, 62 songs matched a video.

4. Putting the icon everywhere without touching seven tabs. Each tab builds its list in its own way. Instead of editing each one, I watch for new rows with a MutationObserver. A short table says which container to watch, what a row looks like, and where the title is:

const DANCE_TARGETS = [
  ['pop-list',  '.pop-row', '.pop-title'],
  ['kpop-list', '.pop-row', '.pop-title'],
  ['tulip-list', '.tulip-song-row:not(.missing)', '.tulip-song-title'],
  // ... four more
];

When a row appears, the observer reads its title, looks for a match, and adds the button. A new tab needs one more line in this table.

5. The password. The hand button does not play anything. A click handler at the document level catches it first and opens the same password screen that the video tab uses. The right password (0708 or 1231) opens a full-screen <video>. Closing it locks again.

One honest limit: this password check is in the browser only. The server does not check it for the dance routes. I did it the same way as my video tab. This is a family app on a private domain, and the password is there to keep a toddler out, not to stop an adult. I would not use this design for anything sensitive.

6. Preparing the videos. Each video is converted once to 720p H.264, so it plays on any phone and does not buffer much on a home connection. To find an intro, I ask ffmpeg for scene changes and look at the biggest jump near the start:

ffmpeg -i in.mp4 -vf "select='gt(scene,0.12)',metadata=print:key=lavfi.scene_score" -f null -

Then I cut at that time and check the first frame by eye. Two videos needed a manual time because the scene score pointed to the wrong cut.

🗂 Claude.md Rule A detached new Audio() does not send media events up to document. To stop two songs from playing at once, add a play listener to each player and pause the others. When a new tab gets its own player, add it to the list.

That rule comes from the other bug. After I added the POP and KPOP tabs, two songs sometimes played together. The old “pause the others” code listened on the whole page, but the new players were not attached to the page, so it never heard them. The fix is a short loop at the end of the script that adds a play listener to every player, and it now includes the dance video too.