Fix for Windows
This commit is contained in:
@@ -48,6 +48,7 @@ class MusicPlayer:
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if not self.mixer.music.get_busy() and not paused:
|
if not self.mixer.music.get_busy() and not paused:
|
||||||
|
self.mixer.music.unload()
|
||||||
return
|
return
|
||||||
while self.mixer.music.get_busy():
|
while self.mixer.music.get_busy():
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@@ -88,6 +89,7 @@ class MusicPlayer:
|
|||||||
pass
|
pass
|
||||||
elif choice == 4:
|
elif choice == 4:
|
||||||
self.mixer.music.stop()
|
self.mixer.music.stop()
|
||||||
|
self.mixer.music.unload()
|
||||||
return
|
return
|
||||||
elif choice == 5:
|
elif choice == 5:
|
||||||
print(
|
print(
|
||||||
@@ -101,6 +103,7 @@ class MusicPlayer:
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
self.mixer.music.stop()
|
self.mixer.music.stop()
|
||||||
|
self.mixer.music.unload()
|
||||||
self.looping = False
|
self.looping = False
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -177,6 +180,11 @@ class MusicGetter:
|
|||||||
|
|
||||||
def download_song(self, song):
|
def download_song(self, song):
|
||||||
content = requests.get(f"{self.server}/webjammies/{song}", verify=False)
|
content = requests.get(f"{self.server}/webjammies/{song}", verify=False)
|
||||||
|
# for some reason windows will throw permission denied errors trying to
|
||||||
|
# overwrite the file, so that's why i'll remove it first for windows
|
||||||
|
if os.name == "nt":
|
||||||
|
if os.path.exists("song0.mp3"):
|
||||||
|
os.remove("song0.mp3")
|
||||||
with open("song0.mp3", "wb") as f:
|
with open("song0.mp3", "wb") as f:
|
||||||
f.write(content.content)
|
f.write(content.content)
|
||||||
self.musicplayer.nextmeta = self.metadata.get(song)
|
self.musicplayer.nextmeta = self.metadata.get(song)
|
||||||
|
Reference in New Issue
Block a user