# Workflow: Play Music

## Trigger phrases
- "play music"
- "play [song name]"
- "open YouTube Music"
- "put on some music"

## Steps

1. Open YouTube Music in real Chrome with the search query:
   `open -a "Google Chrome" "https://music.youtube.com/search?q=<song name, URL encoded>"`
   (if no song specified, use `https://music.youtube.com`)

2. Wait ~2 seconds for the page to load.

3. Use mcp__desktop__Snapshot with use_vision=true to get the accessibility tree.
   Find the AXButton named "تشغيل" (Play) — it will have real screen coordinates in the element list.
   Example: `AXButton|تشغيل|(853,513)` — use those exact coords.

4. Click it with mcp__desktop__Click at those coordinates.

## Key lessons
- ALWAYS use mcp__desktop__Snapshot (use_vision=true) to get exact button coordinates from the accessibility tree — never guess or calculate from screenshot pixel positions.
- The desktop tool coordinates are in logical screen space (1470x956 on Ahmed's MacBook), NOT physical pixels.
- Screenshot pixel coords are NOT the same as desktop tool coords — don't convert, just use the Snapshot accessibility tree.
- Do NOT use osascript JavaScript injection unless "Allow JavaScript from Apple Events" is enabled in Chrome (View → Developer → Allow JavaScript from Apple Events).
- The `k` keyboard shortcut only works if a song is already loaded in the player — useless on the search results page.
