Error and music written in Python

Asked

Viewed 392 times

0

inserir a descrição da imagem aquiI wanted to perform a song in python but when I drag it to my project it gets "written", how can I do to execute it? (I’m new to python)inserir a descrição da imagem aqui

1 answer

1

Good night,

You can listen to the music with the help of the pygame library as well as other solutions. Your music should be in the same directory as the file

import pygame

pygame.init() pygame.mixer.music.load('myMusica.mp3') pygame.mixer.music.play() pygame.event.Wait()

  • Good evening, I’ve used this library only pycharm never plays the music, I tried to use this library with these same command several times and it gives a different error out q my music gets in 'Scratch file' whenever I put in the project directory as shown in the image above

  • You have the pygame installed ?

  • Yes, definitely yes

  • Pip install pygame Requirement already satisfied: pygame in

  • he plays music of various sizes right? Or he is limited in time?

  • Can you show your code? Definitely something is wrong in mine worked. Which operating systems use?

  • I think it has something to do with my song being in Stratch file , is that common? Because before I screwed up, it wasn’t in stratch file,but look at the code: import pygame pygame.init() pygame.mixer.music.load('Purple.mp3') pygame.mixer.music.play() pygame.event.Wait()

  • Please print. In your folder you should only have the script file and music, music and script file cannot be in a subfolder

  • I put another print up there

  • Your music is 4.74 MB is 2.56 MB. Try cutting the music or reducing the size

  • OK thank you very much

  • When you resolve the question as resolved please

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.