- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我希望能够在使用 AVKit 中的新 AVPlayerViewController 时更改播放控件的呈现方式。基本上,我想覆盖单指点击手势来做其他事情,并用双指点击替换该手势。我正在子类化 AVPlayerViewController 以添加此功能。
我可以通过创建一个新的 UITapGestureRecognizer 轻松地添加双指点击,但是通过单击这样做没有任何作用,因为播放控件仍然出现并且我的自定义手势方法没有被调用。我假设是因为 AVPlayerViewController 具有优先调用的手势。
我像往常一样设置手势...
// singleFingerTap: will never fire...
UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleFingerTap:)];
singleFingerTap.numberOfTouchesRequired = 1;
singleFingerTap.delegate = self;
[self.view addGestureRecognizer:singleFingerTap];
// doubleFingerTap: will work correctly...
UITapGestureRecognizer *doubleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleFingerTap:)];
doubleFingerTap.numberOfTouchesRequired = 2;
doubleFingerTap.delegate = self;
[self.view addGestureRecognizer:doubleFingerTap];
关于如何在不访问私有(private)属性的情况下实现这一点有什么想法吗?它甚至被允许吗?我知道我可以用一个 AVPlayer 实例创建我自己的 View Controller ,然后创建我自己的播放控件,但我希望我可以在这里使用轻量级 AVKit 播放器并进行一些简单的修改。
我已经尝试遍历 AVPlayerViewController View 中的手势并删除它们,但 gestureRecognizers 属性为空。即使我能做到这一点,我也不知道如何添加回手势以在双指点击而不是单指点击时显示播放控件。
如有任何建议,我们将不胜感激!特别是这是否可能/是否允许。谢谢!
编辑:我找到了一种方法来显式取消阻止阻止我自己的手势的玩家的私有(private)手势。
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
id firstGesture = gestureRecognizer;
id secondGesture = otherGestureRecognizer;
if ([firstGesture isKindOfClass:[UITapGestureRecognizer class]] && [secondGesture isKindOfClass:[UITapGestureRecognizer class]]) {
UITapGestureRecognizer *tapGesture = firstGesture;
UITapGestureRecognizer *otherTapGesture = secondGesture;
if (tapGesture.numberOfTapsRequired == otherTapGesture.numberOfTapsRequired && tapGesture.numberOfTouches == otherTapGesture.numberOfTouches) {
// Disable the single tap that shows the playback controls...
return YES;
}
}
return NO;
}
这有效地阻止了播放控件出现在点击上,并且我的 singleTapGesture: 按预期触发。但是,我现在遇到了让播放控件出现在不同手势上的问题。 是否可以重新路由私有(private)手势,或以编程方式模拟私有(private)手势?
最佳答案
为什么不首先检查/修改目标/删除默认手势识别器?
您可以使用标准 UIView
的 gestureRecognizers
访问它们。
手势识别器可以隐藏在私有(private) subview 中。
另一种解决方案是将 userInteractionEnabled
设置为 NO
并将您的手势识别器添加到 super View 或“覆盖”透明 View 。
关于ios - 覆盖 AVPlayerViewController 中的框架手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25431215/
在 Apple API Reference 中,它说不要像上面那样子类化 AVPlayerViewController。我想知道为什么。我特意写了一个演示子类AVPlayerViewControlle
当我们播放视频并返回到父窗口时,我遇到内存泄漏。请参阅下面的分配工具读数屏幕截图。 每次,当我弹出 View Controller (显示视频)时,都会有一些与 AVFoundation 相关的对象占
我正在为我的应用程序设计登录屏幕,我希望在其中有动画 Logo 。我创建了一个小视频文件(大约 1 Mb)并使用以下代码创建了 AVPlayerViewController 实例: let video
正确的 UIKit 方法: 根据 Apple 的 WWDC 2019 talk on the subject , AVPlayerViewController 应以模态方式呈现,以利用 API 的所有
我有一个 AVPlayerViewController我用 AVPlayer 初始化还有一些 AVPlayerItem (iOS 10、Xcode 8、Objective C)。AVPlayerVie
所以我试图从这个项目源编辑一些源代码... https://github.com/ariiyu/VideoPlayerSample 所以,当我只是尝试替换视频路径并文件时,它崩溃了,我不知道为什么?
在我的 tvOS 应用程序中,我有一个 AVPlayerViewController,通过显示转场呈现,如果没有找到视频,它会显示警报并展开到上一个 View 。我创建一个警报 Controller
我已经实现了一个标准的 Swift 视频播放器:- let path = NSBundle.mainBundle().pathForResource(assetName, ofType: "m4
我正在使用 AVPlayerViewController 来播放视频。问题是如何检测视频是否开始播放?通常是添加目标,但我找不到可以在该事件中添加的任何目标。有人能帮我吗?提前致谢。 最佳答案 使用来
如果先前的 View Controller 已实例化,我的自定义 AVPlayerViewController 将不会自动旋转。如果我呈现 AVPlayerViewController,它会旋转,如果
我必须快速创建一个视频流应用程序(使用远程网址)。但没有任何确切的视频格式。有时它可以是 m3u8 有时是 mp4 等..但我的视频播放器应该支持来自后端的格式。 此外,当应用程序在后台时,音频应该播
我正在为 iOS 开发一个应用程序,我已经构建了代码,一旦选择了 TableView 中的单元格,它就会转至 AVPlayerViewController 并根据选择的单元格行播放本地视频剪辑。但是当
我们可以将自定义播放速度(0.5、1.0、1.5、2.0)控制添加到 AVPlayerViewController 吗? 有没有一种方法可以使用 UISlider 值更改来刷新速度? 如果正在播放,我
我使用 AVPlayerViewController,我想在视频结束时淡出...我可以捕获视频结束事件,并且我为 AVPlayer 编写的代码可以工作,但对于 AVPlayerViewControll
我在我的项目中添加了一个 DemoVideo.mp4 并将其添加到复制资源文件中。但是当我运行该应用程序时,它不会播放我的视频。这是我的方法。 private func setUpAndPlayVid
我想知道 AVPlayerViewController 何时被关闭或退出全屏以更改其父 View Controller 布局,但我没有找到一个委托(delegate)方法来告诉我它何时发生。 我试过像
我想在使用 AVPlayerViewController 时删除音频和字幕按钮。我按如下方式创建 Controller : // Create the view controller and play
我使用 AVPlayerViewController 播放视频,它工作正常。但是当时设备映射方向运行时它不显示 AVPlayerViewController 状态栏。所以我无法关闭 AVPlayerV
在我的 View Controller 上,我添加了一个 AVPlayerViewController 作为子 Controller 。 它能够播放来自网络的音频和视频文件。但是,我想在按下暂停按钮或
我创建了一个播放器并且大部分时间都运行良好。 在某些情况下(我没有意识到为什么)屏幕视频保持黑色,播放按钮不执行任何操作。 我验证了 url,没问题,这不是问题。 在我的 viewController
我是一名优秀的程序员,十分优秀!