feat(clusters): add bookmark and rating features to video player
- Enable display of bookmarks and ratings in the player UI - Add handlers for bookmarking and unbookmarking actions - Implement rating functionality with corresponding event handler - Enhance user interaction by integrating these new controls - Improve state management related to video selection and player display
This commit is contained in:
parent
335f47549a
commit
7d8694b6f5
|
|
@ -0,0 +1,135 @@
|
||||||
|
# Local Player Auto-Close Issue Fix
|
||||||
|
|
||||||
|
## 🐛 Issue Description
|
||||||
|
The local video player launcher dialog was automatically closing itself after 2 seconds when launched from the cluster folder view, making it impossible to bookmark or rate videos that require external players.
|
||||||
|
|
||||||
|
## 🔍 Root Cause Analysis
|
||||||
|
|
||||||
|
### The Problem
|
||||||
|
The `LocalPlayerLauncher` component has auto-close logic that checks for interactive features:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const hasInteractiveFeatures = showBookmarks || showRatings;
|
||||||
|
if (!hasInteractiveFeatures) {
|
||||||
|
setTimeout(() => {
|
||||||
|
onClose();
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Why It Was Triggered
|
||||||
|
The cluster page was calling `UnifiedVideoPlayer` **without** the required props:
|
||||||
|
|
||||||
|
**Before (Broken)**:
|
||||||
|
```typescript
|
||||||
|
<UnifiedVideoPlayer
|
||||||
|
video={selectedVideo}
|
||||||
|
isOpen={isPlayerOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsPlayerOpen(false);
|
||||||
|
setSelectedVideo(null);
|
||||||
|
}}
|
||||||
|
// ❌ Missing showBookmarks, showRatings, and handlers
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|
||||||
|
**UnifiedVideoPlayer Defaults**:
|
||||||
|
```typescript
|
||||||
|
showBookmarks = false, // ❌ Defaults to false
|
||||||
|
showRatings = false, // ❌ Defaults to false
|
||||||
|
```
|
||||||
|
|
||||||
|
This caused `hasInteractiveFeatures` to be `false`, triggering the auto-close timer.
|
||||||
|
|
||||||
|
## ✅ Solution Applied
|
||||||
|
|
||||||
|
Updated the cluster page to properly pass bookmark and rating props:
|
||||||
|
|
||||||
|
**After (Fixed)**:
|
||||||
|
```typescript
|
||||||
|
<UnifiedVideoPlayer
|
||||||
|
video={selectedVideo}
|
||||||
|
isOpen={isPlayerOpen}
|
||||||
|
onClose={() => {
|
||||||
|
setIsPlayerOpen(false);
|
||||||
|
setSelectedVideo(null);
|
||||||
|
}}
|
||||||
|
showBookmarks={true} // ✅ Enable bookmarks
|
||||||
|
showRatings={true} // ✅ Enable ratings
|
||||||
|
onBookmark={handleBookmark} // ✅ Bookmark handler
|
||||||
|
onUnbookmark={handleUnbookmark} // ✅ Unbookmark handler
|
||||||
|
onRate={handleRate} // ✅ Rating handler
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🎯 How It Works Now
|
||||||
|
|
||||||
|
### Flow for External Player Videos:
|
||||||
|
1. User clicks video in cluster folder view
|
||||||
|
2. `UnifiedVideoPlayer` detects format requires external player
|
||||||
|
3. `LocalPlayerLauncher` is rendered with `showBookmarks={true}` and `showRatings={true}`
|
||||||
|
4. User launches external player
|
||||||
|
5. `hasInteractiveFeatures = true` → **No auto-close timer**
|
||||||
|
6. Dialog stays open for bookmarking and rating
|
||||||
|
7. User can bookmark/rate before manually closing
|
||||||
|
|
||||||
|
### Auto-Close Logic:
|
||||||
|
```typescript
|
||||||
|
const hasInteractiveFeatures = showBookmarks || showRatings;
|
||||||
|
// true || true = true ✅
|
||||||
|
|
||||||
|
if (!hasInteractiveFeatures) {
|
||||||
|
// This branch is NOT taken anymore ✅
|
||||||
|
setTimeout(() => {
|
||||||
|
onClose();
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📊 Comparison with Other Views
|
||||||
|
|
||||||
|
| View | showBookmarks | showRatings | Result |
|
||||||
|
|------|---------------|-------------|---------|
|
||||||
|
| **Cluster Page (Before)** | ❌ false | ❌ false | Auto-closes |
|
||||||
|
| **Cluster Page (After)** | ✅ true | ✅ true | Stays open |
|
||||||
|
| **Bookmarks Page** | ✅ true | ✅ true | Stays open |
|
||||||
|
| **Videos Page** | ✅ true | ✅ true | Stays open |
|
||||||
|
|
||||||
|
## 🧪 Expected Results
|
||||||
|
|
||||||
|
✅ Local player dialog stays open after launching external player
|
||||||
|
✅ Users can bookmark videos requiring external players
|
||||||
|
✅ Users can rate videos requiring external players
|
||||||
|
✅ Consistent behavior across all cluster views
|
||||||
|
✅ No regression in regular video playback
|
||||||
|
|
||||||
|
## 📁 Files Changed
|
||||||
|
|
||||||
|
**Modified**: `/src/app/clusters/[id]/page.tsx`
|
||||||
|
- **Lines Added**: 5 lines
|
||||||
|
- **Change**: Added showBookmarks, showRatings props and handlers to UnifiedVideoPlayer
|
||||||
|
|
||||||
|
## 🔄 Testing Checklist
|
||||||
|
|
||||||
|
- [ ] Open cluster page and navigate to folder with .ts or other external format videos
|
||||||
|
- [ ] Click on video that requires external player
|
||||||
|
- [ ] Verify local player dialog appears
|
||||||
|
- [ ] Click "Launch [Player]" button
|
||||||
|
- [ ] Verify dialog does NOT auto-close after 2 seconds
|
||||||
|
- [ ] Verify bookmark button is visible and functional
|
||||||
|
- [ ] Verify rating stars are visible and functional
|
||||||
|
- [ ] Verify can bookmark video successfully
|
||||||
|
- [ ] Verify can rate video successfully
|
||||||
|
- [ ] Verify can manually close dialog with X button
|
||||||
|
|
||||||
|
## 🎉 Resolution Status
|
||||||
|
|
||||||
|
**Status**: ✅ **FIXED - Ready for Testing**
|
||||||
|
**Risk Level**: Low (isolated change, follows existing patterns)
|
||||||
|
**Impact**: High (restores critical functionality)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Fix applied on 2025-10-12*
|
||||||
|
*Issue: Regression in auto-close behavior*
|
||||||
|
*Solution: Properly pass interactive props to video player*
|
||||||
|
|
@ -462,6 +462,11 @@ export default function ClusterPage({ params }: ClusterPageProps) {
|
||||||
setIsPlayerOpen(false);
|
setIsPlayerOpen(false);
|
||||||
setSelectedVideo(null);
|
setSelectedVideo(null);
|
||||||
}}
|
}}
|
||||||
|
showBookmarks={true}
|
||||||
|
showRatings={true}
|
||||||
|
onBookmark={handleBookmark}
|
||||||
|
onUnbookmark={handleUnbookmark}
|
||||||
|
onRate={handleRate}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue