148 lines
5.5 KiB
Objective-C
148 lines
5.5 KiB
Objective-C
//
|
|
// LMCPInRoomVapView.m
|
|
// SweetParty
|
|
//
|
|
// Created by Xmac on 2024/8/17.
|
|
//
|
|
|
|
#import "LMCPInRoomVapView.h"
|
|
#import "QGVAPWrapView.h"
|
|
#import "UIView+VAP.h"
|
|
#import "QGVAPWrapView+download.h"
|
|
|
|
@interface LMCPInRoomVapView ()<HWDMP4PlayDelegate,VAPWrapViewDelegate>
|
|
|
|
@property (weak, nonatomic) IBOutlet UIView *inRoomTXCover;
|
|
@property (weak, nonatomic) IBOutlet UIView *leftHeaderVapCover;
|
|
@property (weak, nonatomic) IBOutlet UIView *rightHeaderVapCover;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *leftHeaderPic;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *rightHeaderPic;
|
|
@property (weak, nonatomic) IBOutlet UILabel *leftNicknameLabel;
|
|
@property (weak, nonatomic) IBOutlet UILabel *rightNicknameLabel;
|
|
|
|
@property (nonatomic, strong) QGVAPWrapView *leftHeaderVapView;
|
|
@property (nonatomic, strong) QGVAPWrapView *rightHeaderVapView;
|
|
@property (nonatomic, strong) QGVAPWrapView *texiaoVapView;
|
|
|
|
@end
|
|
|
|
@implementation LMCPInRoomVapView
|
|
|
|
- (void)awakeFromNib
|
|
{
|
|
[super awakeFromNib];
|
|
[self.leftHeaderVapCover addSubview:self.leftHeaderVapView];
|
|
[self.leftHeaderVapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.leftHeaderVapCover);
|
|
}];
|
|
|
|
[self.rightHeaderVapCover addSubview:self.rightHeaderVapView];
|
|
[self.rightHeaderVapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.rightHeaderVapCover);
|
|
}];
|
|
|
|
[self.inRoomTXCover addSubview:self.texiaoVapView];
|
|
[self.texiaoVapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(0);
|
|
make.top.mas_equalTo(0);
|
|
make.width.mas_equalTo(APPW);
|
|
make.height.mas_equalTo(APPH);
|
|
}];
|
|
}
|
|
|
|
- (void)playVapWithDict:(NSDictionary *)dict
|
|
{
|
|
NSString *send_nick_name = [dict safeStringForKey:@"send_nick_name"];
|
|
NSString *send_head_pic = [dict safeStringForKey:@"send_head_pic"];
|
|
NSString *receive_nick_name = [dict safeStringForKey:@"receive_nick_name"];
|
|
NSString *receive_head_pic = [dict safeStringForKey:@"receive_head_pic"];
|
|
NSString *texiao_img = [dict safeStringForKey:@"texiao_img"];
|
|
NSString *avatar_play_image = [dict safeStringForKey:@"avatar_play_image"];
|
|
NSString *receive_avatar_play_image = [dict safeStringForKey:@"receive_avatar_play_image"];
|
|
|
|
if (avatar_play_image.length>0){
|
|
[self.leftHeaderVapView playMemoryWithStr:C_string(avatar_play_image) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.leftHeaderVapView playHWDMP4:fileStr repeatCount:-1 delegate:nil];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[self.leftHeaderVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
if (receive_avatar_play_image.length>0){
|
|
[self.rightHeaderVapView playMemoryWithStr:C_string(receive_avatar_play_image) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.rightHeaderVapView playHWDMP4:fileStr repeatCount:-1 delegate:nil];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[self.rightHeaderVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
if (texiao_img.length>0){
|
|
[self.texiaoVapView playMemoryWithStr:C_string(texiao_img) Success:^(NSURL * _Nonnull filePath) {
|
|
NSString *fileStr = [filePath absoluteString];
|
|
if ([fileStr containsString:@"file://"]) {
|
|
fileStr = [fileStr substringFromIndex:7];
|
|
}
|
|
[self.texiaoVapView playHWDMP4:fileStr repeatCount:0 delegate:self];
|
|
} Failure:^(NSError * _Nonnull error) {
|
|
[self.texiaoVapView removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
|
|
[self.leftHeaderPic sd_setImageWithURL:[NSURL URLWithString:send_head_pic] placeholderImage:kDefaultUserIcon];
|
|
[self.rightHeaderPic sd_setImageWithURL:[NSURL URLWithString:receive_head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.leftNicknameLabel.text = send_nick_name;
|
|
self.rightNicknameLabel.text = receive_nick_name;
|
|
}
|
|
|
|
|
|
- (QGVAPWrapView *)leftHeaderVapView {
|
|
if (!_leftHeaderVapView) {
|
|
_leftHeaderVapView = [[QGVAPWrapView alloc] initWithFrame:CGRectZero];
|
|
_leftHeaderVapView.hwd_Delegate = self;
|
|
_leftHeaderVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
|
|
_leftHeaderVapView.userInteractionEnabled = NO;
|
|
}
|
|
return _leftHeaderVapView;
|
|
}
|
|
|
|
- (QGVAPWrapView *)rightHeaderVapView {
|
|
if (!_rightHeaderVapView) {
|
|
_rightHeaderVapView = [[QGVAPWrapView alloc] initWithFrame:CGRectZero];
|
|
_rightHeaderVapView.hwd_Delegate = self;
|
|
_rightHeaderVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
|
|
_rightHeaderVapView.userInteractionEnabled = NO;
|
|
}
|
|
return _rightHeaderVapView;
|
|
}
|
|
|
|
|
|
- (QGVAPWrapView *)texiaoVapView {
|
|
if (!_texiaoVapView) {
|
|
_texiaoVapView = [[QGVAPWrapView alloc] initWithFrame:CGRectZero];
|
|
_texiaoVapView.hwd_Delegate = self;
|
|
_texiaoVapView.contentMode = QGVAPWrapViewContentModeScaleToFill;
|
|
_texiaoVapView.userInteractionEnabled = NO;
|
|
}
|
|
return _texiaoVapView;
|
|
}
|
|
|
|
- (void)vapWrap_viewDidStopPlayMP4:(NSInteger)lastFrameIndex view:(VAPView *)container
|
|
{
|
|
RCMicMainThread(^{
|
|
self.hidden = YES;
|
|
[self.leftHeaderVapView stopHWDMP4];
|
|
[self.rightHeaderVapView stopHWDMP4];
|
|
})
|
|
}
|
|
|
|
|
|
@end
|