步骤获得所有可用的音乐文件阵列在iPhone Rington制造商应用程序的iPhone



我正在创建一个rington maker应用程序。在第一步中,我需要在单击按钮的同时从iTunes应用程序中获得所有可用歌曲的列表。我该怎么做?

您可以从应用程序获取所有文件。像这样的捆绑

NSMutableArray *ArrlistOfSounds = [[NSMutableArray alloc] init];
NSString *bundleRoot = [[NSBundle mainBundle] bundlePath];
    NSError *err;
    NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:&err];
    for (NSString *tString in dirContents) {
        if ([tString hasSuffix:@".wav"] || [tString hasSuffix:@".mp3"]) // you can also add/remove file extension as per your requirement.
        {
            /// here you can get .wav and .mp3 file from you app. bundle and add it to Array (ArrlistOfSounds)
            [ArrlistOfSounds addObject:tString];
        }
    }
NSLog(@"%@", ArrlistOfSounds);

在你的UIButton's方法中写出上面的全部代码;

最新更新