Loading...

gmote-users@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: folder shuffle Corentin Haidon Sun Feb 19 09:00:36 2012

Due to the source code of gmote (on server side), the search of songs
to be shuffled is limited to the current folder (the folder of the
file you have choosen).
So as to correct it, it is needed to edit gmote server application
(written in java) and compile a new version of gmote !

The file to edit is runMusic.java.
I can't give you a version working with search in sub folders because
i can't correct it right.
I wrote this part of code but i'm not really sure it works, i don't
know Java very well, in a few months i'll be able to give you
something working.

All is needed is to add recursively files from the current folder and
all the sub folders.
This is a try, if someone can compile it and test it/correct it !

"private void runMusic(String fileName, FileType fileType) throws
UnsupportedCommandException {
    Playlist playList;
    // Special handling for playlists since there is a bug in jvlc
related to
    // playlists.
    playList = new Playlist(jvlc);

    int idOfOriginal = -1;
    try {

      if (fileType == FileType.PLAYLIST) {
        playList.add(fileName, "Playlist");
        playList.next();
      } else {
        // Add all of the files of the directory in the playlist.
        File originalFile = new File(fileName);

        File[] allFilesInDirectory =
addFilesInFolderRec(originalFile.getParentFile(),allFilesInDirectory);

        if
(DefaultSettings.instance().getSetting(DefaultSettingsEnum.SHUFFLE_SONGS)
            .equalsIgnoreCase("true")) {
          Collections.shuffle(Arrays.asList(allFilesInDirectory));
        }

        for (File file : allFilesInDirectory) {
          String name = file.getName();
          FileType type =
SupportedFiletypeSettings.fileNameToFileType(name);

          if (type == FileType.MUSIC) {

            int id = playList.add(file.getAbsolutePath(),
file.getName());
            if (originalFile.equals(file)) {
              idOfOriginal = id;
            }
          }
        }
      }
    } catch (VLCException e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    }
    commandHandler = VlcPlaylistCommandHandler.instance(playList,
idOfOriginal, jvlc);
    commandHandler.setMediaIsOpen(true);
    controlPlayer(Command.PLAY);
    try {
      for (int i = 0; i < MAX_DELAY_ATTEMPTS && idOfOriginal != -1
          && (playList.getCurrentIndex() != idOfOriginal); i++) {
        sleep(100);
      }
    } catch (VLCException e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      throw new UnsupportedCommandException(e.getMessage());
    }

    // Wait until the song starts playing.
    sleep(100);
    try {
      long startTime = new Date().getTime();
      while (!playList.isRunning() && new Date().getTime() - startTime
< VIDEO_DELAY_TIMEOUT) {
        sleep(100);
      }
    } catch (VLCException e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
    }


    MediaInfoUpdater.instance().sendMediaUpdate(getNewMediaInfo());
    MediaInfoUpdater.instance().setPlayerToPoll(this);

  }

private File[] addFilesInFolderRec(File folder, File[] array) throws
UnsupportedCommandException {
        File[] currentFiles;
        File[] temporaryArray;
        for (File file : array) {
                        if(file.isDirectory())
                        {
                                currentFiles = file.listFiles();
                                temporaryArray = new 
File[currentFiles.length+array.length];
                                
System.arrayCopy(array,0,temporaryArray,0,array.length);
                                
System.arrayCopy(currentFiles,0,temporaryArray,array.length
+1,currentFiles.length);
                                array = temporaryArray;
                                array = addMusicInFolder(file.getName(),array);
                        }
                }

        return array;
}"

On 18 fév, 18:55, Quiltface <[EMAIL PROTECTED]> wrote:
> all i see when i right click the gmote server and choose setting is
> change password
> change media path
> dont shuffle songs
>
> does anyone else have the same problem as me?

-- 
You received this message because you are subscribed to the Google Groups 
"gmote users" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/gmote-users?hl=en.