• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iTunes hook
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iTunes hook


  • Subject: Re: iTunes hook
  • From: "Hiroshi T." <email@hidden>
  • Date: Sat, 5 May 2007 21:42:19 +0900

I searched the net today and found what I want:
http://schinckel.blogsome.com/2005/06/05/notification-from-applescript- studio/


Here is my main.m:
======================================================================== ==========
#import <mach-o/dyld.h>


#import <Foundation/NSDistributedNotificationCenter.h>
#import <Foundation/NSString.h>
#import <AppKit/NSAppleScriptExtensions.h>

extern int NSApplicationMain(int argc, const char *argv[]);

@interface iTunesConnection : NSObject
 - (id) init;
@end

@implementation iTunesConnection
- (id) init {
NSDistributedNotificationCenter *nc = [NSDistributedNotificationCenter defaultCenter];
[nc addObserver:self
selector:@selector(updateNow:)
name:@"com.apple.iTunes.playerInfo"
object:nil];


    return self;
}

- (void) updateNow:(NSNotification *)notification {
NSString *updateScript = [NSString stringWithFormat:@"tell application \"iTunes_Monitor\" to return itunes_hook()"
];
NSAppleScript *as = [[[NSAppleScript alloc] initWithSource:updateScript] autorelease];
[as executeAndReturnError:nil];
}
@end


int main(int argc, const char *argv[])
{
	iTunesConnection *connection;
	connection = [[iTunesConnection alloc] init];

	if (NSIsSymbolNameDefined("_ASKInitialize"))
	{
		NSSymbol *symbol = NSLookupAndBindSymbol("_ASKInitialize");
		if (symbol)
		{
			void (*initializeASKFunc)(void) = NSAddressOfSymbol(symbol);
			if (initializeASKFunc)
			{
				initializeASKFunc();
			}
		}
	}

    return NSApplicationMain(argc, argv);
}

======================================================================== ==========

You have to change the line for your own script:
@"tell application \"iTunes_Monitor\" to return itunes_hook()"

It remains to be checked if selective notification catch is possible.

---
H.T.
Any mail that does not come from this mailing list is ignored.



On May 14, 2006, at 12:15 AM, Walter Bushell wrote:

Does anyone know how to capture this notification and could they tell me?

On May 12, 2006, at 2:01 PM, email@hidden wrote:

I do believe that from iTunes 4.7 onwards you don't need to poll iTunes for the status - it gives out a notification of when the song changes. This is how apps like butler, etc can display the song changing when it does, with no polling of iTunes.

Caius
________________________

Caius Durling
College Student (UK)

tel:          +447738678832
email:        email@hidden
web:                http://caius.name/
________________________


On 12 May 2006, at 16:04, Daniel Jalkut wrote:

Hiroshi - I think you may have to write a "visualizer" or other plug-in to achieve this kind of behavior in a non-polling way. Doing this is probably against the license agreement for developing such plugins, but it might be worth looking into, especially if you're just going to use it for personal stuff.

There is one pretty fancy EQ I saw as a plugin for iTunes that I believe does things along those lines. Can't recall the name now.

Daniel

On May 12, 2006, at 2:17 AM, Hiroshi T. wrote:

Hello!
Are there anyway to execute an Applescript at the beginning of every song
that is being played by iTunes?


What I want to do is to issue commands to hardware equalizer (de-emphasis filter)
according to the comment column of every song being played.
iTunes' 'equalizer column' is not enough for me.


I'd like to avoid daemon-like Applescript that checks iTunes status every minute.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden




-- 
"Rational thought imposes a limit on a person's concept of his relation to the cosmos."  --- John Nash


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden




_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Re: It was two years ago
  • Next by Date: Re: How to burn a folder to DVD(s)?
  • Previous by thread: How to convert a MAC text file to PC encoding?
  • Next by thread: PDF File says in use by Mac OS X
  • Index(es):
    • Date
    • Thread