0

My code:

import pygame
import time

pygame.mixer.init() #to initiate the mixer

pygame.mixer.music.load('/home/xolo/bahara.mp3') #load path of song

time.sleep(1)

pygame.mixer.music.stop() #stop loaded song

while pygame.mixer.music.get_busy():
    time.sleep(1)

Is there any way to handle 2 programs for playing and stopping music using pygame.

Using a similar script I am able to play music but using above code I am not able to stop the music when executing from the terminal.

elegent
  • 3,857
  • 3
  • 23
  • 36
xolo
  • 13
  • 5

1 Answers1

0

instead of stopping song using pygame, one can stop song using terminal; when song is played using python(pygame) by following commands.

ps -A | grep python > pidno.txt

s=cat pidno.txt | cut -d' ' -f2

kill $s

xolo
  • 13
  • 5