开发者

Doing a music player app! previous and next track

How can I make a app to iphone without using ipod library, and doing the next song and the previous song??

I think the best way is doing an array with the songs, but I don't know how to do. Someone can helps me??

My app is working, with pause, play, current time and volume slider... but this part of next song I really don't know!

- (void)viewDidLoad {

    //initialize string to the path of the song in the resource folder
    NSString *myMusic = [[NSBundle mainBundle]pathForResource:@"gastando" ofType:@"mp3"];
    player = [[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:myMusic] error:NULL];
    player.numberOfLoops开发者_如何学编程 = 0;
    player.volume = slider.value;
    timeSlider.maximumValue = player.duration;

    timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(timeLoader) userInfo:nil repeats:YES];

    [super viewDidLoad];        
}


    MPMusicPlayerController *musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
    //get all media
    MPMediaQuery *everything = [[MPMediaQuery alloc] init];
    //empty song list
    NSMutableArray *songList = [[NSMutableArray alloc] init ];

    for (int i = 0 ; i < [[everything items] count] ; i++){
        MPMediaItem *media = (MPMediaItem*)[[everything items] objectAtIndex:i];

        NSInteger mediaType = [[media valueForProperty:MPMediaItemPropertyMediaType] intValue];
        //only want audio
        if (mediaType <= MPMediaTypeAnyAudio) {
            [songList addObject:media];
        }
    }
    //create music collection out of it
    MPMediaItemCollection *musicCollection = [MPMediaItemCollection collectionWithItems:songList];
    //set the playlist
    [musicPlayer setQueueWithItemCollection:musicCollection];
    [everything release];
    [songList release];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜