This commit is contained in:
启星
2025-09-23 09:13:16 +08:00
parent 048b9339eb
commit 0f6df9fb87
17 changed files with 188 additions and 25 deletions

View File

@@ -40,12 +40,14 @@ NS_ASSUME_NONNULL_BEGIN
@interface QXEffectContentView : UIView
@property (nonatomic,assign) BOOL isShow;
@property (nonatomic,assign) BOOL isOnece;
@property (nonatomic,strong) VAPView *playerMp4View;
@property (nonatomic, strong) dispatch_queue_t queue;
-(void)previewEffectWith:(NSString *)play_image;
- (void)displayEffectView:(NSString *)play_image;
- (void)displayEffectViewWithMorePlayImages:(NSArray *)playImages;
- (void)openOrCloseEffectViewWith:(BOOL)isShow;
@property (nonatomic,assign) BOOL isShow;
- (void)destroyEffectView;
-(void)stopPlay;
-(void)startPlay;

View File

@@ -280,6 +280,35 @@ static NSString *PLAY_IMAGE = @"play_image";
}
});
}
-(void)previewEffectWith:(NSString *)play_image{
self.isOnece = YES;
dispatch_async(dispatch_get_main_queue(), ^{
if ([play_image hasSuffix:@"mp4"]) {
__weak typeof(self)weakSelf = self;
/// mp4
[[QXRequset shareInstance] downloadVideoPlayerWithUrl:play_image completion:^(BOOL result, NSString * _Nonnull fileName) {
NSString *videoPath = [QXFileManager getGiftVideoPath:fileName];
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.playerMp4View.hidden = NO;
weakSelf.svagView.hidden = YES;
});
[weakSelf.playerMp4View stopHWDMP4];
[weakSelf.playerMp4View playHWDMP4:videoPath delegate:self];
}];
}else if ([play_image hasSuffix:@"svg"] || [play_image hasSuffix:@"svga"]) {
__weak typeof(self)weakSelf = self;
/// svga
[[QXRequset shareInstance] downloadVideoPlayerWithUrl:play_image completion:^(BOOL result, NSString * _Nonnull fileName) {
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.playerMp4View.hidden = YES;
weakSelf.svagView.hidden = NO;
});
NSString *filePath = [QXFileManager getGiftVideoPath:fileName];
[weakSelf.svagView loadSVGAPlayerWith:filePath];
}];
}
});
}
- (void)openOrCloseEffectViewWith:(BOOL)isShow {
_isShow = isShow;
@@ -307,9 +336,13 @@ static NSString *PLAY_IMAGE = @"play_image";
[self loadStartSVGAPlayer];
}
-(void)viewDidFinishPlayMP4:(NSInteger)totalFrameCount view:(VAPView *)container{
dispatch_async(dispatch_get_main_queue(), ^{
self.playerMp4View.hidden = YES;
});
if (self.isOnece) {
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self loadStartSVGAPlayer];
});
@@ -318,6 +351,9 @@ static NSString *PLAY_IMAGE = @"play_image";
dispatch_async(dispatch_get_main_queue(), ^{
self.playerMp4View.hidden = YES;
});
if (self.isOnece) {
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
[self loadStartSVGAPlayer];
});
@@ -417,6 +453,9 @@ static NSString *PLAY_IMAGE = @"play_image";
__weak typeof(self)weakSelf = self;
_svagView.didFinishedDisplay = ^(QXEffectSvgaView * _Nonnull svgaView) {
[svgaView destroySvga];
if (weakSelf.isOnece) {
return;
}
[weakSelf loadEndSvgaPlayer];
};
}