What's the output from this program using fork() and why?

Interrupting itunes playback - how to do it automagically

  • I want to interrupt a playing itunes stream with another program's output. I already have many pieces in place, but I need to trigger itunes to shaddap. How to do? My client is a coffee shop and has a large Muslim following. We want to have call to prayer announced over the sound system. The sound system in question is a PC with itunes installed. I've installed a piece of software called Athan from IslamicFinder that will announce Azan at the appropriate times. I've tried to contact them but no response. So, what I want is: - itunes is running a playlist - Athan software says "stop! I need to play call to prayer" - itunes pauses - Call to prayer runs and completes - itunes resumes. I know I can script itunes, and I've tested that the itunes stop/start script is the right one for the job. The trick is how to tell it to do so. It appears Athan uses windows media player to play call to prayer. Are there WMI events I could trap, and whats the best way to go about using them? Any suggestions welcome!

  • Answer:

    Are there WMI events I could trap, and whats the best way to go about using them? Does a window pop up when Athan starts playing or anything like that? If there's something like that you can check for, http://www.autohotkey.com/ is probably the easiest way to write a script to do it. Windows API has some relatively easy-to-use functions for checking if a certain window is on the screen or not. Also AutoHotKey specifically has some more complex options like http://www.autohotkey.com/docs/commands/PixelSearch.htm on the screen, so if there's any sort of visual indication when the audio plays you may be able to write a script to detect it.

disclaimer at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

So you just want to trigger an Applescript (to stop/start iTunes) when Athan does its thing, right? Sort of a hacky way to do this is to use http://www.rogueamoeba.com/audiohijackpro/ and set it to run a script when it detects any sound coming from the Athan program. I can't think of a better way to do it without having some access to what Athan is doing. Alternative: Is Athan necessary? Are the times constant every day? You could definitely make your own script that plays a call-to-prayer MP3 at certain times, and interacts with iTunes as well.

supercres

Oh, sorry. I noticed the "PC" part about ten seconds too late. There must be a PC program that runs like Audio Hijack: "Program X has sound output above threshold Y? Okay, run script Z!" I don't know specifics, though. Sorry.

supercres

You can use the terminal command '/usr/bin/osascript /path/to/script.scpt' to execute the AppleScript that tells iTunes to stop/play call to prayer/start. You could then use http://www.macosxhints.com/article.php?story=2001020700163714 (pre OS 10.5) or http://developer.apple.com/macosx/launchd.html (OS 10.5 & later) to run osascript to run the call to prayer script at the designated intervals. Cron is pretty easy to configure "by hand", launchd considerably less so (IMHO) - but there is a launchd GUI called http://lingon.sourceforge.net/ that's helpful.

usonian

::sigh:: I'm sorry - I read your question through twice and still managed to miss the 'PC' part. I'm not familiar with COM scripting for iTunes, but theoretically the same strategy should work; have a an automated process call your script at the correct intervals. Maybe http://cronw.sourceforge.net/ is worth a look?

usonian

Frankly, I would install Linux or FreeBSD on the machine and run http://savonet.sourceforge.net/, which is a powerful (read: stepp learning curve) scriptable stream management package that allows for scheduled interruptions (such as station breaks and calls to prayer). I've Googled for miscellaneous Windows iTunes scripts and while I imagine it's possible to pause/restart or skip to a specific track, I haven't found the information for that yet.

rhizome

A late response... we're going to give AutoHotKey a shot, it looks like it has a good chance of doing exactly what I want. We can't use a cron job (or windows scheduled task) because the actual time of call to prayer varies from season to season and is based on a number of factors. It doesn't happen at the same times every day. Thanks everyone for your responses!

disclaimer

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.