SamuraiK9
SamuraiK9

Reputation: 1

having problems with an audio playlist program using pygama.mixer.music

I have made the player so user inputs folder directory path where their music is stored and then created a list form it. ive tried many ways using os.path.join() etc to band together the folder path and file path in a for loop but kept getting errors. as os.path.join doesn't accept a list as an argument. using os.path.join I have only managed to play one track multiple times but not loop through playlist. I also tried creating and appending to a new list to play using the queue(). In the end I came on stack and used a for loop from an existing answer to play and and queue the songs however now my audio files are not found which I never had issues with before? I Hvent even got to the part about playback functionality yet because of the issue of playing the playlist I know the while loop at the end of the for loop is there but have left that out now so I can find the error issue in this new for loop I have printed the mp3_tunes list to check it and it prints out like a regular list it is all indented and done properly however the question changed it to this format

import pygame
import os
import random
import time


pygame.mixer.init()
print()
print("Hello, welcome to your mp3 media player. For this program you will need to know your file path to the folder where your mp3 files are stored \n") 
path = input("Folder path: ").strip()
folder_path = path
   
mp3_tunes = [file for file in os.listdir(folder_path) if file.endswith(".mp3")]

for i, track in enumerate(mp3_tunes):
    
    if i <= len(mp3_tunes):
        pygame.mixer.music.load(track)
        pygame.mixer.music.play()
    else:
        pygame.mixer.music.queue(track)

Upvotes: -1

Views: 16

Answers (0)

Related Questions