def mediaLoad(self,file,play=False): ret = False; try: #print os.stat(file) #if isPosix: print " . Path Fix" self.mediaUnload(); # remove the old file isExist = os.path.exists(file) #attempt to fix the file path if on a case sensitive file system if not isExist and isPosix: # although MpGlobal.Player also does a path fix # we do need to check here just in case. newFilePath = UnixPathCorrect(file) if os.path.exists(newFilePath): file = newFilePath isExist = True debug( "Path Correction: \n%s"%file ) if not isPosix: path = toUTF16(file) else: path = file; if isExist: # TODO - File load error # python claims the file exists but sometimes # the load still fails, claiming the path does not exist. # by simply re encoding the file path and checking # if the file exists again solves the issue. strange. for i in range(5): path_utf16 = toUTF16(file); fex = PyBASS.utf16_fexists(path_utf16) if fex: ret = PyBASS.load(path_utf16,1); if i > 0: print "Loaded on %d-th attempt"%i PyBASS.setDSPBlock( self.DSP_SETTINGS ) #print self.DSP_SETTINGS break; else: print "for fell thru on load." raise IOError("Failed to load file"); else: print "file not found" #debug(" *** File Not Found;") #debug("PATH: %s"%file) except IOError: raise IOError("Failed to load file"); except Exception as e: print "VLC instance Error: %s"%(e.args) #self.__media__ #self.__media__ = None; #if isPosix: print " . if-Play" if play : self.mediaPlay() elif ret: # if loaded successfully # initial state is STOPPED which is used as ENDED # start then pause to get the state away from stopped PyBASS.play(); PyBASS.pause(); return ret
def mediaPause(self): PyBASS.pause();
def mediaStop(self): PyBASS.setPosition(0); PyBASS.pause();
def mediaLoad(self, file, play=False): ret = False try: #print os.stat(file) #if isPosix: print " . Path Fix" self.mediaUnload() # remove the old file isExist = os.path.exists(file) #attempt to fix the file path if on a case sensitive file system if not isExist and isPosix: # although MpGlobal.Player also does a path fix # we do need to check here just in case. newFilePath = UnixPathCorrect(file) if os.path.exists(newFilePath): file = newFilePath isExist = True debug("Path Correction: \n%s" % file) if not isPosix: path = toUTF16(file) else: path = file if isExist: # TODO - File load error # python claims the file exists but sometimes # the load still fails, claiming the path does not exist. # by simply re encoding the file path and checking # if the file exists again solves the issue. strange. for i in range(5): path_utf16 = toUTF16(file) fex = PyBASS.utf16_fexists(path_utf16) if fex: ret = PyBASS.load(path_utf16, 1) if i > 0: print "Loaded on %d-th attempt" % i PyBASS.setDSPBlock(self.DSP_SETTINGS) #print self.DSP_SETTINGS break else: print "for fell thru on load." raise IOError("Failed to load file") else: print "file not found" #debug(" *** File Not Found;") #debug("PATH: %s"%file) except IOError: raise IOError("Failed to load file") except Exception as e: print "VLC instance Error: %s" % (e.args) #self.__media__ #self.__media__ = None; #if isPosix: print " . if-Play" if play: self.mediaPlay() elif ret: # if loaded successfully # initial state is STOPPED which is used as ENDED # start then pause to get the state away from stopped PyBASS.play() PyBASS.pause() return ret
def mediaPause(self): PyBASS.pause()
def mediaStop(self): PyBASS.setPosition(0) PyBASS.pause()