我想拦截这个动作,以便我自己解开Segue,但我不知道该怎么做?我找到了MPMovIEPlayerVIEwController但不是AVPlayerVIEwController ..
我找到的代码MPMovIEPlayerVIEwController在下面..
- (voID)playVIDeo:(Nsstring*)aVIDeoUrl{ // Initialize the movIE player vIEw controller with a vIDeo URL string MPMovIEPlayerVIEwController *playerVC = [[[MPMovIEPlayerVIEwController alloc] initWithContentURL:[NSURL URLWithString:aVIDeoUrl]] autorelease];// Remove the movIE player vIEw controller from the "playback dID finish" notification observers[[NSNotificationCenter defaultCenter] removeObserver:playerVC name:MPMovIEPlayerPlaybackDIDFinishNotification object:playerVC.movIEPlayer];// Register this class as an observer instead[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEFinishedCallback:) name:MPMovIEPlayerPlaybackDIDFinishNotification object:playerVC.movIEPlayer];// Set the modal Transition style of your choiceplayerVC.modalTransitionStyle = UIModalTransitionStyleCrossdissolve;// Present the movIE player vIEw controller[self presentModalVIEwController:playerVC animated:YES];// Start playback[playerVC.movIEPlayer preparetoPlay];[playerVC.movIEPlayer play];}- (voID)movIEFinishedCallback:(NSNotification*)aNotification{// Obtain the reason why the movIE playback finishedNSNumber *finishReason = [[aNotification userInfo] objectForKey:MPMovIEPlayerPlaybackDIDFinishReasonUserInfoKey];// dismiss the vIEw controller ONLY when the reason is not "playback ended"if ([finishReason intValue] != MPMovIEFinishReasonPlaybackEnded){ MPMovIEPlayerController *movIEPlayer = [aNotification object]; // Remove this class from the observers [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMovIEPlayerPlaybackDIDFinishNotification object:movIEPlayer]; // dismiss the vIEw controller [self dismissModalVIEwControllerAnimated:YES];}
我问苹果这个问题,他们回答如下:
感谢您联系Apple开发人员技术支持(DTS).我们的工程师已经审查了您的请求,并得出结论,鉴于目前的运输系统配置,没有任何支持的方式来实现所需的功能.
解决方法 我对AVPlayerVIEwController进行子类化,并从vIEwWilldisappear发布通知,以指示关闭AVPlayerVIEwController.- (voID) vIEwWilldisappear:(BOol)animated { [[NSNotificationCenter defaultCenter] postNotificationname:kPlayerVIEwdismissednotification object:nil]; [super vIEwWilldisappear:animated];}
这可能不是100%正确的(因为它会失败,如果你有另一个视图显示在AVPlayerVIEwController),但它为我工作,因为AVPlayerVIEwController总是在堆栈的顶部.
总结以上是内存溢出为你收集整理的ios – 如何拦截AVPlayerViewController中的完成按钮?全部内容,希望文章能够帮你解决ios – 如何拦截AVPlayerViewController中的完成按钮?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)