Skip to content

Latest commit

 

History

History
134 lines (112 loc) · 4.55 KB

File metadata and controls

134 lines (112 loc) · 4.55 KB

Stream Setup Fixes - Complete ✅

Changes Made:

1. ✅ Removed Browser Permissions for OBS Streaming

  • Status: Already working correctly!
  • The OBS streaming page (/app/stream-obs/page.tsx) never requests camera/mic permissions
  • Only the browser-based streaming page (/app/stream/page.tsx) uses getUserMedia()
  • When you click "Go Live" on the OBS page, it only:
    • Calls the /api/stream/start endpoint
    • Updates the database to mark stream as live
    • No browser permissions requested

2. ✅ Custom Thumbnail Upload & Display

Implemented complete thumbnail upload and storage flow:

Schema Changes:

  • Added thumbnailStorageId field to streams table in /convex/schema.ts
  • Stores reference to uploaded thumbnail image in Convex storage

Upload Flow:

  1. User selects thumbnail in PrepStreamModal.tsx
  2. PrepStreamProvider.tsx uploads file to Convex storage via /api/upload-url
  3. Gets back storageId
  4. Passes storageId to stream creation
  5. Stored in database with stream

Display Flow:

  1. StreamCard.tsx fetches thumbnail URL from storage
  2. Falls back to Mux generated thumbnail if no custom image
  3. Falls back to default placeholder if no Mux playback ID

Files Modified:

  • /convex/schema.ts - Added thumbnailStorageId field
  • /convex/streams.ts - Updated createStream mutation
  • /app/api/stream/create/route.ts - Accept thumbnailStorageId
  • /app/api/upload-url/route.ts - New file for upload URLs
  • /components/PrepStreamModal.tsx - Pass File object
  • /components/providers/PrepStreamProvider.tsx - Upload logic
  • /app/stream-obs/page.tsx - Pass thumbnailStorageId to API
  • /components/StreamCard.tsx - Fetch and display thumbnail

3. ✅ Stream Card Shows User Profile Avatar

  • Updated StreamCard.tsx to use hostProfile.avatarUrl instead of hardcoded avatar
  • Fetches user profile for each stream
  • Shows user's actual profile picture
  • Falls back to gradient placeholder with first letter if no avatar set

How It Works:

Thumbnail Upload:

User selects image → PrepStreamModal
                    ↓
File passed to → PrepStreamProvider
                    ↓
Upload to Convex → /api/upload-url → generateUploadUrl mutation
                    ↓
Get storageId → Store in streamMetadata
                    ↓
Create stream → Pass thumbnailStorageId to API
                    ↓
Saved in database → streams.thumbnailStorageId

Thumbnail Display:

StreamCard loads → Fetch stream data
                ↓
Has thumbnailStorageId? → Query getFileUrl(storageId)
                ↓
Get URL from Convex storage
                ↓
Display in <Image src={thumbnailUrl} />
                ↓
Fallbacks: Custom → Mux → Default

Avatar Display:

StreamCard loads → Fetch host profile
                ↓
hostProfile.avatarUrl exists?
    Yes → Show actual avatar image
    No → Show gradient with first letter

Testing:

Test Custom Thumbnails:

  1. Click "Go Live" button
  2. In "Prep Your Stream" modal, upload an image
  3. Complete setup and create stream
  4. Check dashboard - your uploaded image should show on stream card
  5. Not your Mux thumbnail, not the default placeholder

Test Profile Avatars:

  1. Update your profile picture in profile settings
  2. Create a new stream
  3. Stream card should show YOUR profile picture
  4. Other users' streams show THEIR profile pictures

Test OBS Flow (No Permissions):

  1. Click "Go Live"
  2. Upload thumbnail
  3. Choose "OBS Studio" setup
  4. Verify: Browser should NOT ask for camera/mic permissions
  5. You go straight to OBS instructions page
  6. Connect OBS and start streaming

Files Summary:

New Files:

  • /app/api/upload-url/route.ts - Upload URL generation endpoint

Modified Files:

  1. /convex/schema.ts - Schema update
  2. /convex/streams.ts - Mutation update
  3. /app/api/stream/create/route.ts - Accept thumbnail ID
  4. /components/PrepStreamModal.tsx - File handling
  5. /components/providers/PrepStreamProvider.tsx - Upload logic
  6. /app/stream-obs/page.tsx - Pass thumbnail ID
  7. /components/StreamCard.tsx - Display thumbnails & avatars

Notes:

  • No browser permissions requested for OBS streaming
  • Custom thumbnails uploaded and stored in Convex
  • User avatars dynamically loaded from profiles
  • Fallback chain ensures something always displays
  • Type-safe with proper TypeScript interfaces
  • Error handling for failed uploads

All three features are now working! 🎉