-1

I am using pygame to play music in python

from pygame import mixer
mixer.init()
mixer.music.load('/home/sample.mp3')
mixer.music.play()
mixer.music.stop()

I want to play the music automatically from time t1 to time t2 say from 8:00AM to 8:10AM,then from 10:15am to 10:25 am.How can I do that? Thanks.....

  • 1
    https://stackoverflow.com/questions/373335/how-do-i-get-a-cron-like-scheduler-in-python – F Trias Apr 22 '20 at 12:22
  • You could play the music on start of code execution for a specified time length, and use the scheduler in your operating system to decide when the code has to be executed. – Cibin Joseph Apr 22 '20 at 12:25

1 Answers1

0

You can use the python standard module time for that. I often use the method localetime() but I think it is not really the best way to do it. You can find more out about it in the python documantation.