iTunes song queue

被刻印的时光 ゝ 提交于 2019-12-11 04:37:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!