package com.deseteral.oudjo;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class OudjoApp extends Application {

    public static final String VERSION = "1.0.0";

    static Database database;
    static OudjoPlayer player;
    static WebService webService;

    @Override
    public void start(Stage primaryStage) throws Exception {

        Parent root = FXMLLoader.load(getClass().getResource("/control_panel_window.fxml"));
        primaryStage.setTitle("oudjo control panel");
        primaryStage.setScene(new Scene(root, 300, 175));
        primaryStage.show();

        // Stop the web service when window closes
        primaryStage.setOnCloseRequest(event -> {
            if (webService != null)
                webService.stopWebService();
        });
    }

    public static void initializeApp(String path) {

        database = new Database(path);

        player = new OudjoPlayer();

        webService = new WebService(4567);
        webService.initialize();

//        player.getPlaylist().add(database.getSongById(2));
//        player.getPlaylist().add(database.getSongById(4));
//        player.getPlaylist().add(database.getSongById(8));
//        player.getPlaylist().add(database.getSongById(16));
//        player.getPlaylist().add(database.getSongById(32));
//        player.getPlaylist().add(database.getSongById(64));
    }

    public static void main(String[] args) {
        launch(args);
    }

    public static Gson createGson() {
        return new GsonBuilder()
                .excludeFieldsWithoutExposeAnnotation()
                .setPrettyPrinting()
                .create();
    }
}

@@ -1152,26 +1152,24 @@
 ize();%0A%0A
-//
         
 player.g
@@ -1164,245 +1164,149 @@
     
-player.getPlaylist().add(database.getSongById(2));%0A//        player.getPlaylist().add(database.getSongById(4));%0A//        player.getPlaylist().add(database.getSongById(8));%0A//        player.getPlaylist().add(database.getSongById(16));%0A//
+// TODO This is for testing purposes only, remove this later%0A        for (int i = 0; i %3C database.getDataset().getSongs().size(); i++) %7B%0A    
     
@@ -1359,24 +1359,21 @@
 yId(
-32
+i
 ));%0A
-//
         
 play
@@ -1372,59 +1372,9 @@
     
-player.getPlaylist().add(database.getSongById(64));
+%7D
 %0A   

Add all songs to playlist (testing)