问题
My app is controlling iTunes via scripting bridge. Other apps are able to choose a range of songs, and play them in order without having to create a playlist. I have searched the web for examples and red the iTunes.h file a dozen times, but I didn't find a solution. Can maybe someone of you help me?
Look at the iTunes header file here: iTunes.h
Thanks!
回答1:
With iTunes 10 it's simply not possible without creating a playlist. The function(which is a known from great other music players) you are talking about is coming in iTunes 11, which will be out in October. It's called next. I think just wait a few weeks and then the details will be out how to do it programmatically
回答2:
You can keep track of the songs in your own app and the when you start playing the first song, set a timer to fire at the finishTime of the track you started playing. When the timer fires start playing the next song and repeat the timer. If there are no songs to play end with a stop command to iTunes.
@property (retain, nonatomic) NSMutableArray *songsToPlay;
- (void)playNext:(NSTimer *)aTimer {
if (songsToPlay.count) {
iTunesTrack *track = songsToPlay.firstObject;
[track playOnce:YES];
[NSTimer scheduledTimerWithTimeInterval:track.finish - 1.0 target:self selector:@selector(playNext:) userInfo:nil repeats:NO];
[songsToPlay removeObjectAtIndex:0];
}
else {
[iTunes stop];
}
}
Somewhere you prime songToPlay
with iTunesTrack songs and then call [self playNext:nil]
.
来源:https://stackoverflow.com/questions/12538855/itunes-song-queue