Home Python music queue/player
Reply: 0

Python music queue/player

user1379
1#
user1379 Published in June 20, 2018, 12:01 am

I'm trying to create a music queue in my pygame app. I created one location for my music and called it 'music_file' which is limited to one mp3 file but I want to be able to queue music but I'm not sure what data structures to add to my code to create a music queue.

def HipHop():
    import pygame as pg
    options = input("do you want to listen to HipHop? Enter y or n :")
    if options == "y" or options == "Y":   
        def play_music(music_file, volume=0.6):
            freq = 44100     
            bitsize = -16    
            channels = 2     
            buffer = 2048    
            pg.mixer.init(freq, bitsize, channels, buffer)
            pg.mixer.music.set_volume(volume)
            clock = pg.time.Clock()
            try:
                pg.mixer.music.load(music_file)
                print("HipHop Music Loaded")
            except pg.error:
                print("File {} not found! ({})".format(music_file, pg.get_error()))
                return
            pg.mixer.music.play()
            while pg.mixer.music.get_busy():
                clock.tick(30)
        music_file = 'C:/Users/jackj/Documents/ocr/HipHop/Drake - God’s Plan (Sevnth  Alo Cover).mp3'
        volume = 0.6
        play_music(music_file, volume)
    elif options == "n" or options == "N":
        Music()
    else:
        HipHop()
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.410666 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO