Skip to content

Add video playback support to Bluesky thread viewer#124

Merged
simonw merged 1 commit intomainfrom
claude/bluesky-video-playback-01Qsy2yjgYp3jE2dSC1AFacr
Nov 28, 2025
Merged

Add video playback support to Bluesky thread viewer#124
simonw merged 1 commit intomainfrom
claude/bluesky-video-playback-01Qsy2yjgYp3jE2dSC1AFacr

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Nov 28, 2025

  • Display video thumbnails with play button overlay for posts containing videos
  • Click thumbnail to open video in modal with full playback controls
  • Use HLS.js for cross-browser HLS video streaming support
  • Support for video embeds both standalone and within recordWithMedia embeds

Use playwright Python to access https://tools.simonwillison.net/bluesky-thread?url=https%3A%2F%2Fbsky.app%2Fprofile%2Fsimonwillison.net%2Fpost%2F3m6pmebfass24&view=thread&hideReplies=1

Note how the first post mentions a video but doesn’t display one

Fetch the JSON yourself to see how videos are shown. Modify the bluesky-thread.html code so that if a thumbnail is available it displays that and when you click it you get a modal playing the video using a

Test it by running a server with python -m http.server and using playwright Python

- Display video thumbnails with play button overlay for posts containing videos
- Click thumbnail to open video in modal with full playback controls
- Use HLS.js for cross-browser HLS video streaming support
- Support for video embeds both standalone and within recordWithMedia embeds
@claude
Copy link
Contributor

claude bot commented Nov 28, 2025

Claude finished @simonw's task —— View job


Code Review for Video Playback Support

Todo List:

  • Check for CLAUDE.md repository guidelines
  • Read and analyze the modified bluesky-thread.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage
  • Provide comprehensive feedback

Code Quality & Best Practices ✅

Strong Points:

  • Clean separation of concerns: Video functionality is well-modularized with dedicated functions (renderVideo, openVideoModal, closeVideoModal)
  • Consistent naming: Video-related CSS classes follow existing patterns (video-container, video-play-icon)
  • Proper resource cleanup: HLS instance is properly destroyed in closeVideoModal() (lines 519-521)
  • Progressive enhancement: Falls back gracefully for browsers with native HLS support (Safari, lines 544-550)

Suggestions for improvement:

  • Consider extracting video modal logic into a separate class for better organization
  • The renderEmbed() function is getting quite large - consider breaking into smaller functions

Potential Issues 🔍

Minor Issues Found:

  1. Memory leak potential: If closeVideoModal() is called multiple times rapidly, hlsInstance.destroy() could throw if already destroyed
  2. Missing error handling: No error handling for HLS loading failures or unsupported video formats
  3. Accessibility: Video modal lacks keyboard navigation (Esc key support)
  4. No fallback message: Users on unsupported browsers get no feedback if video can't play

Suggested fixes:

// Add null check before destroying HLS
if (hlsInstance) {
  try {
    hlsInstance.destroy();
  } catch (e) {
    console.warn('Error destroying HLS instance:', e);
  }
  hlsInstance = null;
}

// Add keyboard support for video modal
videoModal.addEventListener('keydown', (e) => {
  if (e.key === 'Escape') closeVideoModal();
});

Performance Considerations ⚡

Good practices:

  • HLS.js loaded from CDN with proper version pinning
  • Video elements properly reset on modal close
  • Event listeners use delegation where appropriate

Potential optimizations:

  • Consider lazy-loading HLS.js only when first video is clicked
  • Video thumbnails could benefit from loading="lazy" attribute for below-fold content

Security Assessment 🔒

Security posture is good:

  • Uses established CDN (jsdelivr) for HLS.js dependency
  • Video sources come from Bluesky's trusted API endpoints
  • No direct user input handling for video URLs
  • Modal implementation doesn't introduce XSS vectors

No security concerns identified.

Test Coverage 🧪

Current state: No automated tests detected for the video functionality.

Recommended test scenarios:

  • Video modal opens/closes correctly
  • HLS.js integration works with sample URLs
  • Fallback behavior for unsupported browsers
  • Keyboard accessibility (Esc key)
  • Resource cleanup on modal close

Architecture Review 🏗️

The video implementation integrates well with the existing codebase:

  • Follows established patterns for image modal functionality
  • Properly handles both standalone and recordWithMedia embed types (lines 712-730)
  • CSS follows existing design system and responsive patterns

Overall Assessment: Strong implementation with minor refinements needed.

@cloudflare-workers-and-pages
Copy link

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 280824c
Status: ✅  Deploy successful!
Preview URL: https://8cc8c719.tools-b1q.pages.dev
Branch Preview URL: https://claude-bluesky-video-playbac.tools-b1q.pages.dev

View logs

@simonw simonw merged commit dc6149e into main Nov 28, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants