JMSGVideoContent.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * | | | | \ \ / / | | | | / _______|
  3. * | |____| | \ \/ / | |____| | / /
  4. * | |____| | \ / | |____| | | | _____
  5. * | | | | / \ | | | | | | |____ |
  6. * | | | | / /\ \ | | | | \ \______| |
  7. * | | | | /_/ \_\ | | | | \_________|
  8. *
  9. * Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
  10. */
  11. #import <Foundation/Foundation.h>
  12. #import <UIKit/UIKit.h>
  13. #import <JMessage/JMSGMediaAbstractContent.h>
  14. /*!
  15. * 视频内容类型
  16. */
  17. @interface JMSGVideoContent : JMSGMediaAbstractContent<NSCopying>
  18. JMSG_ASSUME_NONNULL_BEGIN
  19. // 不支持使用的初始化方法
  20. - (instancetype)init NS_UNAVAILABLE;
  21. /*!
  22. * @abstract 视频时长 (单位:秒)
  23. */
  24. @property(nonatomic, copy, readonly) NSNumber *duration;
  25. /*!
  26. * @abstract 视频封面图片大小
  27. */
  28. @property(nonatomic, assign, readonly) CGSize videoThumbImageSize;
  29. /*!
  30. * @abstract 获取视频封面图片的本地路径
  31. *
  32. * @discussion 此属性是通过懒加载的方式获取,必须在下载完成之后此属性值才有意义
  33. */
  34. @property(nonatomic, strong, readonly) NSString *JMSG_NULLABLE videoThumbImageLocalPath;
  35. /*!
  36. * @abstract 初始化视频消息内容
  37. *
  38. * @param data 该视频内容的数据
  39. * @param thumbData 缩略图,建议:缩略图上层要控制大小,避免上传过大图片
  40. * @param duration 该视频内容的持续时长,长度应大于 0
  41. *
  42. * @discussion 建议:缩略图上层要控制大小,避免上传过大图片.
  43. */
  44. - (instancetype)initWithVideoData:(NSData *)data
  45. thumbData:(NSData *JMSG_NULLABLE)thumbData
  46. duration:(NSNumber *)duration;
  47. /*!
  48. * @abstract 视频格式
  49. *
  50. * @discussion 创建 videoContent 时可设置,建议设置 format。后缀不需要带点,只需后缀名,如: mp4、mov 等
  51. */
  52. @property(nonatomic, strong) NSString * JMSG_NULLABLE format;
  53. /*!
  54. * @abstract 视频文件名
  55. *
  56. * @discussion 创建 videoContent 时可设置
  57. */
  58. @property(nonatomic, strong) NSString * JMSG_NULLABLE fileName;
  59. /*!
  60. * @abstract 获取视频消息的封面缩略图
  61. *
  62. * @param handler 结果回调。回调参数:
  63. *
  64. * - data 图片数据;
  65. * - objectId 消息msgId;
  66. * - error 不为nil表示出错;
  67. *
  68. * 如果 error 为 ni, data 也为 nil, 表示没有数据.
  69. *
  70. * @discussion 展示缩略时调用此接口,获取缩略图数据。如果本地数据文件已经存在, 则直接返回; 如果本地还没有图片,会发起网络请求下载。下载完后再回调。
  71. */
  72. - (void)videoThumbImageData:(JMSGAsyncDataHandler JMSG_NULLABLE)handler;
  73. /*!
  74. * @abstract 获取视频
  75. *
  76. * @param progressHandler 下载进度。会持续回调更新进度, 直接下载完成。如果为 nil 则表示不关心进度。
  77. * @param handler 结果回调。回调参数:
  78. *
  79. * - data 文件数据;
  80. * - objectId 消息msgId;
  81. * - error 不为nil表示出错;
  82. *
  83. * 如果 error 为 ni, data 也为 nil, 表示没有数据.
  84. *
  85. * @discussion 如果本地数据文件已经存在, 则直接返回;如果本地还没有文件,会发起网络请求下载。下载完后再回调。
  86. */
  87. - (void)videoDataWithProgress:(JMSGMediaProgressHandler JMSG_NULLABLE)progressHandler
  88. completionHandler:(JMSGAsyncDataHandler JMSG_NULLABLE)handler;
  89. JMSG_ASSUME_NONNULL_END
  90. @end