如何使用 AVAudioPlayer 在 iPhone sdk 中暂停和恢复同一首歌曲
我想暂停这首歌,然后在 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.
}
谢谢你, 马丹·莫汉。
I want to pause the song and continue from that point of duration in iphone using programmatic-ally. When I tried to pause the song and again I want to start to play the song where I paused. How it can be coded. Is there any direct properties or suggest any code to that may solve my problem.
-(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.
}
Thank you,
Madan Mohan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)