EMMsgVideoBubbleView.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // EMMsgVideoBubbleView.m
  3. // ChatDemo-UI3.0
  4. //
  5. // Created by XieYajie on 2019/2/14.
  6. // Copyright © 2019 XieYajie. All rights reserved.
  7. //
  8. #import "EMMsgVideoBubbleView.h"
  9. @implementation EMMsgVideoBubbleView
  10. - (instancetype)initWithDirection:(EMMessageDirection)aDirection
  11. type:(EMMessageType)aType
  12. {
  13. self = [super initWithDirection:aDirection type:aType];
  14. if (self) {
  15. [self _setupSubviews];
  16. }
  17. return self;
  18. }
  19. #pragma mark - Subviews
  20. - (void)_setupSubviews
  21. {
  22. self.shadowView = [[UIView alloc] init];
  23. self.shadowView.backgroundColor = [UIColor colorWithWhite:0.7 alpha:0.5];
  24. [self addSubview:self.shadowView];
  25. [self.shadowView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.edges.equalTo(self);
  27. }];
  28. self.playImgView = [[UIImageView alloc] init];
  29. self.playImgView.image = [UIImage imageNamed:@"msg_video_white"];
  30. self.playImgView.contentMode = UIViewContentModeScaleAspectFill;
  31. [self addSubview:self.playImgView];
  32. [self.playImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.center.equalTo(self);
  34. make.width.height.equalTo(@50);
  35. }];
  36. }
  37. #pragma mark - Setter
  38. - (void)setModel:(EMMessageModel *)model
  39. {
  40. EMMessageType type = model.type;
  41. if (type == EMMessageTypeVideo) {
  42. EMVideoMessageBody *body = (EMVideoMessageBody *)model.emModel.body;
  43. NSString *imgPath = body.thumbnailLocalPath;
  44. if ([imgPath length] == 0 && model.direction == EMMessageDirectionSend) {
  45. imgPath = body.localPath;
  46. }
  47. [self setThumbnailImageWithLocalPath:imgPath remotePath:body.thumbnailRemotePath thumbImgSize:body.thumbnailSize imgSize:body.thumbnailSize];
  48. }
  49. }
  50. @end