Newbie can't integrate with iTunes
Moderators: winston, another_commander
Newbie can't integrate with iTunes
Hi,
Just installed the game, getting to know the commands and the like, but cannot for the life of me get the game to integrate with iTunes. I have the 3 suggested playlists created and populated with songs, iTunes open, Oolite open, no sound. The reference suggests i/tunes integration should be switched 'ON', but i cannot find this in the options, only a toggle for Music.
Running Snow Leopard on iMac, Oolite 1.73.4
Any help gratefully received.
Just installed the game, getting to know the commands and the like, but cannot for the life of me get the game to integrate with iTunes. I have the 3 suggested playlists created and populated with songs, iTunes open, Oolite open, no sound. The reference suggests i/tunes integration should be switched 'ON', but i cannot find this in the options, only a toggle for Music.
Running Snow Leopard on iMac, Oolite 1.73.4
Any help gratefully received.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
The Music switch has three settings (under Mac OS X): Off, On and iTunes. (Although switching to iTunes freezes it for several seconds under Snow Leopard, I just discovered.)
E-mail: [email protected]
Re: Newbie can't integrate with iTunes
Did anything change meanwhile? I can't get it to work at all.
I have three playlists that worked before - Oolite-Docked, Oolite-Docking and Oolite-Inflight - and I'm trying it with vanilla Oolite in case an OXP breaks it. Music is set to iTunes, I quit iTunes and started it in case something like a half-played song stops the integration from working.
Oolite 1.77
iTune 11.0.2 (26)
Mac OS X 10.8.2
Here's what I find in the log about it:
I have three playlists that worked before - Oolite-Docked, Oolite-Docking and Oolite-Inflight - and I'm trying it with vanilla Oolite in case an OXP breaks it. Music is set to iTunes, I quit iTunes and started it in case something like a half-played song stops the integration from working.
Oolite 1.77
iTune 11.0.2 (26)
Mac OS X 10.8.2
Here's what I find in the log about it:
14:08:24.867 [sound.music.iTunesIntegration.failed]: ootunes returned :{
NSAppleScriptErrorAppName = iTunes;
NSAppleScriptErrorBriefMessage = "Can\U2019t set song repeat of user playlist id 44877 of source id 73 to all.";
NSAppleScriptErrorMessage = "iTunes got an error: Can\U2019t set song repeat of user playlist id 44877 of source id 73 to all.";
NSAppleScriptErrorNumber = "-10006";
NSAppleScriptErrorRange = "NSRange: {157, 37}";
- JazHaz
- ---- E L I T E ----
- Posts: 2991
- Joined: Tue Sep 22, 2009 11:07 am
- Location: Enfield, Middlesex
- Contact:
Re: Newbie can't integrate with iTunes
Is there any chance of getting iTunes integration for Windows users?
JazHaz
Thanks to Gimi, I got an eBook in my inbox tonight (31st May 2014 - Release of Elite Reclamation)!Gimi wrote:Maybe you could start a Kickstarter Campaign to found your £4500 pledge.drew wrote:£4,500 though! <Faints>
Cheers,
Drew.
Re: Newbie can't integrate with iTunes
I dunno... integration in apple probably runs an applescript to communicate with iTunes, so unlikely. Unless I'm wrongJazHaz wrote:Is there any chance of getting iTunes integration for Windows users?
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
Same in my log with Oolite 1.77 and OSX 10.6:Corny wrote:Did anything change meanwhile? I can't get it to work at all.
Oolite 1.77
iTune 11.0.2 (26)
Mac OS X 10.8.2
Code: Select all
[sound.music.iTunesIntegration.failed]: ootunes returned :{
NSAppleScriptErrorAppName = iTunes;
NSAppleScriptErrorBriefMessage = "AppleEvent timed out.";
NSAppleScriptErrorMessage = "iTunes got an error: AppleEvent timed out.";
NSAppleScriptErrorNumber = "-1712";
NSAppleScriptErrorRange = "NSRange: {68, 26}";
}
[sound.music.iTunesIntegration.failed]: ootunes returned :{
NSAppleScriptErrorAppName = iTunes;
NSAppleScriptErrorBriefMessage = "Can\U2019t set song repeat of user playlist id 1821 of source id 73 to all.";
NSAppleScriptErrorMessage = "iTunes got an error: Can\U2019t set song repeat of user playlist id 1821 of source id 73 to all.";
NSAppleScriptErrorNumber = "-10006";
NSAppleScriptErrorRange = "NSRange: {157, 37}";
}
EDIT:
I get the same errors in the log with Oolite 1.74. With that version, I am sure it always worked. Meaning that the problem is iTunes 11 that is no longer accepting the old commands.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
Any AppleScript experts on board? The whole current code used by Oolite is:
Code: Select all
- (void) playiTunesPlaylist:(NSString *)playlistName
{
NSString *ootunesScriptString =
[NSString stringWithFormat:
@"with timeout of 1 second\n"
" tell application \"iTunes\"\n"
" copy playlist \"%@\" to thePlaylist\n"
" if thePlaylist exists then\n"
" set song repeat of thePlaylist to all\n"
" set shuffle of thePlaylist to true\n"
" play some track of thePlaylist\n"
" end if\n"
" end tell\n"
"end timeout",
playlistName];
NSAppleScript *ootunesScript = [[[NSAppleScript alloc] initWithSource:ootunesScriptString] autorelease];
NSDictionary *errDict = nil;
[ootunesScript executeAndReturnError:&errDict];
if (errDict)
OOLog(@"sound.music.iTunesIntegration.failed", @"ootunes returned :%@", errDict);
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
It is probably 20 Years ago that I tried to write something in AppleScript. Above code reads in short:
But when executing in the AppleScipt editor I get:
It goes wrong with the 'all' parameter. But when opening the iTunes library I see:
So it seems a correct syntax, and always was with iTunes. I know to little off AppleScript to see if this is a change of syntax, or simply a bug in iTunes itself. Any takers?
Code: Select all
tell application "iTunes"
copy playlist "Oolite-Docked" to thePlaylist
if thePlaylist exists then
set song repeat of thePlaylist to all
set shuffle of thePlaylist to true
play some track of thePlaylist
end if
end tell
Code: Select all
tell application "iTunes"
get playlist "Oolite-Docked"
--> user playlist id 1789 of source id 72
exists user playlist id 1789 of source id 72
--> true
set song repeat of user playlist id 1789 of source id 72 to all
--> error number -1708
Resultaat:
error "iTunes kreeg een fout: song repeat of user playlist id 1789 of source id 72 kan niet worden ingesteld op all." number -10006 from song repeat of user playlist id 1789 of source id 72
Code: Select all
song repeat (off/one/all) : playback repeat mode
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Re: Newbie can't integrate with iTunes
In OOMusicController.m the code:-
throws errors but this could be changed to something like:-
Which works (although it requires access for assistive devices to be enables in system preferences )
Recompile using Xcode and use result instead of existing Oolite.app.
Code: Select all
NSString *ootunesScriptString =
[NSString stringWithFormat:
@"with timeout of 1 second\n"
" tell application \"iTunes\"\n"
" copy playlist \"%@\" to thePlaylist\n"
" if thePlaylist exists then\n"
" set song repeat of thePlaylist to all\n"
" set shuffle of thePlaylist to true\n"
" play some track of thePlaylist\n"
" end if\n"
" end tell\n"
"end timeout",
playlistName];
Code: Select all
[NSString stringWithFormat:
@"with timeout of 1 second\n"
" tell application \"iTunes\"\n"
" stop\n"
" copy \"%@\" to ThePlayList\n"
" if playlist ThePlayList exists then\n"
" play playlist ThePlayList\n"
" tell application \"System Events\" to tell process \"iTunes\"\'s menu bar 1\'s menu bar item \"Controls\"\'s menu 1\'s menu item \"Repeat\"\'s menu 1\n"
" perform action \"AXPress\" of menu item \"All\"\n"
" end tell\n"
" else\n"
" set newalias to location of some track of playlist 1\n"
" set newlist to make new playlist\n"
" set name of newlist to ThePlayList\n"
" tell application \"System Events\" to tell process \"iTunes\"\'s menu bar 1\'s menu bar item \"Controls\"\'s menu 1\'s menu item \"Repeat\"\'s menu 1\n"
" perform action \"AXPress\" of menu item \"All\"\n"
" end tell\n"
" tell application \"System Events\" to perform action \"AXPress\" of (first menu item of process \"iTunes\"\'s menu bar 1\'s menu bar item \"Controls\"\'s menu 1\'s menu item \"Shuffle\"\'s menu 1 whose name ends with \"Shuffle\")\n"
" add newalias to newlist\n"
" play newlist\n"
" end if\n"
" end tell\n"
"end timeout",
playlistName];
Recompile using Xcode and use result instead of existing Oolite.app.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
megangel1, thanks for the code. I haven't played, nor compiled Oolite for a long time.
Today I added your code to my source and Oolite can use I-Tunes integration again. And as you say, it asks for permission, but it will be quite clear for end-users what to change in the System preferences to give permanent permission.
But, although it now works, it still throws an error in the log:
Today I added your code to my source and Oolite can use I-Tunes integration again. And as you say, it asks for permission, but it will be quite clear for end-users what to change in the System preferences to give permanent permission.
But, although it now works, it still throws an error in the log:
Code: Select all
16:26:53.003 [sound.music.iTunesIntegration.failed] OOMusicController.m:387: ootunes returned :{
NSAppleScriptErrorAppName = "System Events";
NSAppleScriptErrorBriefMessage = "AppleEvent timed out.";
NSAppleScriptErrorMessage = "System Events got an error: AppleEvent timed out.";
NSAppleScriptErrorNumber = "-1712";
NSAppleScriptErrorRange = "NSRange: {297, 47}";
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
Interesting. With a timeout of 5 seconds,I get the same errors in the log.
But setting the timeout to 30 seconds , I find in the log:
So, that is the reason for the time-out. An error in Dutch, meaning Oolite has no access to assistive devices. Even when I see in the preferences that access is granted.
But setting the timeout to 30 seconds , I find in the log:
Code: Select all
16:38:58.189 [sound.music.iTunesIntegration.failed] OOMusicController.m:387: ootunes returned :{
NSAppleScriptErrorAppName = "System Events";
NSAppleScriptErrorBriefMessage = "Oolite heeft geen toegang voor hulpapparaten.";
NSAppleScriptErrorMessage = "System Events got an error: Oolite heeft geen toegang voor hulpapparaten.";
NSAppleScriptErrorNumber = "-1719";
NSAppleScriptErrorRange = "NSRange: {296, 47}";
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
Now I know why the script of megangel1 is still throwing errors. Selecting menu-items of iTunes by name is language specific. When replacing "Controls" with "Regelaars" and "Turn On Shuffle" by "Schakel shuffle in", Oolite stops throwing errors and really turns on the shuffling option. But this is not a useful method if it is language sensitive.
A bit of googling gives a lots of hits, telling that the "Shuffle" and "Repeat" commands are removed from iTunes 11. And all come up with a variation of the script that uses the language dependent method that megangel1 gives. I could not find an official replacement if these functions. But looking in the apple script library, both methods should still be possible. Bug in iTunes 11?
Anyhow, just removing the two lines in the original script that set shuffle and repeat, makes that the scrips works again in Oolite. Not being able to set shuffle and repeat is not a big problem. iTines will now use the last settings for those.
A bit of googling gives a lots of hits, telling that the "Shuffle" and "Repeat" commands are removed from iTunes 11. And all come up with a variation of the script that uses the language dependent method that megangel1 gives. I could not find an official replacement if these functions. But looking in the apple script library, both methods should still be possible. Bug in iTunes 11?
Anyhow, just removing the two lines in the original script that set shuffle and repeat, makes that the scrips works again in Oolite. Not being able to set shuffle and repeat is not a big problem. iTines will now use the last settings for those.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Diziet Sma
- ---- E L I T E ----
- Posts: 6312
- Joined: Mon Apr 06, 2009 12:20 pm
- Location: Aboard the Pitviper S.E. "Blackwidow"
Re: Newbie can't integrate with iTunes
So Apple have language-specific commands hard-coded into different versions of iTunes? Talk about a brain-dead move.
Coming on top of the "goto bug" security hole, I guess this really does show that some of their programmers are still stuck in the '80s.
(sorry if this comes across as Apple-bashing, but seriously.. such sloppy coding practice in this day and age is ridiculous)
Coming on top of the "goto bug" security hole, I guess this really does show that some of their programmers are still stuck in the '80s.
(sorry if this comes across as Apple-bashing, but seriously.. such sloppy coding practice in this day and age is ridiculous)
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Newbie can't integrate with iTunes
It is not Apple doing that. Two functions are removed from the iTunes library (at least are not working) and scripters are replacing that by a method were the system is instructed to activate specific menu items. They just choose to do it by name instead by position in the menu. They just use the hardcoded name instead of position because it is easier to remember. And because 90% of the demoscripts you see around do it in that way.Diziet Sma wrote:So Apple have language-specific commands hard-coded into different versions of iTunes?
I'm not familiar with Apple Script, but think that there must be a more sensible method.
UPS-Courier & DeepSpacePirates & others at the box and some older versions