Home Python music queue/player
Reply: 1

Python music queue/player

Dr Creator
Dr Creator Published in 2018-02-13 23:58:26Z

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)
            clock = pg.time.Clock()
                print("HipHop Music Loaded")
            except pg.error:
                print("File {} not found! ({})".format(music_file, pg.get_error()))
            while pg.mixer.music.get_busy():
        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":
Anthony Kong
Anthony Kong Reply to 2018-02-14 01:41:55Z

A list should be good enough

    music_files = ['C:/Users/jackj/Documents/ocr/HipHop/Drake - God’s Plan (Sevnth  Alo Cover).mp3',
      'C:/Users/jackj/Documents/ocr/simon and garfunkel/the sound of silence.mp3',
      'C:/Users/jackj/Documents/ocr/simon and garfunkel/mr robinson.mp3'
    volume = 0.6 
    for music_file in music_files:
      play_music(music_file, volume)

You can find out more about list here: https://developers.google.com/edu/python/lists and here: https://docs.python.org/2/tutorial/datastructures.html#

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO