AppleScript daemon to monitor iTunes playback info - scripting

Is it possible to write an AppleScript as a daemon to monitor or poll from iTunes the current playing song info such as artist name, song title, playback position, etc. ?
Ideally, I'd like to be able to get the info at the exact starting moment of the song.
If yes, where can I find the resources to learn how to do it?

Yes, it is possible to write a launch agent or daemon-like background app that uses AppleScript to get the currently playing iTunes song.
Looking at this closely related question, I see that whenever the state of iTunes changes, it sends out a systemwide notification event named "com.apple.itunes.playerinfo" that you can register your app to listen for.

Related

iTunes has stopped updating this podcast because you have not listened to any episodes recently

iTunes has stopped updating this podcast because you have not listened to any episodes recently ...
Has anyone found a workaround for this annoyance with iTunes for the PC? I listen to podcasts with rockbox, so podcasts are never updated in iTunes, and I have to manually tell iTunes to resume updating my many podcast subscriptions.
I've read this is in-built, but perhaps some clever readers of this post have come up with a way to fool iTunes (a script temporarily changing the system date, a hack to some iTunes control file or script, etc.).
Thx.

NAudio - Detect Audio via Application

Windows Volume Mixer shows audio output for individual applications.
Using NAudio, what is the right way for me to tap into this information? I essentially want to be able to make my application say:
Always record all audio input/output. Unless otherwise specified, only keep a buffer of the last 30 seconds. Throw the test away. (I know how to do this)
When Skype, Vonage, or Ring Central plays audio for more than 5 seconds, ask the user if they want to start saving the audio. (How would I do this?)
If so, save the 30-second buffer to a file and then start recording live. (I know how to do this)
Thanks for the help!
Windows won't let you capture audio from individual applications. You can use NAudio's WasapiLoopbackCapture to capture audio from all applications.
If you just want to see audio output levels for all apps, that can be achieved with the IMMDevice APIs which NAudio has wrappers for. It doesn't come with a specific demo showing that, but there's another open source project, EarTrumpet that you could explore to see how its done.

Tracking object's location in Objective C (How to prevent program from quitting)

Let's say I wanted to track the location of my car as I drive around the city, just for kicks.
I have an old iphone 5, so I write up a little program using Parse.com framework, and using geopoints easily construct a little collection of data which I save to my cloud server. Piece of cake, right?
Well, my question is this: I put the phone on the seat after I begin to run the program. How do I ensure that the phone does not go to sleep? And what happens to my program if the app goes to sleep/quits? And how would I prevent this, if such a thing might occur?
Read about Apple's "Background Execution" abilities. A great example of this is Spotify: users can select a song, change apps, and put their phone to sleep. All the while Spotify continues to play that song.
In your case it sounds like you want location tracking, most likely using the "Significant-change location service". Using the location framework with background execution enabled will allow your application to save those geo-points to Parse at specific, distance-triggered points, even if the application is in the background or the phone's asleep.

How can my application perform a task when it is minimized or be started on certain events?

How can an application perform stuff when its actually closed like google+?
I notice that I got a notification from huddle chat from the google+ app for iOS. But google+ was actually not active, it was closed. Same situation with Whatsapp, I always get push messages both if the app is closed or active.
This kind of behaviour seems for me to be impossible to implement. From other questions I know that we cannot register some kind of background process. How do this apps handle that?
Can I still listen form something when my app is minimized?
When my app is just minimized but not closed I know that a certain method is called. Can I perform a repeating update task, e.g. read geo data?
The apps you mentioned use something called Push Notifications which work regardless of your App being open/in the background/closed. They are notifications sent to the device when an action happens and most of the processing is done on the Server (The notifications are not generated by the App itself. A server pushes the Notification on).
Apple has a fantastic section on Executing Code in the Background when your App is minimised which should provide most of the answers you need. It even has a dedicated section on explaining the Geo Data capture which should help you in this case.

task with action in background service

I've been searching an googleing over one hour now and I'm not really sure of it's legal and possible to add some tasks in an background service that triggers an action ( and bring the app to the foreground ).
With tasks i mean that the background service is doing something on an indicated time. I know its possible to bring up the IOS alert with the notifications ect... But an simple notifiction is not good enough.
Actually I wanna play an video, and if this is not possible maybe the audio ? Since bringing the app to the foreground is not possible, or is it?
What are the options?
It's not acceptable to take away the user from what they are doing, this applies to iOS since it's a one-thing at a time OS. How would you feel if an application switched to itself while you're playing, chatting or half-way reading an article?
Apple doesn't allow it, you should stick to the Notifications, and if the user truly wants to see/hear the video/audio, then he will go to your app.