import pygame ''' #1 Play a sequence of songs pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096) pygame.mixer.music.load('when I miss you.mp3') pygame.mixer.music.queue('soft1.mp3') pygame.mixer.music.queue('soft2.mp3') pygame.mixer.music.play(0) ''' #2 Play song randomly import random L = ['when I miss you.mp3', 'soft1.mp3', 'soft2.mp3', 'wind.mp3', 'Jason Piano.mp3'] pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096) def play_random(): global L song = random.choice(L) print(song) pygame.mixer.music.load(song) pygame.mixer.music.play() def play_next(): global L L = L[1:] + L[0] print(L[0]) pygame.mixer.music.load(L[0]) pygame.mixer.music.play() for i in range(10): play_random()