Detecting events in iTunes

I've only spent 30 days with AppleScript, so I'm still asking questions like "Can AppleScript get messages or does it only send them?"
Here's what I'm getting at. Is there a way for an AppleScript to detect when iTunes changes tracks, when it reaches the end of a playlist, or if the user changes iTune's playing state?
Similarly, can a script detect when the user opens a new movie in QuickTime (or selects a new movie).
I'm imagining in pseudo code:
on iTunesEvent theEvent
-- script here
end iTunesTimeEvent
on QuickTimeEvent theEvent
-- script here
end QuickTimeEvent
Anything like that?
In other words, does iTunes send a message when such event occurs. If not, then my script must regularly get the state of those properties from iTunes and determine if they've changed, correct?
I've received VERY helpful advice and insights on these forums! Many thanks to all! Through your help I've got a powerful tool I'll use almost every day in my work.
John

What you're asking for is a feature known as attachability - the abilty to attach a script to an application.
It is possible to do in AppleScript, but the catch is that the application developer has to specifically support it in his app. Like the vast majority of applications iTunes doesn't do this.
The only way you can do what you describe is to periodically poll the app to find out what it's doing. iTunes supports a 'player state' property that tells you what it's doing, plus a 'current track' property that identifies the current track being played (if any).
Something like this should work (untested):
<pre class=command>global lastTrack
on run
-- initialize a variable to store the current track
set lastTrack to missing value
end run
on idle
tell application "iTunes"
if (get player state) = playing then
set curTrack to (get current track)
if curTrack ≠ lastTrack then
-- we're not playing what we were playing last time we checked, so:
display dialog "Now playing " & name of curTrack giving up after 5
-- record the current track for prosperity
set lastTrack to curTrack
end if
end if
return 10 -- check again in 10 seconds
end idle</pre>

Similar Messages

  • HT1369 iphone4 is not getting detect in my itunes after installing itunes 10.7.0.21

    iphone4 is not getting detect in my itunes on Windows vista (OS) after installing/upgrading to itunes 10.7.0.21

    Device not detected in iTunes

  • My iphone is not being detected by the itunes on my laptop with windows 8

    the iphone is not being detected by the itunes on my laptop with windows 8
    someone please help

    iPhone, iPad, or iPod touch not appearing in iTunes

  • Can no longer sync aperture events through iTunes to ipad3

    I can no longer sync aperture events through iTunes with ipad3. Mavericks/Aperture 3.5.1/ IOS 7.0.4
    Have tried deleting Iphoto cache from Aperture Library.
    Worked once. 
    Itunes will sync a folder of images onto Ipad with sync.
    But will no longer extract events from Aperture library.
    Was hoping tonights Aperture fix grade in conjunction with IOS upgrade would repair issue.
    No luck.  Help?

    I have the same problem with my ipod nano. I downloaded tunes from my old pc. ITunes does not recognise it from my new pc and I cannot sync.

  • PVC2300 - Alternative to Motion Detection Event / FTP Upload

    Hi Cisco Community,
    My apologies if I am not posting this in the correct section / allowed to post here.
    I've got a PVC2300 mounted inside a pelco enclosure that is positioned 6 meters high. Sometimes the motion detection event doesn't work to well (this is due to the fact that its in an enclosure and pointed out towards the ocean at a beach location).
    Also the motion detection event is pretty much useless at night without surrounding illumination.
    In Australia we also have severe lack of broadband speed and also download allowance, therefore it is not practical to broadcast streaming video (we would get charged excessive fees for exceeding download quotas and only one person could view the camera at any one time).
    I've written a custom windows service that reads the PVC2300's MJPEG stream over http at a specified interval and saves a single .JPG file in which the windows service uploads the .JPG file to a specified website. This means that you will always get an updated image from the camera every 5 minutes, rather than based on motion detection. It would have been nice if cisco / linksys implemented this within the camera's firmware (maybe in a future version?).
    Anyway, communities share things with each other, so i've made the software freely available to anyone who wishes to use it. I would appreciate any feedback from Cisco / Linksys.
    http://www.airbiscuit.com.au/pvc2300-service.html - PVC2300 Windows Service
    http://www.airbiscuit.com.au/camera.aspx - The actual PVC2300 in operation
    Regards,
    David Zielinski

    You came to the right place and thats a very cool post IMO.
    First, thanks for using Cisco Small Business products and you can look forward enhancements and options in our line, of course.  I think I noticed your other post mentioning you are in Australia?  We have a few really top BU folks (TMEs and Biz Dev) down under and they are very active in the BU solutions area for Small Business.   Do you know Leah Davis and Dave Harper (they are Participants on this community as well)? 
    In any event, I think compressed streaming is a very valid design idea and we are actually looking at similar partners in the US experimenting with the same.  In one Partners case he has a lightweight application (java) that runs on your mobile and allows all the mobile streams to come compressed from a server farm.
    Typical use case is a Day Care where 15 parents want to watch the same camera, and the compression benefit becomes crucial in scale.   But your case is a financial one (therefore good too) where you would have to pay for streaming video. 
    While we dont offer this today (the external managed service that is), I am sure you have played with the camera GUI and realize you can try some of the following to reduce bandwidth
    1- lower quality of video (resolution, FPS, illuminate Audio, etc)
    2- reduce motion detection size (seconds)
    3- Purchase a local NSS2100 or NSS3x00 to store High Quality video on the LAN and only alert for motion via email (not realy friendly for remote monitoring I admit).
    For sensitivity in an enclosure, have you played with Sensitivity settings thresholds in the Camera GUI under motion detection?
    For night illumination without an external IR Illuminator, have you tried the 'night schedule', which activates (or deactivates) the IR Cut Filter?
    For the periodic updates, I'll let Davin Oishi comment as he is about ready to announce the PVC300 and I know it offers a browser based periodic refresh and I am not sure how far he has extended that to an API for external access.....
    Thanks for your post
    Steve DiStefano
    Systems Engineer in the US field channel
    RTP, N.C.

  • Windows detects nano but iTunes does NOT detect even aftr doing all steps

    my windows detects nano but iTunes does NOT detect even after doing all the steps described in the site. Any help ??? please ....

    I did all the steps described in the article in Apple site at iPod appears in Windows Explorer but does not appear in iTunes http://docs.info.apple.com/article.html?artnum=93716

  • A solution for idevice not detected/synced with itunes (11.3 ios 7.1.2 also here)

    hello !
    -the problem i had :
    all perfect, but since last itunes my iphone 5s was not detected anymore by itunes 11.3 or 2 (who cares... but me)
    updated my ios to 7.1.2 then tryied again to sync WIFI-USB to iTunes... => fail !
    (i thinked about wiaitng for a next itunes and/or ios from apple to fix that... but i wanted to fix fastler.)
    (Probelms some have : they reboot their iphone with "connect to itunes" coz their iphone want to be  "RESTOREd" on tiunes when plugged... => THERe NO MIRACLES for that... wait ios update n/or itunes update so..)
    ALWAYS SAVE YOUR idevice USING ICLOUD !!!! IT SAVES ... ALL !! (includings apps data, but the apps themselves ! USE IT ! i done this...)
    -a Fix i have done that worked perfect for me :
    my iphone so was working perfect after ios 7.1.2 update but could not sync...
    so i activated icloud sync on it .... used the "sync to icloud - SAVe NOW" ....
    and...
    (crossing fingers..)
    i restored my idevice !
    (/!\ SINCE my iPhone 3G 16 Mb i never had any problems... or just a bit but always tried to solve by using google or YAHOO..)
    so i restored ALL my iphone LIKE AS LAST STATE ! (i had just to DL all apps, but it's automatik....)
    games saves, apps saves ? (probly too... will test...), all photos docs etc.... where on icloud it was just 1,2 Gb data (not including apps again.)
    -iTunes was not detecting my iDevice (iphone 5s) :
    for this i searched (hadly) on this forum... and found this solution that worked for me :
    (Itunes can't recognize my IPhone ) <- click topik link
    if i remember well ... (i am on PC win 8.1 x64 bits) ...
    you must desinstalle :
    "APPLE SOFTWARE UPDATE", "iTUNES" and "APPLE MOBILE DEVICE SUPPORT" and (.... 30 sec plz...) .. and " APPPLE application support" also...
    (not sure but check this link just up here ^ ....)
    voilà...
    ->
    THINK ALSO, YOUR iDEVICE USB CABLE MUST BE "CERTIFIED FOR APPLE" .... i bought a chineze cable for 5 € did not worked...
    i bought a "BELKIN" on Amazon it works flawless... (coz it's certified apple, even it's not an apple... but solid one)
    ->
    don't forget to reboot your system before relaunching the itunes if u need reboot...
    i hope i helped somes here...
    iDevice are REALLY NICE i love them but sometyimes they caprices.... (sciences is unperfect)...
    -> dont let it down (this topik) this can serves... well !
    peace...

    ALWAYS SAVE YOUR idevice USING ICLOUD !!!! IT SAVES ... ALL !! (includings apps data, but the apps themselves ! USE IT ! i done this...)

  • I can't sync my photo events using iTunes; only some of them appear on my IPhone Why?

    I can't sync my photo events using iTunes; only some of them appear on my IPhone Why?

    Solved here...
    Photos app not syncing with iTunes

  • Hola , me compre un ipod 5g pero resulta que al conectarlo a la pc solo lo detecta windows y itunes no y tambien tengo otro problema resulta que cuando abro itunes la pantalla de mi pc se hace pequeña o aveces grande es algo muy raro :/ necesito ayuda

    Hola , me compre un ipod 5g pero resulta que al conectarlo a la pc solo lo detecta windows y itunes no y tambien tengo otro problema resulta que cuando abro itunes la pantalla de mi pc se hace pequeña o aveces grande es algo muy raro :/ necesito ayuda

    Google translate:
    Hi, I bought an ipod 5g but it turns out that when connected to the pc only detects windows and itunes not and also I have another problem is that when I open itunes the screen of my pc is small or sometimes big is something very strange :/ I need help
    See
    iOS: Device not recognized in iTunes for Windows
    - I would start with
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    or               
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    However, after your remove the Apple software components also remove the iCloud Control Panel via Windows Programs and Featurs appin the Window Control Panel. Then reinstall all the Apple software components
    - New cable and different USB port
    - Run this and see if the results help with determine the cause
    iTunes for Windows: Device Sync Tests
    - Try on another computer to help determine if computer or iPod problem

  • HT1925 what to do when my ipone displays diferrent sim detected connect to itunes

    hi
    what to do when my ipone displays diferrent sim detected ,connect to itunes thanks for your reply in advance

    When using recovery mode, you can only restore the device. All user content on the device will be erased, but if you had previously synced with iTunes on this computer, you can restore from a previous backup. See this article for more information.

  • My iPhone cannot detected by the iTunes

    My iPhone cannot detected by the iTunes,what can I do?

    The following may help:
    iTunes on Windows computer: http://support.apple.com/kb/TS1538
    Mac: http://support.apple.com/kb/TS1591

  • Mon ipod affiche la pomme et ne bouge plus de plus je ne le detecte pas sur itunes que faire ?

    mon ipod affiche la pomme et ne bouge plus de plus je ne le detecte pas sur itunes que faire ?

    Google translate:
    my ipod shows the apple and not move again I do not detect itunes on what to do?
    Try:
    - iOS: Not responding or does not turn on
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iPod fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - If still not successful that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.

  • Unable to detect touch4g in windows only. Am able to detect it using itunes

    I got my new touch 4g yesterday. when I first plugged it in, the PC detected it as a camera. After installing iTunes, my device was detected by iTunes but was not detected by PC. I went through several message boards on the net and did the reinstallation, etc. When I completely removed iTunes, my PC again detected the device as a camera. But after the reinstallation of itunes, my PC (again) stopped showing the device. I am still able to use the device with iTunes, but I would like to be able to use another software with it, which requires that the device be recognized by the PC. Please help!
    PS - I upgraded to iOS5 after the whole thing, but it didn't help.

    OK, there is still not much to go there.
    I assume you are using 32 bit XP Pro, iTunes will not install on 64 bit XP but you should get a different error.
    Lets try installing the components of iTunes separately.
    Download the iTunes installer and save it in your downloads folder.
    The files will be either itunessetup.exe or itunes64setup.exe for a 64 bit system.
    Open notepad and copy the following 3 lines into it.
    md temp
    itunes64setup /extract temp
    pause
    Remove 64 for 32 bit itunes.
    Save the file as extract.bat into the same folder that contains the itunes installer.
    Open the downloads folder and you should find the extract file that you saved. Double click on it and a black window will open telling you what it is doing. When its finished, press any key to continue.
    You should find that a folder called temp has been created containing all the itunes msi files.
    Install by double clicking on them  in this order:
    Apple Application Support
    Bonjour
    Apple Mobile Device Support
    Apple Software Update
    iTunes
    Make a note of any error messages and which component it relates to.
    Also use the Windows Event viewer to see if there are error messages at the time you attempted the installs.
    The following article gives information about using the Event Viewer:
    http://support.microsoft.com/kb/308427

  • I have recently downloaded the latest version of itunes and now my ipod is not being detected on my itunes

    This has been really frustrating me today, I downloaded the new version of itunes today and now it seems that my ipod will no longer connect to itunes. when I plug the usb cable into my laptop it recognizes it is there but itunes doesn't detect that it is there.
    it doesn't even open the itunes up when i plug it in, this is really bugging so any help would be great.
    thanks

    See TS1538: iOS: Device not recognized in iTunes for Windows, in particular section 5.
    tt2

  • My iPhone 4s is not detected by windows iTunes.

    After upgrading to Windows Ultimate, my iPhone 4s is not detected by Itunes (latest version) though my iPad 3 does and my old iPhone 3s are detected ok.

    http://support.apple.com/kb/TS1538

Maybe you are looking for

  • What is the model number of 9 cell battery - Satellite Pro A300

    What is the model number of the 9 cell battery for the Satellite Pro A300? I am ready to make the jump, but I can't find the battery. thanks jb

  • Hangparas environment in LaTeX (hanging.sty)

    I'm trying to make a list of references for a paper in APA format - incidentally, the same one I talk about in a couple of other posts. I know this can be done with BibTeX somehow, but I'm not quite there yet At any rate, I don't have a huge list. Th

  • Running a OS command from PL/sql Block.

    I am using UTL_FILE to write data to a text file from within a stored procedure.Before terminating the procedure i would like to run FTP command on the server to copy the file to a different server. Can this be done..... ? Or is this asking for too m

  • Replacing an updated page in multiple files in the same folder

    I have a large number of files of 5 pages long with some of the pages being the same.  There comes a time when information on some of these pages has to be up-dated. I want to know if there is a fast way of exchanging a page in all these files withou

  • New To Flash Lite

    Hi, I am new to Flash Lite. Can any one tell me a site to learn about Flash Lite.