简体   繁体   English

如何创建音频歌曲的播放列表

[英]how to create playlist of audio songs

我正在创建一个下载应用程序,其中我在应用程序内的不同文件夹中有多个音频文件,我想创建音频歌曲的播放列表。我不知道从哪里开始。目前正在使用avaudio播放器。

try this 尝试这个

NSArray *array = [[NSMutableArray alloc]init ];
[array insertObject: [[NSString alloc] initWithFormat:[[NSBundle mainBundle] pathForResource:@"firstTrack" ofType:@"mp3"]] atIndex:0];
[array insertObject:[[NSString alloc] initWithFormat: [[NSBundle mainBundle] pathForResource:@"secondTrack" ofType:@"mp3"]] atIndex:1];
[array insertObject:[[NSString alloc] initWithFormat: [[NSBundle mainBundle] pathForResource:@"thirdTrack" ofType:@"mp3"]] atIndex:2];
[array insertObject:[[NSString alloc] initWithFormat: [[NSBundle mainBundle] pathForResource:@"forthTrack" ofType:@"mp3"]] atIndex:3];

then in the player: 然后在播放器中:

    path = [array objectAtIndex:currentTrack];

or use this: 或使用此:

path=[[NSBundle mainBundle] pathForResource:@"sounds" ofType:@"plist"];
dict=[NSDictionary dictionaryWithContentsOfFile:path];

animalaudio=[dict valueForKey:@"audio"];
  audiolist=[animalaudio objectAtIndex:currentsound];
NSLog(@"audiolist:%@",audiolist);
url=[NSURL fileURLWithPath:audiolist];
NSLog(@"url:%@",url);
 audioplayer=[[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
NSLog(@"audioplayer:%@",audioplayer);
 if( audioplayer == nil ){

    NSLog(@"Failed with reason: %@", [error localizedDescription]);
}
else{
    [audioplayer play];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 核心数据:如何创建播放列表并从数据库添加歌曲? - Core data: How do I create playlist and add songs from a database? 如何在phonegap中创建和管理播放列表? (音频/视频文件) - How can I create and manage playlist in phonegap? (audio/Video files) 如何在iPhone中创建本地歌曲应用程序? - How to create a local songs application in iPhone ? 音频分析仪,用于查找歌曲音高 - Audio analyzer for finding songs pitch 音频压缩不适用于Itunes Songs - Audio compression is not working for Itunes Songs 想要通过使用“ .plist”文件动态创建音频播放列表,然后要在内置音频播放器的iphone中播放它 - want to create an audio playlist dynamically by using “.plist” file an then want to play it in iphone in built audio player 如何在Ipod中创建可编辑列表,例如播放列表? - How to create a editable list like the playlist in Ipod? 在iOS中使用AVAudioPlayer和MPMusicPlayerController在歌曲播放列表中添加渐变效果 - Add fading effect in songs playlist using AVAudioPlayer and MPMusicPlayerController in ios 如何依次播放放置在iPhone资源文件夹中的音频歌曲 - How to play audio songs one after other which is placed in resources folder in iphone 如何从我的App将歌曲/音频文件保存到iPhone设备iTunes? - How can I save songs/audio files to iPhone device iTunes from my App?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM