def process(self):
     try:
         currentFile=MrcFile.MrcFile('', True, False)
         if self.query.fileid:
             currentFile=MrcFile.getFromFileCache(self.query.fileid)
         if not currentFile.path:
             MrcLogger.error('failed to get file from cache with file id '+self.query.fileid)
             self.error='failed to get file from cache with file id '+self.query.fileid
         if currentFile.ismusicfile:
             MrcPlayer.instance().playFile(currentFile)
         else:
             self.reply.error='not a music file: '+currentFile.path
     except Exception as e:
         self.reply.error=e.__str__()
    def process(self):
        try:
            currentFile = MrcFile.MrcFile("", True, False)

            if self.query.fileid:
                currentFile = MrcFile.getFromFileCache(self.query.fileid)
            if not currentFile.path:
                MrcLogger.error("failed to get file from cache with file id " + self.query.fileid)
                self.reply.error = "failed to get file from cache with file id " + self.query.fileid
                return
            if not currentFile.isdir:
                self.reply.error = "not a music directory: " + currentFile.path
                return

            self.gatherMusicFiles(currentFile)

            if not self.files:
                self.reply.error = "no music file in: " + currentFile.path
                return

            MrcPlayer.instance().playFiles(self.files)
        except Exception as e:
            self.reply.error = e.__str__()
 def processByFileId(self):
     try:
         pathToBrowse=MrcSettings.BASE_MUSIC_PATH
         if self.query.fileid:
             self.reply.currentFolder=MrcFile.getFromFileCache(self.query.fileid) 
             pathToBrowse+=self.reply.currentFolder.path
         if not pathToBrowse:
             MrcLogger.error('failed to get file from cache with file id '+self.query.fileid)
             self.error='failed to get file from cache with file id '+self.query.fileid
         i=0
         for f in os.listdir(pathToBrowse):
             i+=1
             fpath=pathToBrowse+MrcSettings.OS_SEPARATOR+f
             fpath=fpath[len(MrcSettings.BASE_MUSIC_PATH):]
             if fpath.startswith(MrcSettings.OS_SEPARATOR):
                 fpath=fpath[len(MrcSettings.OS_SEPARATOR):]
             if os.path.isdir(pathToBrowse+MrcSettings.OS_SEPARATOR+f):
                 mf=MrcFile.MrcFile(fpath, True, False)
                 mf.setFileId(self.query.fileid, i)
                 mf.getDisplayName()
                 self.reply.files.append(mf)
                 MrcFile.addToFileCache(mf)
             else:
                 ismusicfile=False
                 for ext in MrcSettings.MUSIC_FILE_EXTENSIONS:
                     if f.lower().endswith(ext):
                         ismusicfile=True
                         break
                 if ismusicfile:
                     mf=MrcFile.MrcFile(fpath, False, True)
                     mf.setFileId(self.query.fileid, i)
                     mf.getDisplayName()
                     self.reply.files.append(mf)
                     MrcFile.addToFileCache(mf)
         self.reply.files=sorted(self.reply.files, key=lambda mf:mf.getSortingName())
     except Exception as e:
         self.reply.error=e.__str__()