0
내 사운드를 재생할 때 AVAudioPlayer를 사용하면 배경 음악 플레이어가 중지되고 내 사운드가 음악 플레이어를 마쳤을 때 음악 플레이어를 다시 시작할 수 있습니까?xcode에서 내 앱에서 사운드를 재생 한 후 뮤직 플레이어를 다시 시작하는 방법
내 사운드를 재생할 때 AVAudioPlayer를 사용하면 배경 음악 플레이어가 중지되고 내 사운드가 음악 플레이어를 마쳤을 때 음악 플레이어를 다시 시작할 수 있습니까?xcode에서 내 앱에서 사운드를 재생 한 후 뮤직 플레이어를 다시 시작하는 방법
#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController() <AVAudioPlayerDelegate>
@property (nonatomic, strong) AVAudioPlayer *audioPlayer;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"ttt" ofType:@"mp3"]] error:nil];
_audioPlayer.delegate = self;
}
- (void)play:(id)sender
{
[_audioPlayer play];
}
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag
{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *error = nil;
if (![audioSession setActive:NO withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation error:&error]) {
NSLog(@"resume music player failed, error=%@", error);
}
}
@end
나는 그것이 오래되었음을 알고 있지만, 정말 고마워, 정말 도와 줬어! – PaulRBerg
음악 플레이어 또는 원주민 플레이어가 있습니까? – Retro
기본 음악 플레이어 응용 프로그램 – user1899125
이 당신에게 도움이 될 수 http://stackoverflow.com/questions/5549756/how-to-pause-and-resume-same-song-in-iphone-sdk-using-avaudioplayer –