SongHandler.java 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package model;
  2. import java.io.File;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import javazoom.jl.player.Player;
  6. import main.Window;
  7. import audio.Song;
  8. import audio.io.DirScanner;
  9. public class SongHandler {
  10. private List<Song> songs;
  11. private Song currentSong;
  12. private int currentIndex;
  13. private File dir;
  14. public SongHandler()
  15. {
  16. songs = new ArrayList<Song>();
  17. currentSong = null;
  18. currentIndex = 0;
  19. if(Window.ON_RASP)
  20. dir = new File(System.getProperty( "user.home" ) + "/ColorStrike/Songs");
  21. else
  22. dir = new File("Songs");
  23. songs = DirScanner.scanDirectories(dir);
  24. currentSong = songs.get(currentIndex);
  25. }
  26. public void next()
  27. {
  28. currentIndex++;
  29. currentIndex%=songs.size();
  30. currentSong = songs.get(currentIndex);
  31. updatePlayer();
  32. }
  33. public void previous()
  34. {
  35. currentIndex--;
  36. currentIndex%=songs.size();
  37. currentSong = songs.get(currentIndex);
  38. updatePlayer();
  39. }
  40. private void updatePlayer()
  41. {
  42. }
  43. }