| | |
Alarm Question
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 0
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;
any help would be great.
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;
Python Syntax (Toggle Plain Text)
from win32com.client import Dispatch #set up music player mp = Dispatch("WMPlayer.OCX") tune = mp.newMedia("Therock.wav") mp.currentPlaylist.appendItem(tune) import time import random #alarm clock print "Awesome Alarm Clock!" print "Awesome Alarm will go off at 8:00AM" not_exec = 1 while(not_exec): dt = list(time.localtime()) hour = dt[3] minute = dt[4] if hour == 8 and minute == 00: not_exec = 0 mp.controls.play() #turn off game print "Guess the number to stop the music" print "**********************************" guess = input("Guess > ") x = 0 rando = random.randint(1, 100) while x == 0: if guess > rando: guess = input("Nope too high try again ") mp.currentPlaylist.appendItem(tune) elif guess < rando: guess = input("Nope too low try again ") mp.currentPlaylist.appendItem(tune) else: print "Congrats, now try to stay awake" x=1 mp.controls.stop()
any help would be great.
•
•
Join Date: Dec 2006
Posts: 1,056
Reputation:
Solved Threads: 298
0
#2 Nov 8th, 2009
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.
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
![]() |
Similar Threads
- WJQS.exe caught by Zone Alarm - Question (Viruses, Spyware and other Nasties)
Other Threads in the Python Forum
- Previous Thread: Rectangles in functions?
- Next Thread: Maze solving
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied apache application argv beginner book change code color converter dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path phonebook port prime program programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse scrolledtext server session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython






