Get current playing song using Cocoa - cocoa

Is there a way (ofcourse there is a way, but which way) to get info about the song currently playing in iTunes on a Mac (OS 10.5.8 and OS 10.6) programmatically?
I need this for my Cocoa application.
I use iTunes 8 and Objective-C.

Use the Scripting Bridge to ask iTunes. iTunes is even the example that the docs use.

Related

Add Apple Music track to iTunes on OSX

As per this article, it is now possible for third party apps running on iOS 9.3 to add Apple Music track to a user's playlist.
Is there something similar on the latest OSX?

AVKit in OSX 10.8

We're developing an OSX app that have to be supported by OSX 10.7 to 10.9. We're currently using QTKit and QTMovieView to show videos, but when trying to upload a new version recently we got this error message:
Deprecated API usage. Apple no longer accepts submissions of apps that use QuickTime APIs.
We have also tested to set the Base SDK to 10.8, but same result there.
And changing to AVKit and AVPlayerView does not work for version prior to 10.9.
So is there a way to use AVKit for versions prior to 10.9 or some way to publish an app with QTKit?
You can't use AVKit on OS X versions prior to Mavericks.
But AVKit is a very small framework that only consists of a player view that has some advanced features out of the box (e.g. chapter navigation, selection & trimming, ... - similar to QTMovieView).
If your app doesn't require those features, you can easily implement a view with simple playback functionality with AVFoundation-only classes (AVFoundation was introduced with OS X 10.7).
Instead of AVPlayerView, you can use a combination of AVPlayer & AVPlayerLayer.
There is some Apple sample code that shows how to build a DIY player view here:
https://developer.apple.com/library/mac/samplecode/AVSimplePlayerOSX/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011060
This custom player view supports:
Play/Pause
Rewind
Playback progress
Fast forward
Volume control

Pass NSWindow from Apple script to Cocoa

In my Cocoa app, I need to refer to another window. After searching about it a bit, it looks like that I need to use Apple scripts to do that. My question is that can I return the window of another app as a NSWindow from the Apple script to my Mac app. I've seen some Apple script samples, but not sure how to pass a value from the Apple script to the Cocoa app.
(We have a Mac touchscreen bought recently and there, in order for the touches to get detected in my unity app (through the SDK given for the Touch screen), I need to get that Unity Window and pass it to the touchscreen methods. I'm totally new to Mac development, so I can't figure out how I can pass another Window as a NSWindow to the touchscreen SDK)

How do I write an Applescript for iTunes to find iPhone apps?

How can I write with AppleScript an action to search for any iPhone app (for example Facebook) in iTunes and download it to my computer?

AirPlay Meta Data on Apple TV from Mac App

I am using the class MPNowPlayingInfoCenter to set a song's meta data in an iOS app. How do I set it in an OS X app?
Before Mountain Lion (OS X 10.8), there was no official 3rd party support for AirPlay, although iTunes has integrated it for a long time.
Mountain Lion added a control to allow the user to choose the audio output. However, this happens outside of your app and there are still no public APIs to control AirPlay.
There are several 3rd party implementations of AirPlay. The most famous being AirFoil. They have a public API to display metadata. However, it relies on AppleScript, which doesn't work with the new App Store sandbox.
This is the big picture. Feel free to ask more if you need clarifications.

Resources