Iphone 一起播放.mp3文件的两个循环
在iphone sdk中有没有办法一起播放声音文件的2个循环 谢谢和问候 shwetaIphone 一起播放.mp3文件的两个循环,iphone,ios,Iphone,Ios,在iphone sdk中有没有办法一起播放声音文件的2个循环 谢谢和问候 shweta#导入 #进口 @接口MultiAVPlay:NSObject{ AVAudioPlayer*myplayer; NSArray*文件名; int ind; } @属性(非原子,保留)AVAudioPlayer*myplayer; @属性(非原子,保留)NSArray*文件名; -(id)initWithFileNameQueue:(NSArray*)名称; -(无效)AudioPlayerDifinishPl
#导入
#进口
@接口MultiAVPlay:NSObject{
AVAudioPlayer*myplayer;
NSArray*文件名;
int ind;
}
@属性(非原子,保留)AVAudioPlayer*myplayer;
@属性(非原子,保留)NSArray*文件名;
-(id)initWithFileNameQueue:(NSArray*)名称;
-(无效)AudioPlayerDifinishPlaying:(AVAudioPlayer*)播放器成功:(BOOL)标志;
-(void)play:(int)i;
-(无效)停止;
@结束
#导入“MultiAVPlay.h”
@多视频播放的实现
@合成myplayer,文件名;
-(id)initWithFileNameQueue:(NSArray*)文件{
if((self=[super init])){
self.fileNames=文件;
指数=0;
[自我游戏:索引];
}
回归自我;
}
-(无效)AudioPlayerDifinishPlaying:(AVAudioPlayer*)玩家成功:(BOOL)标志{
if(索引
#导入
#进口
@接口MultiAVPlay:NSObject{
AVAudioPlayer*myplayer;
NSArray*文件名;
int ind;
}
@属性(非原子,保留)AVAudioPlayer*myplayer;
@属性(非原子,保留)NSArray*文件名;
-(id)initWithFileNameQueue:(NSArray*)名称;
-(无效)AudioPlayerDifinishPlaying:(AVAudioPlayer*)播放器成功:(BOOL)标志;
-(void)play:(int)i;
-(无效)停止;
@结束
#导入“MultiAVPlay.h”
@多视频播放的实现
@合成myplayer,文件名;
-(id)initWithFileNameQueue:(NSArray*)文件{
if((self=[super init])){
self.fileNames=文件;
指数=0;
[自我游戏:索引];
}
回归自我;
}
-(无效)AudioPlayerDifinishPlaying:(AVAudioPlayer*)玩家成功:(BOOL)标志{
if(索引
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
@interface MultiAVPlay : NSObject <AVAudioPlayerDelegate> {
AVAudioPlayer* myplayer;
NSArray* fileNames;
int ind;
}
@property (nonatomic, retain) AVAudioPlayer* myplayer;
@property (nonatomic, retain) NSArray* fileNames;
- (id)initWithFileNameQueue:(NSArray*)names;
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag;
- (void)play:(int)i;
- (void)stop;
@end
#import "MultiAVPlay.h"
@implementation MultiAVPlay
@synthesize myplayer, fileNames;
- (id)initWithFileNameQueue:(NSArray*)files {
if ((self = [super init])) {
self.fileNames = files;
index = 0;
[self play:index];
}
return self;
}
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {
if (index < fileNames.count) {
[self playMp3:index];
} else {
//reached end of queue
}
}
- (void)playMp3:(int)i {
self.myplayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:[fileNames objectAtIndex:i] ofType:nil]] error:nil];
[myplayer release];
myplayer.delegate = self;
[myplayer prepareToPlay];
[myplayer play];
index++;
}
- (void)stop {
if (self.myplayer.playing) [myplayer stop];
}
- (void)dealloc {
self.filenames = nil;
self.myplayer = nil;
[super dealloc];
}
@end