Python play pause music

import time
import pygame
#3、 Set absolute music path

# Music path

filepath=r"13.mp3"

#4、# initialization

pygame.mixer.init()

# Load music
track = pygame.mixer.music.load(filepath)

# play music
pygame.mixer.music.play()

# The time for playing music, if there is no sleep time, the program will be executed at once, and the music will not be played
time.sleep(232)

# Music off
pygame.mixer.music.stop()

Thank you for your attention

~

If you are learning crawlers, you can get learning materials in the "Learning Materials" column
If you need any python-related learning materials, please leave a message~

Recommended Posts

Python play pause music
Python is short-crawling music
Play WeChat with Python
Python example method to open music files
How to add background music in python