Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Home Forums Cody Bank Play Pause media player by Python Library

Viewing 0 reply threads
  • Author
    Posts
    • #1091
      Abhishek TyagiAbhishek Tyagi
      Keymaster
      import pygame
      import time
      
      files = ['./vp1.mp3','./vp.mp3']
      pygame.init()
      pygame.mixer.init()
      stepper = 0
      #file loading
      while stepper < len(files):
          pygame.mixer.music.load(files[stepper])
          print("Playing:",files[stepper])
          stepper += 1
          pygame.mixer.music.play()
      #play and pause
          while pygame.mixer.music.get_busy():
              timer = pygame.mixer.music.get_pos()
              time.sleep(1)
              control = input()
              pygame.time.Clock().tick(10)
              if control == "pause":
                  pygame.mixer.music.pause()
              elif control == "play" :
                  pygame.mixer.music.unpause()
              elif control == "time":
                  timer = pygame.mixer.music.get_pos()
                  timer = timer/1000
                  print (str(timer))
              elif int(timer) > 10:
                  print ("True")
                  pygame.mixer.music.stop()
                  break
              else:
                  continue
Viewing 0 reply threads
  • You must be logged in to reply to this topic.