Fix Porn Cinema desktop file manager integration
- Initialize DesktopFileManager properly in porn-cinema.html - Add minimal data manager for standalone cinema operation - Update VideoLibrary to use correct desktop file manager API - Scan all video directories (background, tasks, rewards, punishments) - Add fallback to localStorage for stored videos - Improve empty library display with helpful instructions - Add gameDataManager dependency for data operations - Better error handling and user guidance Fixes: Desktop file manager now properly initialized Video library loads from all categories Graceful fallback when videos not found Clear instructions for adding videos
This commit is contained in:
parent
c524f3bc46
commit
c65a58bae9
|
|
@ -191,6 +191,7 @@
|
|||
</main>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="src/data/gameDataManager.js"></script>
|
||||
<script src="src/utils/desktop-file-manager.js"></script>
|
||||
<script src="src/features/media/videoLibrary.js"></script>
|
||||
<script src="src/features/media/pornCinema.js"></script>
|
||||
|
|
@ -200,6 +201,28 @@
|
|||
document.addEventListener('DOMContentLoaded', function() {
|
||||
console.log('🎬 Initializing Porn Cinema...');
|
||||
|
||||
// Initialize desktop file manager if in Electron environment
|
||||
if (window.electronAPI && typeof DesktopFileManager !== 'undefined') {
|
||||
// Create a minimal data manager for the cinema (since we don't have the full game instance)
|
||||
const minimalDataManager = {
|
||||
get: (key) => {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(key));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
set: (key, value) => {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
}
|
||||
};
|
||||
|
||||
window.desktopFileManager = new DesktopFileManager(minimalDataManager);
|
||||
console.log('🖥️ Desktop File Manager initialized for porn cinema');
|
||||
} else if (!window.electronAPI) {
|
||||
console.warn('⚠️ Running in browser mode - video management limited');
|
||||
}
|
||||
|
||||
// Initialize the cinema
|
||||
window.pornCinema = new PornCinema();
|
||||
window.pornCinema.initialize();
|
||||
|
|
|
|||
|
|
@ -60,26 +60,51 @@ class VideoLibrary {
|
|||
return;
|
||||
}
|
||||
|
||||
// Get video files from the desktop file manager
|
||||
const videoData = await window.desktopFileManager.getVideoList();
|
||||
// Get video files from all categories
|
||||
let allVideos = [];
|
||||
|
||||
if (!videoData || !videoData.videos) {
|
||||
try {
|
||||
const backgroundVideos = await window.desktopFileManager.scanDirectoryForVideos('background');
|
||||
const taskVideos = await window.desktopFileManager.scanDirectoryForVideos('tasks');
|
||||
const rewardVideos = await window.desktopFileManager.scanDirectoryForVideos('rewards');
|
||||
const punishmentVideos = await window.desktopFileManager.scanDirectoryForVideos('punishments');
|
||||
|
||||
allVideos = [
|
||||
...backgroundVideos,
|
||||
...taskVideos,
|
||||
...rewardVideos,
|
||||
...punishmentVideos
|
||||
];
|
||||
|
||||
console.log(`📁 Found ${allVideos.length} videos total`);
|
||||
} catch (error) {
|
||||
console.error('Error scanning video directories:', error);
|
||||
|
||||
// Fallback to localStorage
|
||||
const storedVideos = JSON.parse(localStorage.getItem('videoFiles') || '{}');
|
||||
console.log('📁 Falling back to stored videos');
|
||||
|
||||
allVideos = Object.values(storedVideos).flat();
|
||||
}
|
||||
|
||||
if (!allVideos || allVideos.length === 0) {
|
||||
console.log('No videos found');
|
||||
this.displayEmptyLibrary('No videos found');
|
||||
this.displayEmptyLibrary('No videos found. Upload some videos first!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Process video data
|
||||
this.videos = videoData.videos.map(video => ({
|
||||
name: video.name,
|
||||
path: video.path,
|
||||
this.videos = allVideos.map(video => ({
|
||||
name: video.title || video.name || 'Unknown Video',
|
||||
path: video.path || video.filePath,
|
||||
size: video.size || 0,
|
||||
duration: video.duration || 0,
|
||||
thumbnail: video.thumbnail || null,
|
||||
resolution: video.resolution || 'Unknown',
|
||||
format: video.format || 'mp4',
|
||||
format: video.format || this.getFormatFromPath(video.path || video.filePath),
|
||||
bitrate: video.bitrate || 0,
|
||||
dateAdded: video.dateAdded || new Date().toISOString(),
|
||||
category: video.category || 'unknown',
|
||||
qualities: this.detectVideoQualities(video)
|
||||
}));
|
||||
|
||||
|
|
@ -352,10 +377,22 @@ class VideoLibrary {
|
|||
displayEmptyLibrary(message) {
|
||||
this.libraryContent.innerHTML = `
|
||||
<div class="library-loading">
|
||||
<p>${message}</p>
|
||||
<button class="btn btn-secondary" onclick="window.location.href='index.html'">
|
||||
📂 Manage Videos
|
||||
</button>
|
||||
<h3>📁 ${message}</h3>
|
||||
<p>To add videos to your library:</p>
|
||||
<ol style="text-align: left; max-width: 400px; margin: 20px auto;">
|
||||
<li>Return to the home screen</li>
|
||||
<li>Click "🎬 Manage Video"</li>
|
||||
<li>Upload videos to your library</li>
|
||||
<li>Return to Porn Cinema to enjoy them!</li>
|
||||
</ol>
|
||||
<div style="margin-top: 20px;">
|
||||
<button class="btn btn-primary" onclick="window.location.href='index.html'">
|
||||
🏠 Return to Home
|
||||
</button>
|
||||
<button class="btn btn-secondary" onclick="window.location.reload()">
|
||||
🔄 Refresh Library
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
|
@ -383,6 +420,12 @@ class VideoLibrary {
|
|||
return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${sizes[i]}`;
|
||||
}
|
||||
|
||||
getFormatFromPath(path) {
|
||||
if (!path) return 'mp4';
|
||||
const extension = path.toLowerCase().split('.').pop();
|
||||
return extension || 'mp4';
|
||||
}
|
||||
|
||||
// Public methods for external access
|
||||
getSelectedVideo() {
|
||||
return this.selectedVideo;
|
||||
|
|
|
|||
Loading…
Reference in New Issue