【发布时间】:2015-01-05 07:26:45
【问题描述】:
我在我的项目中被困在 AVAudioPlayer。情况是, 在 CollectionViewController 的“didSelectItemAtIndexPath”方法中,我像下面这样分配和初始化 AVAudioPlayer,
dict=[plist objectAtIndex:indexPath.item];
NSURL* urlPath=[NSURL new];
urlPath=[NSURL URLWithString:[dict objectForKey:@"FilePath"]];
NSError *error = nil;
self.player=[[AVAudioPlayer alloc]initWithContentsOfURL:urlPath error:&error];
NSLog(@"Error[%@]",[error localizedDescription]);
[self.player setDelegate:self];
[self.player prepareToPlay];
但在此之后,它仍然是空的.. 首先,我尝试不让玩家拥有财产。但没有运气.... 所以我尝试使用this
【问题讨论】:
-
你有没有仔细检查 urlPath 不为零?
-
@WorldOfWarcraft "urlPath" 不为零..
-
你把你的代码放在
didSelectItemAtIndexPath,这意味着播放器只有在你选择的时候才会启动。 -
在此处发布您的代码。
标签: objective-c iphone ios8 xcode6 avaudioplayer