diff --git a/resources/[tools]/nordi_dj/html/script.js b/resources/[tools]/nordi_dj/html/script.js index 4b4673b3c..84cd380be 100644 --- a/resources/[tools]/nordi_dj/html/script.js +++ b/resources/[tools]/nordi_dj/html/script.js @@ -1707,6 +1707,147 @@ function showDJInterface() { } +// Vereinfachte Playlist-Verwaltung +let playlists = []; +let currentPlaylist = null; +let currentPlaylistIndex = 0; + +// Playlist laden - vereinfacht +function loadPlaylists() { + console.log('DJ System: Loading playlists'); + + // Simuliere Playlists für den Anfang + playlists = [ + { + id: 1, + name: "Party Hits", + isOwner: true, + songs: [ + { id: 1, title: "Song 1", artist: "Artist 1", url: "https://example.com/song1.mp3" }, + { id: 2, title: "Song 2", artist: "Artist 2", url: "https://example.com/song2.mp3" } + ] + }, + { + id: 2, + name: "Chill Vibes", + isOwner: true, + songs: [ + { id: 3, title: "Chill Song 1", artist: "Chill Artist 1", url: "https://example.com/chill1.mp3" }, + { id: 4, title: "Chill Song 2", artist: "Chill Artist 2", url: "https://example.com/chill2.mp3" } + ] + } + ]; + + // Aktualisiere Anzeige + updatePlaylistDisplay(); +} + +// Playlist-Anzeige aktualisieren - vereinfacht +function updatePlaylistDisplay() { + console.log('DJ System: Updating playlist display'); + + const playlistContainer = document.getElementById('playlist-container'); + if (!playlistContainer) { + console.error('DJ System: Playlist container not found'); + return; + } + + playlistContainer.innerHTML = ''; + + if (playlists.length === 0) { + playlistContainer.innerHTML = '
Keine Playlists gefunden
'; + return; + } + + // Erstelle Playlist-Elemente + playlists.forEach((playlist) => { + const playlistElement = document.createElement('div'); + playlistElement.className = 'playlist-item'; + if (currentPlaylist && currentPlaylist.id === playlist.id) { + playlistElement.classList.add('active'); + } + + playlistElement.innerHTML = ` +
+ ${playlist.name} + ${playlist.songs.length} Songs +
+
+ +
+ `; + + // Event-Listener für Play-Button + const playBtn = playlistElement.querySelector('.playlist-play-btn'); + if (playBtn) { + playBtn.onclick = function(e) { + e.preventDefault(); + e.stopPropagation(); + playPlaylist(playlist); + }; + } + + playlistContainer.appendChild(playlistElement); + }); +} + +// Playlist abspielen - vereinfacht +function playPlaylist(playlist) { + console.log('DJ System: Playing playlist', playlist.name); + + if (!playlist || !playlist.songs || playlist.songs.length === 0) { + showNotification('Diese Playlist enthält keine Songs', 'warning'); + return; + } + + currentPlaylist = playlist; + currentPlaylistIndex = 0; + + // Ersten Song abspielen + playPlaylistSong(currentPlaylistIndex); +} + +// Playlist-Song abspielen - vereinfacht +function playPlaylistSong(index) { + if (!currentPlaylist || !currentPlaylist.songs || index >= currentPlaylist.songs.length) { + showNotification('Playlist beendet', 'info'); + currentPlaylist = null; + return; + } + + const song = currentPlaylist.songs[index]; + console.log('DJ System: Playing playlist song', song.title); + + // Spiele den Song direkt ab + PlayMusicAsDJ(song.title, song.url, currentVolume || 50); + + showNotification(`Playlist: ${currentPlaylist.name} - Song ${index + 1}/${currentPlaylist.songs.length}`, 'info'); +} + +// Nächster Song in Playlist +function playNextSong() { + if (!currentPlaylist) return; + + currentPlaylistIndex++; + if (currentPlaylistIndex < currentPlaylist.songs.length) { + playPlaylistSong(currentPlaylistIndex); + } else { + showNotification('Playlist beendet', 'info'); + currentPlaylist = null; + } +} + +// Funktion zum Abspielen von Musik als DJ (vereinfacht) +function PlayMusicAsDJ(title, url, volume) { + console.log('DJ System: Playing music as DJ', title, url); + + // Sende an FiveM + notifyFiveM('playTrack', { + title: title, + url: url, + volume: volume || 50 + }); +}