这是我用于播放视频的代码, 我需要在点击按钮时停止视频,但它会抛出EXC_BAD_ACCESS异常,我在日志中收到以下消息
发送到已解除分配的实例的消息
-(void) getallData{
NSString * video=[dict valueForKey:@"abc"];
NSString *strvideo = [NSString stringWithFormat:@"%@XXXX/XXX/%@",appDelegate.baseURL,video];
NSURL *fileURL = [NSURL URLWithString: strvideo];
avPlayer = [AVPlayer playerWithURL:fileURL];
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
avPlayerLayer.frame = CGRectMake(2, 45, 724, 450);
[self.view.layer addSublayer:avplayerLayer];
[viewObj.layer addSublayer:avPlayerLayer];
[avPlayer play];
}
-(IBAction)btnBackClick:(id)sender
{
//I need to stop video here
[avPlayer pause];
}