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>
|
</main>
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
|
<script src="src/data/gameDataManager.js"></script>
|
||||||
<script src="src/utils/desktop-file-manager.js"></script>
|
<script src="src/utils/desktop-file-manager.js"></script>
|
||||||
<script src="src/features/media/videoLibrary.js"></script>
|
<script src="src/features/media/videoLibrary.js"></script>
|
||||||
<script src="src/features/media/pornCinema.js"></script>
|
<script src="src/features/media/pornCinema.js"></script>
|
||||||
|
|
@ -200,6 +201,28 @@
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
console.log('🎬 Initializing Porn Cinema...');
|
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
|
// Initialize the cinema
|
||||||
window.pornCinema = new PornCinema();
|
window.pornCinema = new PornCinema();
|
||||||
window.pornCinema.initialize();
|
window.pornCinema.initialize();
|
||||||
|
|
|
||||||
|
|
@ -60,26 +60,51 @@ class VideoLibrary {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get video files from the desktop file manager
|
// Get video files from all categories
|
||||||
const videoData = await window.desktopFileManager.getVideoList();
|
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');
|
console.log('No videos found');
|
||||||
this.displayEmptyLibrary('No videos found');
|
this.displayEmptyLibrary('No videos found. Upload some videos first!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process video data
|
// Process video data
|
||||||
this.videos = videoData.videos.map(video => ({
|
this.videos = allVideos.map(video => ({
|
||||||
name: video.name,
|
name: video.title || video.name || 'Unknown Video',
|
||||||
path: video.path,
|
path: video.path || video.filePath,
|
||||||
size: video.size || 0,
|
size: video.size || 0,
|
||||||
duration: video.duration || 0,
|
duration: video.duration || 0,
|
||||||
thumbnail: video.thumbnail || null,
|
thumbnail: video.thumbnail || null,
|
||||||
resolution: video.resolution || 'Unknown',
|
resolution: video.resolution || 'Unknown',
|
||||||
format: video.format || 'mp4',
|
format: video.format || this.getFormatFromPath(video.path || video.filePath),
|
||||||
bitrate: video.bitrate || 0,
|
bitrate: video.bitrate || 0,
|
||||||
dateAdded: video.dateAdded || new Date().toISOString(),
|
dateAdded: video.dateAdded || new Date().toISOString(),
|
||||||
|
category: video.category || 'unknown',
|
||||||
qualities: this.detectVideoQualities(video)
|
qualities: this.detectVideoQualities(video)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -352,10 +377,22 @@ class VideoLibrary {
|
||||||
displayEmptyLibrary(message) {
|
displayEmptyLibrary(message) {
|
||||||
this.libraryContent.innerHTML = `
|
this.libraryContent.innerHTML = `
|
||||||
<div class="library-loading">
|
<div class="library-loading">
|
||||||
<p>${message}</p>
|
<h3>📁 ${message}</h3>
|
||||||
<button class="btn btn-secondary" onclick="window.location.href='index.html'">
|
<p>To add videos to your library:</p>
|
||||||
📂 Manage Videos
|
<ol style="text-align: left; max-width: 400px; margin: 20px auto;">
|
||||||
</button>
|
<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>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
@ -383,6 +420,12 @@ class VideoLibrary {
|
||||||
return `${(bytes / Math.pow(1024, i)).toFixed(1)} ${sizes[i]}`;
|
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
|
// Public methods for external access
|
||||||
getSelectedVideo() {
|
getSelectedVideo() {
|
||||||
return this.selectedVideo;
|
return this.selectedVideo;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue