QGVAPWrapView.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // UIView+VAP.h
  2. // Tencent is pleased to support the open source community by making vap available.
  3. //
  4. // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
  5. //
  6. // Licensed under the MIT License (the "License"); you may not use this file except in
  7. // compliance with the License. You may obtain a copy of the License at
  8. //
  9. // http://opensource.org/licenses/MIT
  10. //
  11. // Unless required by applicable law or agreed to in writing, software distributed under the License is
  12. // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  13. // either express or implied. See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. #import <UIKit/UIKit.h>
  16. #import "UIView+VAP.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. typedef NS_ENUM(NSUInteger, QGVAPWrapViewContentMode) {
  19. QGVAPWrapViewContentModeScaleToFill,
  20. QGVAPWrapViewContentModeAspectFit,
  21. QGVAPWrapViewContentModeAspectFill,
  22. };
  23. @protocol VAPWrapViewDelegate <NSObject>
  24. @optional
  25. //即将开始播放时询问,true马上开始播放,false放弃播放
  26. - (BOOL)vapWrap_viewshouldStartPlayMP4:(VAPView *)container config:(QGVAPConfigModel *)config;
  27. - (void)vapWrap_viewDidStartPlayMP4:(VAPView *)container;
  28. - (void)vapWrap_viewDidPlayMP4AtFrame:(QGMP4AnimatedImageFrame*)frame view:(VAPView *)container;
  29. - (void)vapWrap_viewDidStopPlayMP4:(NSInteger)lastFrameIndex view:(VAPView *)container;
  30. - (void)vapWrap_viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container;
  31. - (void)vapWrap_viewDidFailPlayMP4:(NSError *)error;
  32. //vap APIs
  33. - (NSString *)vapWrapview_contentForVapTag:(NSString *)tag resource:(QGVAPSourceInfo *)info; //替换配置中的资源占位符(不处理直接返回tag)
  34. - (void)vapWrapView_loadVapImageWithURL:(NSString *)urlStr context:(NSDictionary *)context completion:(VAPImageCompletionBlock)completionBlock; //由于组件内不包含网络图片加载的模块,因此需要外部支持图片加载。
  35. @end
  36. /*
  37. 封装VAPView,本身不响应手势
  38. 提供ContentMode功能
  39. 播放完成后会自动移除内部的VAPView(可选)
  40. */
  41. @interface QGVAPWrapView : UIView
  42. /// default is QGVAPWrapViewContentModeScaleToFill
  43. @property (nonatomic, assign) QGVAPWrapViewContentMode contentMode;
  44. // 是否在播放完成后自动移除内部VAPView, 如果外部用法会复用当前View,可以不移除
  45. @property (nonatomic, assign) BOOL autoDestoryAfterFinish;
  46. - (void)playHWDMP4:(NSString *)filePath
  47. repeatCount:(NSInteger)repeatCount
  48. delegate:(id<VAPWrapViewDelegate>)delegate;
  49. - (void)stopHWDMP4;
  50. - (void)pauseHWDMP4;
  51. - (void)resumeHWDMP4;
  52. //增加点击的手势识别, 如果开启了autoDestoryAfterFinish,那么手势将在播放完毕后失效
  53. - (void)addVapTapGesture:(VAPGestureEventBlock)handler;
  54. //手势识别通用接口, 如果开启了autoDestoryAfterFinish,那么手势将在播放完毕后失效
  55. - (void)addVapGesture:(UIGestureRecognizer *)gestureRecognizer callback:(VAPGestureEventBlock)handler;
  56. /*
  57. QGVAPWrapView本身不响应手势,只有子视图响应手势,请使用vapWrapView_addVapTapGesture / vapWrapView_addVapGesture添加
  58. */
  59. - (void)addGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer NS_UNAVAILABLE;
  60. @end
  61. NS_ASSUME_NONNULL_END