Alarm Question

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2009
Posts: 1
Reputation: herebutfortea is an unknown quantity at this point 
Solved Threads: 0
herebutfortea herebutfortea is offline Offline
Newbie Poster

Alarm Question

 
0
  #1
25 Days Ago
As many people new to python i seem to have run into a bit of a snag with an alarm program i was making. I wanted to make something that would play a song (.wav) at a given time and would not stop unless you played a little game, guess the number from 1 to 100.

Now my program works when i run it in pythonwin through the interactive window, however when i try to run it though cmd the music doesn't play. here's what i came up with;

  1. from win32com.client import Dispatch
  2. #set up music player
  3. mp = Dispatch("WMPlayer.OCX")
  4. tune = mp.newMedia("Therock.wav")
  5. mp.currentPlaylist.appendItem(tune)
  6.  
  7. import time
  8. import random
  9. #alarm clock
  10. print "Awesome Alarm Clock!"
  11. print "Awesome Alarm will go off at 8:00AM"
  12. not_exec = 1
  13. while(not_exec):
  14. dt = list(time.localtime())
  15. hour = dt[3]
  16. minute = dt[4]
  17. if hour == 8 and minute == 00:
  18. not_exec = 0
  19.  
  20. mp.controls.play()
  21.  
  22. #turn off game
  23. print "Guess the number to stop the music"
  24. print "**********************************"
  25. guess = input("Guess > ")
  26. x = 0
  27. rando = random.randint(1, 100)
  28. while x == 0:
  29.  
  30. if guess > rando:
  31. print
  32. guess = input("Nope too high try again ")
  33. mp.currentPlaylist.appendItem(tune)
  34. elif guess < rando:
  35. print
  36. guess = input("Nope too low try again ")
  37. mp.currentPlaylist.appendItem(tune)
  38. else:
  39. print "Congrats, now try to stay awake"
  40. x=1
  41. mp.controls.stop()

any help would be great.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,022
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 288
woooee woooee is offline Offline
Veteran Poster
 
0
  #2
24 Days Ago
That is usually a directory problem, i.e. it can't find something because it is not in the current directory. For this line, give it the absolute path name
tune = mp.newMedia("/complete/path/Therock.wav")
If that doesn't work, check that something is printed so you know the program was started. Finally, if you haven't found anything, use a try/except to catch error messages and see if anything is printed.
Linux counter #99383
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC