0

我是 iphone 开发的新手(Xcode 中的第 4 天),我正在尝试实现 AvAudioPlayer 并使用 AwesomeMenu 库控制它。我初始化和播放音频没有问题,但是当我尝试通过很棒的菜单控件暂停或停止音频时,AVAudioPlayer 没有响应。任何帮助是极大的赞赏。

编辑

我能够确定我的方法没有在其中执行条件 if/else 语句。这更莫名其妙。didSelectIndex 正在触发,但内部的 if 语句不是。我是否正确编码了我的条件语句?

我的代码:

AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
podcastPlayer = [[AVPlayer playerWithPlayerItem:playerItem] retain];
[podcastPlayer play];

//Control for AvAudioPlayer

- (void)AwesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx{
if (idx==0) {
    if(!podcastPlayer.isPlaying){
        podcastPlayer.play;
    }

}else if(idx==1){
    if(podcastPlayer.isPlaying){
        podcastPlayer.pause;
    }

}else if(idx==2){
    if(podcastPlayer.isPlaying){
        podcastPlayer.stop;
        podcastPlayer.release;

        GSCCAppDelegate *appDelegate = (GSCCAppDelegate *)[[UIApplication sharedApplication] delegate];

        [appDelegate.menu removeFromSuperview];

    }

}else if(idx==3){


}else if(idx==4){

}else if(idx==5){

}

NSLog(@"Select the index : %d",idx);
}

编辑

- (void)AwesomeMenu:(AwesomeMenu *)menu didSelectIndex:(NSInteger)idx{
if (idx==0) {

    NSLog(@"Index 0"); //Doesn't work

}else if(idx==1){

    NSLog(@"Index 1"); //Doesn't work

}

}

NSLog(@"Select the index : %d",idx); //<--This Works.

}

4

1 回答 1

0

声明AVPlayerItem *playerItem为 apropertysynthesis它。

不要声明为本地人

于 2013-03-13T21:46:15.490 回答