我想暂停这首歌,然后在 iPhone 中使用编程方式从该持续时间点继续播放。当我尝试暂停歌曲并再次开始播放我暂停的歌曲时。如何对其进行编码。是否有任何直接属性或建议任何代码可以解决我的问题。
-(void)playMusic
{
path=[[NSBundle mainBundle]pathForResource:@"01my song here" ofType:@"mp3"];
AVAudioPlayer *myAudio=[[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:path ] error:nil];
self.audioPlayer=myAudio;
[myAudio release];
//audioPlayer.playing ;
[audioPlayer play];
}
-(void)stopMusic
{
[audioPlayer stop];
}
-(void)pauseMusic
{
[audioPlayer pause];// here it is just stopping, how can I start where I sttoped.
}
谢谢你,
马丹·莫汉。
if(!player){
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
resourcePath = [resourcePath stringByAppendingString:@"/grabbag.m4a"];
NSLog(@"Path to play: %@", resourcePath);
NSError* err;
//Initialize our player pointing to the path to our resource
player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:resourcePath] error:&err];
if( err ){
//bail!
NSLog(@"Failed with reason: %@", [err localizedDescription]);
}
else{
//set our delegate, flip the button and let the magic happen
player.delegate = self;
[self flipButton:YES];
[player play];
}
}
else{
//If the player exists here, then we're already playing.
NSLog(@"Resuming playback!");
[player play];
[self flipButton:YES];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)