Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to play music on pygame

import pygame

pygame.init()
mixer.music.load("music/main.wav")#music file 
mixer.music.play(-1)
Comment

how to play audio in python using pygame

from pygame import mixer
  
# Starting the mixer
mixer.init()
  
# Loading the song
mixer.music.load("song.mp3")
  
# Setting the volume
mixer.music.set_volume(0.7)
  
# Start playing the song
mixer.music.play()
  
# infinite loop
while True:
      
    print("Press 'p' to pause, 'r' to resume")
    print("Press 'e' to exit the program")
    query = input("  ")
      
    if query == 'p':
  
        # Pausing the music
        mixer.music.pause()     
    elif query == 'r':
  
        # Resuming the music
        mixer.music.unpause()
    elif query == 'e':
  
        # Stop the mixer
        mixer.music.stop()
        break
Comment

PREVIOUS NEXT
Code Example
Python :: python print 2d array as table 
Python :: @foreach 1 numper 
Python :: how to convert a matrix string back to a matrix python 
Python :: tkinter label border color 
Python :: python cassandra 
Python :: fill column based on values of another column 
Python :: how delete an entry tkinter 
Python :: name columns pandas 
Python :: pandas transform count where condition 
Python :: generate barcode using python 
Python :: how to leave a function python 
Python :: add row to dataframe 
Python :: python cursor placement 
Python :: ** in python 
Python :: Maximize Difference 
Python :: np array size 
Python :: embed python discord 
Python :: python type casting 
Python :: Count Zero 
Python :: create array numpy 
Python :: python use variable name as string 
Python :: python dataframe sort by column name 
Python :: assert with message python 
Python :: value list in django 
Python :: lenet 5 keras 
Python :: deleting a tuple in python 
Python :: numpy maximum 
Python :: Python Pandas - How to write in a specific column in an Excel Sheet 
Python :: how to do input python 
Python :: librosa python 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =