#---------------------------------------------------------------------------------------------# # DPMusic v1.1 (c) Copyright 2014 hTml. All Rights Reserved # # Please do not modify this app without my permission - i still work on this project. # #---------------------------------------------------------------------------------------------# from ID3 import * import mp3play from os.path import getmtime from os import getcwd from os import listdir from os import popen import time first=True volx=100 path=getcwd() mp3="" content=[] contentx=listdir(path+'\\pball\\music') for i in contentx: if i[-4:]==".mp3": content.append(i) print content if len(content)>0: tx=content[0] mtime=getmtime(path+'\\pball\\mp3.txt') for i in range(len(content)): content[i]=content[i].lower() def doesrun(): global mp3 try: fo=open('paintball2.exe', 'a') fo.close() mp3.stop() return False except: return True def getcommand(): fo=open('pball/mp3.txt', 'r') return fo.read().split('\n')[-3] fo.close() def play(f): global stime global first global volx global mtime global mp3 try: finfo=ID3('pball/music/'+f) fox1=open('pball/configs/track.dpmusic', 'w') fox1.write('me is listening to '+finfo['TITLE']+' by '+finfo['ARTIST']+" [DPMusic by hTml]") fox1.close() except: fox1=open('pball/configs/track.dpmusic', 'w') fox1.write('echo "No artist and/or track title specified in the mp3 file. Posting the filename.\nme is listening to '+f) fox1.close() finfo="" mp3=mp3play.load('pball/music/'+f) mp3.play() stime=time.time() if first: first=False mp3.pause() mp3.volume(volx) done=False while (mp3.isplaying() or mp3.ispaused()) and doesrun(): done=False while 1: if not mp3.isplaying() and not mp3.ispaused(): cmd="" break if mtime!=getmtime(path+'\\pball\\mp3.txt'): mtime=getmtime(path+'\\pball\\mp3.txt') cmd=getcommand() break else: agsfhd=12135 if not doesrun(): cmd="" break time.sleep(1) if cmd[:9]=="mp3 load ": play(cmd[9:]+'.mp3') done=True if cmd=="mp3 pause": mp3.pause() done=True if cmd=="mp3 unpause": mp3.unpause() done=True if cmd=="mp3 stop": mp3.stop() done=True if cmd=="mp3 next": play(nextt(f)) done=True if cmd=="mp3 previous": play(previoust(f)) done=True if cmd[:11]=="mp3 volume ": mp3.volume(int(cmd[11:])) volx=int(cmd[11:]) done=True if not done and doesrun(): play(nextt(f)) def nextt(track): numer=content.index(track) nextie=(numer+1)%len(content) return content[nextie] def previoust(track): numer=content.index(track) nextie=(numer-1)%len(content) return content[nextie] if len(content)>0: play(tx)