Hi, so I'm in the process of writing a music player with a GUI. I would like to be able to print a statement after I am done playing a song. I originally through I could just get away with getting the song's length and time.sleep'ing for that long. Since my GUI has a pause button, I think just using time.sleep is out of the question, as the song and the sleep function would become out of sync. So, how would I be able to accomplish my goal? Hopefully my question is clear enough...just ask if you need more information.

By the way, I am using tkSnack as my sound library.

Thanks in advance.

I guess your audio toolkit of choice have state for checking status of playing stream. If true, then simple if will do the job on the timer event

if MY_AUDIO_STREAM_RUNNING== mytoolkit.FINISHED_PLAYING:
    print "Finished!" #here you print

so it will skip it each time until it finds stream have ended. Since I'm not sure if you are still using TkSnack then That is for now (I'm zero in TkSnack so sorry :))

Well, thanks for the suggestion, but tkSnack does not have anything close to that.

Okay, I've found my solution and I thought I would share it. Even though tkSnack cannot tell you if the stream is active or not, it does tell you how long a track is. Using that information, I used a thread to keep the elapsed time of a song (by sleeping for 0.5 seconds then updating the elapsed time).

Problem solved.

I think 10ms is the best for time accuracy :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.