forked from Simnation/Main
Update script.js
This commit is contained in:
parent
ab48cbdd05
commit
875c8448e1
1 changed files with 141 additions and 0 deletions
|
@ -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 = '<div class="no-playlists">Keine Playlists gefunden</div>';
|
||||
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 = `
|
||||
<div class="playlist-header">
|
||||
<span class="playlist-name">${playlist.name}</span>
|
||||
<span class="playlist-count">${playlist.songs.length} Songs</span>
|
||||
</div>
|
||||
<div class="playlist-actions">
|
||||
<button class="playlist-play-btn" title="Play"><i class="fas fa-play"></i></button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 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
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue