The PyBass PYTHON wrapper is licensed under the MIT license. Meanwhile the BASS C Library is dual licensed as free to use for non-commercial development but requires a license for paid/commercial work. Please see http://un4seen.com
A simple wrapper around un4seen.com's BASS audio library to enable playing various format media files from python.
fromargparseimportArgumentParserfrompybass3importSongimporttimedefmain(song_file): song=Song(song_file) song.play() len_bytes=song.duration_bytesposition_bytes=song.position_bytesprint("Playing: ", song_file) print(f"Bytes: {len_bytes=}") whileposition_bytes<len_bytes: print(song.position, song.duration) time.sleep(1) if__name__=="__main__": parser=ArgumentParser() parser.add_argument("song_file") args=parser.parse_args() main(args.song_file)importpathlibimporttimeimportargparseimportmsvcrtfrompybass3importSongfrompybass3.playlistimportPlaylistdefkbfunc(): x=msvcrt.kbhit() ifx: ret=ord(msvcrt.getch()) else: ret=0returnretdefmain(dir_path): dir_path=pathlib.Path(dir_path) playlist=Playlist() playlist.add_directory(dir_path, recurse=True) playlist.play() play_indefinitely=Truewhileplay_indefinitely: try: print(playlist.current.file_path.name, playlist.current.position, playlist.current.duration) playlist.tick() key=kbfunc() ifkey: ifkey==122: # Zprint("Previous") playlist.previous() elifkey==98: # B print("Next") playlist.next() elifkey==120: # Xprint("Play") playlist.play() elifkey==99: # cprint("Pause") playlist.pause() elifkey==118: # vprint("Stop") playlist.stop() else: time.sleep(1) exceptKeyboardInterrupt: playlist.free() play_indefinitely=Falseif__name__=="__main__": parser=argparse.ArgumentParser() parser.add_argument("song_dir") args=parser.parse_args() main(args.song_dir)