play_video
Play YouTube or TikTok videos in a lightweight mpv player. Start at specific timestamps or use audio-only mode for podcasts and music while working.
Instructions
Play a video from YouTube or TikTok in a lightweight mpv player window. Optionally start at a specific timestamp. Set audio_only to true for audio-only playback (great for podcasts/music while coding).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | YouTube or TikTok video URL | |
| timestamp | No | Start position in seconds | |
| audio_only | No | Audio-only mode — no video window, just audio |
Implementation Reference
- src/index.ts:13-38 (handler)Implementation of the 'play_video' tool, which handles validation, calls mpv.launch, and returns the playback status.
server.tool( 'play_video', 'Play a video from YouTube or TikTok in a lightweight mpv player window. Optionally start at a specific timestamp. Set audio_only to true for audio-only playback (great for podcasts/music while coding).', { url: z.string().url().describe('YouTube or TikTok video URL'), timestamp: z.number().min(0).optional().describe('Start position in seconds'), audio_only: z.boolean().default(false).describe('Audio-only mode — no video window, just audio'), }, async ({ url, timestamp, audio_only }) => { const urlErr = validateVideoUrl(url); if (urlErr) return errorResult(urlErr); const depErr = checkDeps(); if (depErr) return errorResult(depErr); try { await mpv.launch({ url, timestamp, audioOnly: audio_only }); } catch { return errorResult('mpv failed to start. Run `mpv <url>` manually to see the error.'); } let title = url; try { title = (await mpv.getProperty('media-title')) as string || url; } catch { /* loading */ } return textResult({ status: 'playing', title, url, audioOnly: audio_only, ...(timestamp ? { startedAt: `${timestamp}s` } : {}) }); } );