
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
173 lines
4.5 KiB
Objective-C
173 lines
4.5 KiB
Objective-C
//
|
||
// RoomBoomProgressView.m
|
||
// YuMi
|
||
//
|
||
// Created by P on 2024/9/27.
|
||
//
|
||
|
||
#import "RoomBoomExplosionView.h"
|
||
|
||
#import <QGVAPWrapView.h>
|
||
#import "BoomInfoModel.h"
|
||
#import "AttachmentModel.h"
|
||
#import "RoomBoomManager.h"
|
||
#import "XPRoomGiftAnimationParser.h"
|
||
|
||
@interface RoomBoomExplosionView() <HWDMP4PlayDelegate>
|
||
|
||
@property (nonatomic, strong) VAPView *vapView;
|
||
@property (nonatomic, strong) XPRoomGiftAnimationParser *vapParser;
|
||
@property (nonatomic, assign) NSInteger seq;
|
||
|
||
@property (nonatomic, copy) NSString *countDownURLString;
|
||
@property (nonatomic, copy) NSString *endURLString;
|
||
|
||
@property (nonatomic, copy) void(^completeDisplay)(void);
|
||
|
||
@end
|
||
|
||
@implementation RoomBoomExplosionView
|
||
|
||
+ (void)display:(UIView *)superView
|
||
with:(NSArray *)vapSources
|
||
complete:(void(^)(void))complete {
|
||
if (vapSources.count < 2) {
|
||
[[RoomBoomManager sharedManager] explosionEnd];
|
||
return;
|
||
}
|
||
|
||
RoomBoomExplosionView *explosionView = [[RoomBoomExplosionView alloc] initWithFrame:CGRectMake(0, 0, superView.bounds.size.width, superView.bounds.size.height)];
|
||
explosionView.userInteractionEnabled = NO;
|
||
explosionView.completeDisplay = complete;
|
||
[superView addSubview:explosionView];
|
||
explosionView.countDownURLString = [vapSources firstObject];
|
||
explosionView.endURLString = [vapSources lastObject];
|
||
|
||
[explosionView play_count];
|
||
}
|
||
|
||
- (void)saveCurrenRoomUID:(NSInteger)room {
|
||
|
||
}
|
||
|
||
- (void)dealloc
|
||
{
|
||
[self.vapView stopHWDMP4];
|
||
[self.vapView removeFromSuperview];
|
||
self.vapView = nil;
|
||
}
|
||
|
||
- (void)handleEnd {
|
||
[[RoomBoomManager sharedManager] explosionEnd];
|
||
}
|
||
|
||
- (instancetype)initWithFrame:(CGRect)frame {
|
||
if (self = [super initWithFrame:frame]) {
|
||
|
||
self.seq = 0;
|
||
self.backgroundColor = [UIColor colorWithWhite:0.6 alpha:0.3];
|
||
|
||
[self addSubview:self.vapView];
|
||
[self.vapView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.edges.mas_equalTo(self);
|
||
}];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)play_count {
|
||
self.seq = 1;
|
||
|
||
NSString *path = [self.countDownURLString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
||
if (path.length == 0) {
|
||
[self handleEnd];
|
||
return;
|
||
}
|
||
|
||
NSString *encodingUrl = [path pureURLString];
|
||
@kWeakify(self);
|
||
[self.vapParser parseWithURL:encodingUrl completionBlock:^(NSString * _Nullable videoUrl) {
|
||
@kStrongify(self);
|
||
if (videoUrl.length) {
|
||
[self.vapView setMute:NO];
|
||
[self.vapView playHWDMP4:videoUrl repeatCount:0 delegate:self];
|
||
}
|
||
} failureBlock:^(NSError * _Nullable error) {
|
||
@kStrongify(self);
|
||
[self handleEnd];
|
||
}];
|
||
}
|
||
|
||
- (void)play_boom {
|
||
self.seq = 2;
|
||
NSString *path = [self.endURLString pureURLString];
|
||
if (path.length == 0) {
|
||
[self handleEnd];
|
||
return;
|
||
}
|
||
|
||
@kWeakify(self);
|
||
[self.vapParser parseWithURL:path completionBlock:^(NSString * _Nullable videoUrl) {
|
||
@kStrongify(self);
|
||
if (videoUrl.length) {
|
||
[self.vapView setMute:NO];
|
||
[self.vapView playHWDMP4:videoUrl repeatCount:0 delegate:self];
|
||
}
|
||
} failureBlock:^(NSError * _Nullable error) {
|
||
@kStrongify(self);
|
||
[self handleEnd];
|
||
}];
|
||
}
|
||
|
||
|
||
#pragma mark - HWDMP4PlayDelegate
|
||
//即将开始播放时询问,true马上开始播放,false放弃播放
|
||
- (BOOL)shouldStartPlayMP4:(VAPView *)container config:(QGVAPConfigModel *)config {
|
||
return YES;
|
||
}
|
||
|
||
- (void)viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container {
|
||
if (self.seq == 1) {
|
||
[self play_boom];
|
||
} else if (self.seq == 2) {
|
||
self.seq = 0;
|
||
@kWeakify(self);
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
@kStrongify(self);
|
||
[[RoomBoomManager sharedManager] explosionEnd];
|
||
[self removeFromSuperview];
|
||
});
|
||
}
|
||
}
|
||
|
||
- (void)viewDidStopPlayMP4:(NSInteger)lastFrameIndex view:(VAPView *)container {
|
||
|
||
}
|
||
|
||
- (void)viewDidFailPlayMP4:(NSError *)error{
|
||
@kWeakify(self);
|
||
dispatch_async(dispatch_get_main_queue(), ^{
|
||
@kStrongify(self);
|
||
[[RoomBoomManager sharedManager] explosionEnd];
|
||
[self removeFromSuperview];
|
||
});
|
||
}
|
||
|
||
#pragma mark -
|
||
- (VAPView *)vapView {
|
||
if (!_vapView) {
|
||
_vapView = [[VAPView alloc] init];
|
||
_vapView.contentMode = UIViewContentModeScaleAspectFill;
|
||
}
|
||
return _vapView;
|
||
}
|
||
|
||
- (XPRoomGiftAnimationParser *)vapParser {
|
||
if (!_vapParser) {
|
||
_vapParser = [[XPRoomGiftAnimationParser alloc] init];
|
||
}
|
||
return _vapParser;
|
||
}
|
||
|
||
@end
|