Tag: avplayerlayer

从UITableViewCell上的多个AVPlayerItem中添加和删除观察者

我试图做一个表视图播放多个videoAVPlayer和AVPlayerItem ,我需要addObserver到每个AVPlayerItem所以我可以跟踪playbackLikelyToKeepUp属性 我试过和失败的是在设置AVPlayerItem之后添加观察者,并在UITableViewCell的deinit中删除它,但由于单元格永远不会被释放,但得到出列所以这将无法正常工作,我会得到这个错误 An instance 0x14eedebc0 of class AVPlayerItem was deallocated while key value observers were still registered with it. search后,我想出了这个 我不应该在UITableViewCell上添加或删除观察者,但我必须因为播放器项目是在单元格子类 处理观察者的最好方法是在'UITableViewDelegate'方法中 在willDisplayCell添加并在willDisplayCell移除 但即使这不起作用,因为AVPlayerItem需要时间来初始化 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! TableViewCell cell.setUpPLayer() return cell } override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath […]

在collections视图单元中播放video,例如在Facebook应用时间轴中播放的video

我想在collections视图单元格中播放video,需求就像instagram时间线,播放video就像在Facebook时间线上播放video一样, 为此我使用了UICollectionViewCell巫婆我现在有一些图像没有video我是从画廊的图像,我正在使用相机拍摄的图像,我正在录制的video,每次我会有任何一个从上面出来,把我有添加到时间线。 例如,我们采取3vc第一个vc是有一些图像收集视图,我第二个vc我们得到的输出要么是video,图像,我正在把图像和图像的第一帧中的共同数组是在从VC3的VC3中,我将数组和输出videopathurl传递给使用通知中心的1stVC – (IBAction)sharebuttn:(id)sender { [self dismissViewControllerAnimated:YES completion:^{ // Tabbar index [[NSNotificationCenter defaultCenter] postNotificationName:@"ShareArray" object:_selectedimgarray]; [[NSNotificationCenter defaultCenter] postNotificationName:@"SharetitleArray" object:_newtile]; [[NSNotificationCenter defaultCenter] postNotificationName:@"sharevideooutputurl" object:_finalvideourl]; }]; 在1stVC中,我正在像这样检索它们 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedArray:) name:@"ShareArray" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedtitleArray:) name:@"SharetitleArray" object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sharevideooutputurl:) name:@"Sharevideourl" object:nil]; – (void)receivedArray 🙁 NSNotification *)notification { NSMutableArray* userInfo = notification.object; UIImage […]

AVPlayer不显示任何东西

我尝试从youtube vimeo,dailymotion中embedded不同的video。 可悲的是在这一刻没有任何东西显示,除了我的containerView的backgroundcolor: UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0, 320.0f, 200.0f)]; //item.url is my url which i get fro my webserver, it looks like http://www.youtube.com/watch?v=zPP6lXaL7KA&feature=youtube_gdata_player AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:item.url]]; AVPlayer *avPlayer = [AVPlayer playerWithPlayerItem:playerItem]; NSLog(@"%@",playerItem); AVPlayerLayer *avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer]; avPlayerLayer.frame = self.frame; [containerView.layer addSublayer:avPlayerLayer]; [self addSubview:containerView]; [avPlayer play]; if (avPlayer.status == […]

AVPlayer的多个video

我正在开发iPad的iOS应用程序,需要在屏幕的某个部分播放video。 我有几个video文件需要按照编译时没有给出的顺序播放。 它看起来好像只是一个video播放。 当从一个video到另一个video时,这两个video的最后一帧或最后一帧显示有一些延迟,但是没有内容的闪烁或白色屏幕应该是不错的。 video不包含audio。 考虑到内存使用情况非常重要。 这些video具有非常高的分辨率,并且可以同时播放几个不同的video序列。 为了获得这个,我已经尝试了几个解决scheme。 如下所列: AVPlayer与AVComposition与其中的所有video 在这个解决scheme中,我有一个AVPlayer,它只能在AVPlayerItem上使用,AVPlayerItem使用包含所有放在一起的video的AVComposition。 当我去看具体的video的时候,我试图在下一个video开始的时候进行合成。这个解决scheme的问题是,当寻找播放器的时候会很快显示出它正在寻找的一些帧,这是不可接受的。 似乎没有办法直接跳到组合中的特定时间。 我试图通过在刚刚完成的video中制作最后一帧的图像来解决这个问题,然后在AVPLayer的前面显示该图像,最后在查找完成后将其删除。 我正在使用AVAssetImageGenerator制作图像,但出于某种原因,图像的质量与video不一样,所以在显示和隐藏图像时会有显着的变化。 另一个问题是,AVPlayer使用大量的内存,因为一个AVPlayerItem保存所有的video。 AVPlayer有多个AVPlayerItems 此解决scheme为每个video使用AVPlayerItem,并在切换到新video时replaceAVPlayer的项目。 这个问题是,当切换一个AVPlayer的项目时,它会显示一个白色的屏幕短时间加载新的项目。 为了解决这个问题,可以使用在加载的同时在最后一帧放置图像的解决scheme,但是仍然存在图像和video的质量不同且显着的问题。 3.两个AVPlayers彼此轮stream播放AVPlayerItem 我试过的下一个解决scheme是将两个AVPlayer放在一起,然后轮stream播放AVPlayerItems。 所以当玩家完成游戏时,它将停留在video的最后一帧。 另一个AVPlayer将被带到前面(其项目设置为零,所以它是透明的),并且下一个AVPlayerItem将被插入到该AVPlayer中。 一旦它被加载,它将开始播放,两个video之间的顺利交易的幻想将完好无损。 这个解决scheme的问题是内存使用情况。 在某些情况下,我需要同时在屏幕上播放两个video,这将导致4个AVPlayers同时载入一个AVPlayerItem。 由于video的分辨率可能很高,因此记忆体太多了。 有没有人有一些想法,build议,意见或有关整体的问题和上述张贴的解决办法。

来电后AVplayer恢复

我正在使用AVPlayer进行音乐播放。 我的问题是,来电后,玩家将不会恢复。 来电时如何处理?