0

Everything of the program works when I ask pycharm to run it. yet when I ask my raspberry Pi to run it, it skips the EndTimer. so the song keeps on playing. On windows the song would stop. What could make this little diffrence?

import datetime
import pygame

def Clockupdate(time):
    Timer = "21:56:00"
    EndTimer = '21:56:20'
    if time == Timer:
        playsound()
    if time == EndTimer:
        global a
        a = False
def secondrefresher():
    newtime = ""
    oldtime = datetime.datetime.now()
    a = str(oldtime.hour)
    b = str(oldtime.minute)
    c = str(oldtime.second)
    if int(c) < 10:
        c = "0"+str(c)
    if int(b) < 10:
        b = "0"+str(b)
    curtime = (a+":"+b+':'+c)
    if curtime != newtime:
        newtime = curtime
        Clockupdate(newtime)

def playsound():
    pygame.mixer.init()
    pygame.mixer.music.load("ABTPP.mp3")
    pygame.mixer.music.play()

global a
a = True

while a:
    secondrefresher()
Anton van der Wel
  • 451
  • 1
  • 6
  • 20
  • Probably doesn't have anything to do with your problem but this code burned my eyes a little. Please consider using `datetime` objects to represent and compare times. Learning their formatting will also save you a lot of time (pun indented) – Josep Valls Jun 01 '17 at 21:03
  • to make a program small enough to fit here I just copied and delete some from my main code. The `datetime` objects are used more carefull there ;). But still it may have taken asmuch time to copy as to write a new time function so maybe I will update it tonight. – Anton van der Wel Jun 01 '17 at 21:36

0 Answers0