Skip to content

Commit

Permalink
fixed last song not playing
Browse files Browse the repository at this point in the history
  • Loading branch information
Astarcys committed Jan 29, 2024
1 parent d1c7478 commit a30df58
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Sap.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
from os import listdir
from os import remove
from pygame import mixer
from time import sleep
mixer.init()
print("\nWelcome to Sappy!\n")
print("Here are your saved songs... To add more, move the required audio files to the 'songs' folder.\n")
v=1.0
L=listdir('songs')
for i in range(len(L)):
print(i+1,'.','\t',L[i])
for i in range(len(listdir('songs'))):
if listdir('songs')[i]!='ZZZ.txt':
print(i+1,'.','\t',listdir('songs')[i])
print('\n')
while True:
n=input("\nChoose function (Enter h for help): ")
if n.lower()=='p':
sn=int(input("Specify the song ID from the list: "))
if sn in range(len(L)):
s=str(L[sn-1])
if sn in range(len(listdir('songs'))):
s=str(listdir('songs')[sn-1])
if mixer.music.get_busy()==False:
print("Now playing:",s)
mixer.music.load("./songs/"+s)
mixer.music.set_volume(v)
mixer.music.play()
else:
mixer.music.queue("./songs/"+s)
print("Queued:",s)
else:
mixer.music.queue("./songs/"+s)
print("Queued:",s)
print('Invalid function... try again.')
elif n.lower()=='l':
print("\nShowing song list.\n")
for i in range(len(L)):
print(i+1,'.','\t',L[i])
for i in range(len(listdir('songs'))):
if listdir('songs')[i]!='ZZZ.txt':
print(i+1,'.','\t',listdir('songs')[i])
elif n.lower()=='v':
print("Current volume:",mixer.music.get_volume()*100,'%')
v=(float(input("Enter Volume: ")))/100
Expand All @@ -42,6 +46,12 @@
elif n.lower()=="s":
mixer.music.stop()
mixer.music.unload()
elif n.lower()=="d":
d=input("Song number to be deleted (enter 'esc' to skip): ")
if d=='esc':
continue
elif int(d)-1 in range(len(listdir('songs'))):
remove('songs/'+str(listdir('songs')[int(d)-1]))
elif n.lower()=='q':
if mixer.music.get_busy()==True:
mixer.music.stop()
Expand Down
Binary file added songs/10-Second-Beep-Timer.mp3
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions songs/ZZZ.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[IMPORTANT!!!!!]
DON'T DELETE ME.
NO MATTER WHAT.
JUST DON'T.

0 comments on commit a30df58

Please sign in to comment.