1
我想從ImagePickerController的照片庫中取最大30秒的特定視頻。獲取接收內存警告?
當我收到URL後,我打算在第二個視圖中播放AVPlayer中選定的視頻。
我收到「收到的內存警告」。和 「」 連接到assetsd中斷或assetsd死了」。
如何解決這個問題?有人可以幫我嗎?
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *videoURL= [info objectForKey:UIImagePickerControllerMediaURL];
NSURL *url = [info objectForKey:UIImagePickerControllerMediaURL];
AVAsset *asset = [AVAsset assetWithURL:url];
[picker dismissViewControllerAnimated:YES completion:^{
Edition *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"EditionVC"];
vc.videoUrl=videoURL;
vc.asset=asset;
[self presentViewController:vc animated:YES completion:nil];
}];
}
在第二視圖中播放視頻。
self.avPlayerItem = [AVPlayerItem playerItemWithURL:self.videoUrl];
self.avPlayer = [AVPlayer playerWithPlayerItem:self.avPlayerItem];
[self.avPlayer play];
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidPlayToEndTime:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:self.avPlayerItem];
你是如何解決這個問題的? – abhi1992
我爲視頻設置了較低的質量。 'picker.videoQuality = UIImagePickerControllerQualityTypeIFrame1280x720;' –