ed
This commit is contained in:
		
							parent
							
								
									b0f9fbee65
								
							
						
					
					
						commit
						d6480dfebd
					
				
					 2 changed files with 104 additions and 36 deletions
				
			
		|  | @ -1284,9 +1284,9 @@ function stopResize() { | |||
| } | ||||
|  | ||||
| function closeDJInterface() { | ||||
|  | ||||
|     console.log('DJ System: Closing interface...'); | ||||
|      | ||||
|     // Entferne Event-Listener | ||||
|     // Entferne Event-Listener für Drag und Resize | ||||
|     document.removeEventListener('mousemove', handleDrag); | ||||
|     document.removeEventListener('mouseup', stopDrag); | ||||
|     document.removeEventListener('mousemove', handleResize); | ||||
|  | @ -1298,14 +1298,19 @@ function closeDJInterface() { | |||
|         djInterfaceElement.classList.add('hidden'); | ||||
|     } | ||||
|      | ||||
|     // Benachrichtige FiveM | ||||
|     // Wichtig: Benachrichtige FiveM BEVOR wir irgendwelche lokalen Variablen zurücksetzen | ||||
|     notifyFiveM('djInterfaceClosed', { | ||||
|         stopMusic: false // Wichtig: Teile FiveM mit, dass die Musik weiterlaufen soll | ||||
|         stopMusic: false // Musik weiterlaufen lassen | ||||
|     }); | ||||
|      | ||||
|     // Setze Drag & Resize Status zurück | ||||
|     isDragging = false; | ||||
|     isResizing = false; | ||||
|      | ||||
|     console.log('DJ System: Interface closed, music continues playing'); | ||||
| } | ||||
|  | ||||
|  | ||||
| function stopAllAudio() { | ||||
|     // Stoppe YouTube-Player | ||||
|     for (const deck of ['A', 'B']) { | ||||
|  | @ -1333,24 +1338,34 @@ function stopAllAudio() { | |||
| } | ||||
|  | ||||
| function showDJInterface() { | ||||
|     console.log('DJ System: Showing interface'); | ||||
|      | ||||
|     const djInterfaceElement = document.getElementById('dj-interface'); | ||||
|     if (djInterfaceElement) { | ||||
|         djInterfaceElement.classList.remove('hidden'); | ||||
|          | ||||
|         // Position weiter rechts und unten | ||||
|         if (!localStorage.getItem('djInterfacePosition')) { | ||||
|             interfacePosition = { | ||||
|                 x: (window.innerWidth - interfaceSize.width) / 2 + 200, // 200px weiter rechts | ||||
|                 y: (window.innerHeight - interfaceSize.height) / 2 + 150 // 150px weiter unten | ||||
|             }; | ||||
|         } | ||||
|          | ||||
|         // Wende gespeicherte Einstellungen an | ||||
|         applyInterfaceSettings(); | ||||
|     if (!djInterfaceElement) { | ||||
|         console.error('DJ System: Interface element not found!'); | ||||
|         notifyFiveM('error', {error: 'Interface element not found'}); | ||||
|         return; | ||||
|     } | ||||
|      | ||||
|     // Entferne hidden-Klasse | ||||
|     djInterfaceElement.classList.remove('hidden'); | ||||
|      | ||||
|     // Position weiter rechts und unten, falls keine gespeicherte Position | ||||
|     if (!localStorage.getItem('djInterfacePosition')) { | ||||
|         interfacePosition = { | ||||
|             x: (window.innerWidth - interfaceSize.width) / 2, | ||||
|             y: (window.innerHeight - interfaceSize.height) / 2 | ||||
|         }; | ||||
|     } | ||||
|      | ||||
|     // Wende gespeicherte Einstellungen an | ||||
|     applyInterfaceSettings(); | ||||
|      | ||||
|     console.log('DJ System: Interface shown'); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| // Aktualisiere den Message Handler | ||||
| window.addEventListener('message', function(event) { | ||||
|     const data = event.data; | ||||
|  | @ -1453,32 +1468,45 @@ function extractYouTubeVideoId(url) { | |||
|     return null; | ||||
| } | ||||
|  | ||||
| // Verbesserte notifyFiveM-Funktion mit Callback-Unterstützung | ||||
| // Verbesserte notifyFiveM-Funktion mit Fehlerbehandlung | ||||
| function notifyFiveM(event, data, callback) { | ||||
|     const callbackId = callback ? Date.now().toString() + Math.random().toString(36).substr(2, 5) : null; | ||||
|      | ||||
|     if (callback) { | ||||
|         window.callbacks = window.callbacks || {}; | ||||
|         window.callbacks[callbackId] = callback; | ||||
|     } | ||||
|      | ||||
|     fetch(`https://${GetParentResourceName()}/${event}`, { | ||||
|         method: 'POST', | ||||
|         headers: { | ||||
|             'Content-Type': 'application/json' | ||||
|         }, | ||||
|         body: JSON.stringify({ | ||||
|     try { | ||||
|         const callbackId = callback ? Date.now().toString() + Math.random().toString(36).substr(2, 5) : null; | ||||
|          | ||||
|         if (callback) { | ||||
|             window.callbacks = window.callbacks || {}; | ||||
|             window.callbacks[callbackId] = callback; | ||||
|         } | ||||
|          | ||||
|         const payload = { | ||||
|             ...data, | ||||
|             callbackId: callbackId | ||||
|         }) | ||||
|     }).catch(err => { | ||||
|         console.error('DJ System: Failed to notify FiveM:', err); | ||||
|         }; | ||||
|          | ||||
|         console.log(`DJ System: Sending ${event} to FiveM`, payload); | ||||
|          | ||||
|         fetch(`https://${GetParentResourceName()}/${event}`, { | ||||
|             method: 'POST', | ||||
|             headers: { | ||||
|                 'Content-Type': 'application/json' | ||||
|             }, | ||||
|             body: JSON.stringify(payload) | ||||
|         }).catch(err => { | ||||
|             console.error('DJ System: Failed to notify FiveM:', err); | ||||
|             if (callback) { | ||||
|                 delete window.callbacks[callbackId]; | ||||
|                 callback({success: false, error: 'Failed to communicate with FiveM'}); | ||||
|             } | ||||
|         }); | ||||
|     } catch (error) { | ||||
|         console.error('DJ System: Error in notifyFiveM:', error); | ||||
|         if (callback) { | ||||
|             delete window.callbacks[callbackId]; | ||||
|             callback({success: false, error: 'Internal error'}); | ||||
|         } | ||||
|     }); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| // Callback-Handler | ||||
| window.handleCallback = function(callbackId, data) { | ||||
|     if (window.callbacks && window.callbacks[callbackId]) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nordi98
						Nordi98