个播房动态背景
This commit is contained in:
@@ -114,6 +114,8 @@
|
||||
9B0086CA27BA4F570032BD2B /* AnchorMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */; };
|
||||
9B060B5827BCAEE20001B767 /* AnchorGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */; };
|
||||
9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; };
|
||||
9B17F71827BD150600440843 /* SVGAParserManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B17F71727BD150600440843 /* SVGAParserManager.m */; };
|
||||
9B17F71A27BD16CD00440843 /* anchor_room_bg.svga in Resources */ = {isa = PBXBuildFile; fileRef = 9B17F71927BD16CD00440843 /* anchor_room_bg.svga */; };
|
||||
9B7B605B27BB53060070BB72 /* XPAnchorAudienceUpMicView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B605A27BB53060070BB72 /* XPAnchorAudienceUpMicView.m */; };
|
||||
9B7B606227BB96E40070BB72 /* XPRoomAnchorInfoCardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B606127BB96E40070BB72 /* XPRoomAnchorInfoCardView.m */; };
|
||||
9B7B606627BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B606527BBA0EE0070BB72 /* XPAnchorAttentSendInfo.m */; };
|
||||
@@ -643,6 +645,9 @@
|
||||
9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorGiftValueView.m; sourceTree = "<group>"; };
|
||||
9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = "<group>"; };
|
||||
9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = "<group>"; };
|
||||
9B17F71627BD150600440843 /* SVGAParserManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAParserManager.h; sourceTree = "<group>"; };
|
||||
9B17F71727BD150600440843 /* SVGAParserManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SVGAParserManager.m; sourceTree = "<group>"; };
|
||||
9B17F71927BD16CD00440843 /* anchor_room_bg.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = anchor_room_bg.svga; sourceTree = "<group>"; };
|
||||
9B7B605927BB53060070BB72 /* XPAnchorAudienceUpMicView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPAnchorAudienceUpMicView.h; sourceTree = "<group>"; };
|
||||
9B7B605A27BB53060070BB72 /* XPAnchorAudienceUpMicView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPAnchorAudienceUpMicView.m; sourceTree = "<group>"; };
|
||||
9B7B606027BB96E40070BB72 /* XPRoomAnchorInfoCardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPRoomAnchorInfoCardView.h; sourceTree = "<group>"; };
|
||||
@@ -1704,6 +1709,8 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
180116F6279E8C3100F2CBC0 /* Date */,
|
||||
9B17F71527BD14FF00440843 /* SVGAParserManager */,
|
||||
E88863D0278ED4A0004BCFAB /* Timestamp */,
|
||||
E82D5C77276B25B000858D6D /* SpriteSheetManager */,
|
||||
E865964E2701A1A900846EBD /* StatisticsService */,
|
||||
E89DA6612700590A008483C1 /* IAPHelper */,
|
||||
@@ -1940,6 +1947,15 @@
|
||||
path = Anchor;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9B17F71527BD14FF00440843 /* SVGAParserManager */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9B17F71627BD150600440843 /* SVGAParserManager.h */,
|
||||
9B17F71727BD150600440843 /* SVGAParserManager.m */,
|
||||
);
|
||||
path = SVGAParserManager;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9B7B605827BB52FD0070BB72 /* AnchorView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -2995,6 +3011,7 @@
|
||||
E8A1E45D276220DA00B294CA /* candyTree_banner.svga */,
|
||||
E8A1E45F276220DA00B294CA /* candyTree_light.svga */,
|
||||
E8A1E45E276220DA00B294CA /* candyTree.svga */,
|
||||
9B17F71927BD16CD00440843 /* anchor_room_bg.svga */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
@@ -3641,6 +3658,7 @@
|
||||
E8937AC9276C3EDE00B2C7E1 /* svga_member_in_lv90.svga in Resources */,
|
||||
E8937ACC276C3EDE00B2C7E1 /* svga_member_in_lv80.svga in Resources */,
|
||||
E8937AC8276C3EDE00B2C7E1 /* svga_member_in_lv70.svga in Resources */,
|
||||
9B17F71A27BD16CD00440843 /* anchor_room_bg.svga in Resources */,
|
||||
E8DEC98B27637EA50078CB70 /* candyTree_open.svga in Resources */,
|
||||
E8A1E460276220DA00B294CA /* candyTree_banner.svga in Resources */,
|
||||
E8937ACA276C3EDE00B2C7E1 /* svga_member_in_lv50.svga in Resources */,
|
||||
@@ -3958,6 +3976,7 @@
|
||||
E8A1E4572762092700B294CA /* XPCandyTreePresenter.m in Sources */,
|
||||
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */,
|
||||
E8E70D8C26F2F5A500F03460 /* XPMineMatchCollectionViewCell.m in Sources */,
|
||||
9B17F71827BD150600440843 /* SVGAParserManager.m in Sources */,
|
||||
E80DE40D2775ABA500BE5BCB /* XPFirstRechargeFlowLayout.m in Sources */,
|
||||
E896EFA22771AE9400AD2CC1 /* XPMineFriendViewController.m in Sources */,
|
||||
186A534A26FC6ED900D67B2C /* TTActionSheetConfig.m in Sources */,
|
||||
|
18
xplan-ios/Base/Tool/SVGAParserManager/SVGAParserManager.h
Normal file
18
xplan-ios/Base/Tool/SVGAParserManager/SVGAParserManager.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// SVGAParserManager.h
|
||||
// XChat
|
||||
//
|
||||
// Created by 卫明何 on 2018/4/11.
|
||||
// Copyright © 2018年 XC. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SVGA.h"
|
||||
|
||||
@interface SVGAParserManager : NSObject
|
||||
|
||||
- (void)loadSvgaWithURL:(NSURL *_Nullable)url
|
||||
completionBlock:(void ( ^ _Nonnull )(SVGAVideoEntity * _Nullable videoItem))completionBlock
|
||||
failureBlock:(void ( ^ _Nullable)(NSError * _Nullable error))failureBlock;
|
||||
|
||||
@end
|
111
xplan-ios/Base/Tool/SVGAParserManager/SVGAParserManager.m
Normal file
111
xplan-ios/Base/Tool/SVGAParserManager/SVGAParserManager.m
Normal file
@@ -0,0 +1,111 @@
|
||||
//
|
||||
// SVGAParserManager.m
|
||||
// XChat
|
||||
//
|
||||
// Created by 卫明何 on 2018/4/11.
|
||||
// Copyright © 2018年 XC. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SVGAParserManager.h"
|
||||
#import "YYUtility.h"
|
||||
#import "GCDHelper.h"
|
||||
#import "XPMacro.h"
|
||||
|
||||
static NSInteger retryCount = 3;
|
||||
|
||||
@interface SVGAParserManager ()
|
||||
@property (nonatomic,strong) NSMutableDictionary *parserQueue;
|
||||
@property (nonatomic,strong) NSMutableDictionary *retryCache;
|
||||
@property (nonatomic,strong) SVGAParser *parser;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SVGAParserManager
|
||||
- (void)loadSvgaWithURL:(NSURL *)url
|
||||
completionBlock:(void (^)(SVGAVideoEntity * _Nullable))completionBlock
|
||||
failureBlock:(void (^)(NSError * _Nullable))failureBlock {
|
||||
if (!url) return;
|
||||
@kWeakify(self);
|
||||
NSString *key = [self cacheURL:url];
|
||||
[self.parser parseWithURL:url completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
@kStrongify(self);
|
||||
dispatch_main_sync_safe(^{
|
||||
@kStrongify(self);
|
||||
if (videoItem) {
|
||||
completionBlock(videoItem);
|
||||
[self removeCacheWithKey:key];
|
||||
[self.retryCache removeObjectForKey:key];
|
||||
}
|
||||
});
|
||||
} failureBlock:^(NSError * _Nullable error) {
|
||||
@kStrongify(self);
|
||||
if (error) {
|
||||
if (![self.retryCache objectForKey:key]) {
|
||||
[self.retryCache setObject:@(0) forKey:key];
|
||||
}
|
||||
[self.retryCache setObject:@([[self.retryCache objectForKey:key] integerValue] + 1) forKey:key];
|
||||
if ([[self.retryCache objectForKey:key] integerValue] < retryCount) {
|
||||
[self retryWithKey:key completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
completionBlock(videoItem);
|
||||
} failureBlock:^(NSError * _Nullable error) {
|
||||
failureBlock(error);
|
||||
}];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
// 尝试重新播放
|
||||
- (void)retryWithKey:(NSString *)key
|
||||
completionBlock:(void (^)(SVGAVideoEntity * _Nullable))completionBlock
|
||||
failureBlock:(void (^)(NSError * _Nullable))failureBlock {
|
||||
if (key) {
|
||||
NSURL *url = [self.parserQueue objectForKey:key];
|
||||
[self loadSvgaWithURL:url completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
completionBlock(videoItem);
|
||||
} failureBlock:^(NSError * _Nullable error) {
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存url
|
||||
- (NSString *)cacheURL:(NSURL *)url {
|
||||
NSString *key = [self getUUid];
|
||||
[self.parserQueue setObject:url forKey:key];
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
- (void)removeCacheWithKey:(NSString *)key {
|
||||
[self.parserQueue removeObjectForKey:key];
|
||||
}
|
||||
|
||||
- (NSString *)getUUid {
|
||||
return [UIDevice currentDevice].identifierForVendor.UUIDString;
|
||||
}
|
||||
|
||||
#pragma mark - Getter
|
||||
|
||||
- (SVGAParser *)parser {
|
||||
if (_parser == nil) {
|
||||
_parser = [[SVGAParser alloc]init];
|
||||
}
|
||||
return _parser;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)parserQueue {
|
||||
if (_parserQueue == nil) {
|
||||
_parserQueue = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _parserQueue;
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)retryCache {
|
||||
if (_retryCache == nil) {
|
||||
_retryCache = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return _retryCache;
|
||||
}
|
||||
|
||||
@end
|
@@ -101,6 +101,7 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) {
|
||||
@property (nonatomic , assign) NSInteger operatorStatus;
|
||||
@property (nonatomic , copy) NSString * roomPwd;
|
||||
@property (nonatomic , assign) BOOL leaveMode;
|
||||
@property (nonatomic, copy) NSString *backPic;
|
||||
@property (nonatomic , assign) RoomModeType roomModeType;//房间模式
|
||||
///糖果树的配置
|
||||
@property (nonatomic,strong) CandyTreeSwitchModel *boxSwitchVo;
|
||||
|
@@ -7,9 +7,10 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "RoomHostDelegate.h"
|
||||
#import "RoomGuestDelegate.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomBackContainerView : UIView
|
||||
@interface XPRoomBackContainerView : UIView<RoomGuestDelegate>
|
||||
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate;
|
||||
@end
|
||||
|
||||
|
@@ -8,14 +8,22 @@
|
||||
#import "XPRoomBackContainerView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
///Model
|
||||
#import "RoomInfoModel.h"
|
||||
|
||||
|
||||
//SVGA动画播放
|
||||
#import "SVGA.h"
|
||||
#import "SVGAParserManager.h"
|
||||
///Tool
|
||||
#import "XPMacro.h"
|
||||
#import "XCHUDTool.h"
|
||||
#import "NetImageView.h"
|
||||
|
||||
@interface XPRoomBackContainerView ()
|
||||
///背景图片
|
||||
@property (nonatomic,strong) UIImageView *backImageView;
|
||||
@property (nonatomic,strong) NetImageView *backImageView;
|
||||
@property (nonatomic, strong) SVGAImageView *svgDisplayView;
|
||||
@property (nonatomic, strong) SVGAParserManager *parserManager;
|
||||
///host 代理
|
||||
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
|
||||
|
||||
@@ -35,6 +43,7 @@
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.svgDisplayView];
|
||||
[self addSubview:self.backImageView];
|
||||
}
|
||||
|
||||
@@ -42,11 +51,69 @@
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
[self.svgDisplayView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)onRoomUpdate {
|
||||
[self updateRoomBg];
|
||||
}
|
||||
|
||||
- (void)updateRoomBg {
|
||||
RoomInfoModel *roomInfo = [self.delegate getRoomInfo];
|
||||
// UserInfoModel *userInfo = [self.delegate getUserInfo];
|
||||
if (roomInfo.backPic.length > 0) {
|
||||
///MARK:更改图片拉伸策略 BY lvjunhang, 2018-12-03,原值为:UIViewContentModeScaleAspectFit
|
||||
self.backImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
if ([roomInfo.backPic containsString:@".svga"]) { //房间背景是SVGA动态背景
|
||||
self.backImageView.hidden = YES;
|
||||
self.svgDisplayView.hidden = NO;
|
||||
@weakify(self);
|
||||
//@"https://img.erbanyy.com/Noble_OpenEffect_5.svga"
|
||||
[self.parserManager loadSvgaWithURL:[NSURL URLWithString:roomInfo.backPic] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
@strongify(self);
|
||||
self.svgDisplayView.loops = INT_MAX;
|
||||
self.svgDisplayView.clearsAfterStop = NO;
|
||||
self.svgDisplayView.videoItem = videoItem;
|
||||
[self.svgDisplayView startAnimation];
|
||||
} failureBlock:^(NSError * _Nullable error) {
|
||||
[XCHUDTool showErrorWithMessage:@"贵族专属背景图加载失败"];
|
||||
}];
|
||||
} else { //房间背景是静态背景
|
||||
[self.svgDisplayView stopAnimation];
|
||||
self.svgDisplayView.hidden = YES;
|
||||
self.backImageView.hidden = NO;
|
||||
self.backImageView.imageUrl = roomInfo.backPic;
|
||||
}
|
||||
}else { //没有设置背景,显示默认背景加高斯模糊
|
||||
if (roomInfo.type == RoomType_Anchor) {
|
||||
self.backImageView.hidden = YES;
|
||||
self.svgDisplayView.hidden = NO;
|
||||
@weakify(self);
|
||||
NSString *bgString = [[NSBundle mainBundle] pathForResource:@"anchor_room_bg" ofType:@"svga"];
|
||||
NSURL *bgUrl = [NSURL fileURLWithPath:bgString];
|
||||
[self.parserManager loadSvgaWithURL:bgUrl completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
|
||||
@strongify(self);
|
||||
self.svgDisplayView.loops = INT_MAX;
|
||||
self.svgDisplayView.clearsAfterStop = NO;
|
||||
self.svgDisplayView.videoItem = videoItem;
|
||||
[self.svgDisplayView startAnimation];
|
||||
} failureBlock:^(NSError * _Nullable error) {
|
||||
[XCHUDTool showErrorWithMessage:@"个播背景图加载失败"];
|
||||
}];
|
||||
return;
|
||||
}
|
||||
self.svgDisplayView.hidden = YES;
|
||||
self.backImageView.hidden = NO;
|
||||
self.backImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIImageView *)backImageView {
|
||||
- (NetImageView *)backImageView {
|
||||
if (!_backImageView) {
|
||||
_backImageView = [[UIImageView alloc] init];
|
||||
_backImageView = [[NetImageView alloc] init];
|
||||
_backImageView.userInteractionEnabled = YES;
|
||||
_backImageView.image = [UIImage imageNamed:@"room_background"];
|
||||
_backImageView.layer.masksToBounds = YES;
|
||||
@@ -54,4 +121,24 @@
|
||||
}
|
||||
return _backImageView;
|
||||
}
|
||||
|
||||
- (SVGAImageView *)svgDisplayView {
|
||||
if (_svgDisplayView == nil) {
|
||||
_svgDisplayView = [[SVGAImageView alloc]init];
|
||||
_svgDisplayView.contentMode = UIViewContentModeScaleToFill;
|
||||
_svgDisplayView.userInteractionEnabled = NO;
|
||||
_svgDisplayView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
|
||||
_svgDisplayView.hidden = YES;
|
||||
_svgDisplayView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _svgDisplayView;
|
||||
}
|
||||
|
||||
- (SVGAParserManager *)parserManager {
|
||||
if (!_parserManager) {
|
||||
_parserManager = [[SVGAParserManager alloc]init];
|
||||
}
|
||||
return _parserManager;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@@ -423,6 +423,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.functionView onRoomUpdate];
|
||||
[self.activityContainerView onRoomUpdate];
|
||||
[self.backContainerView onRoomUpdate];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
BIN
xplan-ios/Sources/anchor_room_bg.svga
Normal file
BIN
xplan-ios/Sources/anchor_room_bg.svga
Normal file
Binary file not shown.
Reference in New Issue
Block a user