Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
pidan
/
FuSiLive
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
aabf284e
authored
Jan 17, 2025
by
pierce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed 首次安装开播可能崩溃的问题
parent
6df54f9b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
125 deletions
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Other/FUSLiveHelper.m
Modules/FUSShowRoomModule/FUSShowRoomModule/Features/NewLive/Main/Other/FUSLiveHelper.m
View file @
aabf284e
...
...
@@ -202,138 +202,144 @@
[[
NSFileManager
defaultManager
]
removeItemAtPath
:
bytedanceResource
error
:
nil
];
}
NSString
*
bdurl
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurl
;
NSString
*
bdurlmd5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurlmd5
;
[
FUSResourceDownloader
.
shareInstance
fus_removeTaskKeyWithDownloadUrl
:
bdurl
md5
:
bdurlmd5
];
NSString
*
licbag
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbag
;
NSString
*
licbagmd5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbagmd5
;
[
FUSResourceDownloader
.
shareInstance
fus_removeTaskKeyWithDownloadUrl
:
licbag
md5
:
licbagmd5
];
FUSDownloadResourceModel
*
downloadModel
=
[[
FUSDownloadResourceModel
alloc
]
init
];
downloadModel
.
resourceUrl
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurl
;
downloadModel
.
md5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurlmd5
;
downloadModel
.
downloadPriority
=
NSOperationQueuePriorityVeryHigh
;
downloadModel
.
unzipPath
=
FUSBeautyHelper
.
shareInstance
.
beautyConfig
.
beautyResourcePath
;
FUSDownloadResourceModel
*
licbagDownloadModel
=
[[
FUSDownloadResourceModel
alloc
]
init
];
licbagDownloadModel
.
resourceUrl
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbag
;
licbagDownloadModel
.
md5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbagmd5
;
licbagDownloadModel
.
downloadPriority
=
NSOperationQueuePriorityVeryHigh
;
licbagDownloadModel
.
unzipPath
=
FUSBeautyHelper
.
shareInstance
.
beautyConfig
.
beautyResourceLicBagPath
;
__block
BOOL
hasCancelLoading
=
NO
;
FUSResourceDownloadingView
*
loadingView
=
[[
FUSResourceDownloadingView
alloc
]
initWithFrame
:
UIView
.
fus_screenFrame
];
loadingView
.
tapToCloseHandler
=
^
{
hasCancelLoading
=
YES
;
};
[[
UIApplication
sharedApplication
].
keyWindow
addSubview
:
loadingView
];
__weak
typeof
(
loadingView
)
weakLoadingView
=
loadingView
;
__weak
typeof
(
self
)
weakSelf
=
self
;
dispatch_group_t
group
=
dispatch_group_create
();
dispatch_queue_t
queue
=
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
);
__block
CGFloat
resourceProgress
=
0
;
__block
CGFloat
licbagProgress
=
0
;
dispatch_group_enter
(
group
);
__block
BOOL
hasLeaveLivePushConfig
=
NO
;
downloadModel
.
succeedHandler
=
^
(
NSString
*
_Nonnull
filePath
)
{
dispatch_async
(
dispatch_get_global_queue
(
0
,
0
),
^
{
if
(
hasLeaveLivePushConfig
)
{
return
;
}
hasLeaveLivePushConfig
=
YES
;
dispatch_group_leave
(
group
);
};
downloadModel
.
failedHandler
=
^
(
NSString
*
_Nonnull
msg
,
NSInteger
code
)
{
NSString
*
bdurl
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurl
;
NSString
*
bdurlmd5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurlmd5
;
[
FUSResourceDownloader
.
shareInstance
fus_removeTaskKeyWithDownloadUrl
:
bdurl
md5
:
bdurlmd5
];
if
(
hasLeaveLivePushConfig
)
{
return
;
}
hasLeaveLivePushConfig
=
YES
;
dispatch_group_leave
(
group
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
FUSDialogView
fus_showDialog
:
msg
];
});
};
downloadModel
.
progresshandler
=
^
(
NSUInteger
bytesRead
,
long
long
totalBytesRead
,
long
long
totalBytesExpectedToRead
)
{
NSString
*
licbag
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbag
;
NSString
*
licbagmd5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbagmd5
;
[
FUSResourceDownloader
.
shareInstance
fus_removeTaskKeyWithDownloadUrl
:
licbag
md5
:
licbagmd5
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
hasLeaveLivePushConfig
)
{
return
;
}
if
(
weakLoadingView
)
{
CGFloat
progress
=
0
;
if
(
totalBytesRead
>
0
&&
totalBytesExpectedToRead
>
0
)
{
progress
=
(
CGFloat
)
totalBytesRead
/
(
CGFloat
)
totalBytesExpectedToRead
;
FUSDownloadResourceModel
*
downloadModel
=
[[
FUSDownloadResourceModel
alloc
]
init
];
downloadModel
.
resourceUrl
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurl
;
downloadModel
.
md5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
bdurlmd5
;
downloadModel
.
downloadPriority
=
NSOperationQueuePriorityVeryHigh
;
downloadModel
.
unzipPath
=
FUSBeautyHelper
.
shareInstance
.
beautyConfig
.
beautyResourcePath
;
FUSDownloadResourceModel
*
licbagDownloadModel
=
[[
FUSDownloadResourceModel
alloc
]
init
];
licbagDownloadModel
.
resourceUrl
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbag
;
licbagDownloadModel
.
md5
=
FUSLiveHelper
.
shareInstance
.
livePushConfig
.
licbagmd5
;
licbagDownloadModel
.
downloadPriority
=
NSOperationQueuePriorityVeryHigh
;
licbagDownloadModel
.
unzipPath
=
FUSBeautyHelper
.
shareInstance
.
beautyConfig
.
beautyResourceLicBagPath
;
__block
BOOL
hasCancelLoading
=
NO
;
FUSResourceDownloadingView
*
loadingView
=
[[
FUSResourceDownloadingView
alloc
]
initWithFrame
:
UIView
.
fus_screenFrame
];
loadingView
.
tapToCloseHandler
=
^
{
hasCancelLoading
=
YES
;
};
[[
UIApplication
sharedApplication
].
keyWindow
addSubview
:
loadingView
];
__weak
typeof
(
loadingView
)
weakLoadingView
=
loadingView
;
__weak
typeof
(
self
)
weakSelf
=
self
;
dispatch_group_t
group
=
dispatch_group_create
();
dispatch_queue_t
queue
=
dispatch_get_global_queue
(
DISPATCH_QUEUE_PRIORITY_DEFAULT
,
0
);
__block
CGFloat
resourceProgress
=
0
;
__block
CGFloat
licbagProgress
=
0
;
dispatch_group_enter
(
group
);
__block
BOOL
hasLeaveLivePushConfig
=
NO
;
downloadModel
.
succeedHandler
=
^
(
NSString
*
_Nonnull
filePath
)
{
if
(
hasLeaveLivePushConfig
)
{
return
;
}
resourceProgress
=
0
.
9
*
progress
;
[
weakLoadingView
fus_setprogress
:
resourceProgress
+
licbagProgress
];
}
else
{
FUSLogInfo
(
@""
);
}
});
};
dispatch_group_enter
(
group
);
__block
BOOL
hasLeave
=
NO
;
licbagDownloadModel
.
succeedHandler
=
^
(
NSString
*
_Nonnull
filePath
)
{
if
(
hasLeave
)
{
return
;
}
hasLeave
=
YES
;
dispatch_group_leave
(
group
);
};
licbagDownloadModel
.
failedHandler
=
^
(
NSString
*
_Nonnull
msg
,
NSInteger
code
)
{
if
(
hasLeave
)
{
return
;
}
hasLeave
=
YES
;
dispatch_group_leave
(
group
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
FUSDialogView
fus_showDialog
:
msg
];
});
};
licbagDownloadModel
.
progresshandler
=
^
(
NSUInteger
bytesRead
,
long
long
totalBytesRead
,
long
long
totalBytesExpectedToRead
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
hasLeave
)
{
return
;
}
if
(
weakLoadingView
)
{
CGFloat
progress
=
0
;
if
(
totalBytesRead
>
0
&&
totalBytesExpectedToRead
>
0
)
{
progress
=
(
CGFloat
)
totalBytesRead
/
(
CGFloat
)
totalBytesExpectedToRead
;
hasLeaveLivePushConfig
=
YES
;
dispatch_group_leave
(
group
);
};
downloadModel
.
failedHandler
=
^
(
NSString
*
_Nonnull
msg
,
NSInteger
code
)
{
if
(
hasLeaveLivePushConfig
)
{
return
;
}
licbagProgress
=
0
.
1
*
progress
;
[
weakLoadingView
fus_setprogress
:
resourceProgress
+
licbagProgress
];
}
else
{
FUSLogInfo
(
@""
);
}
});
};
dispatch_group_notify
(
group
,
queue
,
^
{
// 做一小会儿延迟,保证文件已经写入完成
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
.
2
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
!
hasCancelLoading
)
{
[
weakSelf
fus_pushLive
];
}
[
weakLoadingView
removeFromSuperview
];
hasLeaveLivePushConfig
=
YES
;
dispatch_group_leave
(
group
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
FUSDialogView
fus_showDialog
:
msg
];
});
};
downloadModel
.
progresshandler
=
^
(
NSUInteger
bytesRead
,
long
long
totalBytesRead
,
long
long
totalBytesExpectedToRead
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
hasLeaveLivePushConfig
)
{
return
;
}
if
(
weakLoadingView
)
{
CGFloat
progress
=
0
;
if
(
totalBytesRead
>
0
&&
totalBytesExpectedToRead
>
0
)
{
progress
=
(
CGFloat
)
totalBytesRead
/
(
CGFloat
)
totalBytesExpectedToRead
;
}
resourceProgress
=
0
.
9
*
progress
;
[
weakLoadingView
fus_setprogress
:
resourceProgress
+
licbagProgress
];
}
else
{
FUSLogInfo
(
@""
);
}
});
};
dispatch_group_enter
(
group
);
__block
BOOL
hasLeave
=
NO
;
licbagDownloadModel
.
succeedHandler
=
^
(
NSString
*
_Nonnull
filePath
)
{
if
(
hasLeave
)
{
return
;
}
hasLeave
=
YES
;
dispatch_group_leave
(
group
);
};
licbagDownloadModel
.
failedHandler
=
^
(
NSString
*
_Nonnull
msg
,
NSInteger
code
)
{
if
(
hasLeave
)
{
return
;
}
hasLeave
=
YES
;
dispatch_group_leave
(
group
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[
FUSDialogView
fus_showDialog
:
msg
];
});
};
licbagDownloadModel
.
progresshandler
=
^
(
NSUInteger
bytesRead
,
long
long
totalBytesRead
,
long
long
totalBytesExpectedToRead
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
hasLeave
)
{
return
;
}
if
(
weakLoadingView
)
{
CGFloat
progress
=
0
;
if
(
totalBytesRead
>
0
&&
totalBytesExpectedToRead
>
0
)
{
progress
=
(
CGFloat
)
totalBytesRead
/
(
CGFloat
)
totalBytesExpectedToRead
;
}
licbagProgress
=
0
.
1
*
progress
;
[
weakLoadingView
fus_setprogress
:
resourceProgress
+
licbagProgress
];
}
else
{
FUSLogInfo
(
@""
);
}
});
};
dispatch_group_notify
(
group
,
queue
,
^
{
// 做一小会儿延迟,保证文件已经写入完成
dispatch_after
(
dispatch_time
(
DISPATCH_TIME_NOW
,
(
int64_t
)(
0
.
2
*
NSEC_PER_SEC
)),
dispatch_get_main_queue
(),
^
{
if
(
!
hasCancelLoading
)
{
[
weakSelf
fus_pushLive
];
}
[
weakLoadingView
removeFromSuperview
];
});
});
[
FUSResourceDownloader
.
shareInstance
fus_addDownloadResource
:
downloadModel
];
[
FUSResourceDownloader
.
shareInstance
fus_addDownloadResource
:
licbagDownloadModel
];
});
});
[
FUSResourceDownloader
.
shareInstance
fus_addDownloadResource
:
downloadModel
];
[
FUSResourceDownloader
.
shareInstance
fus_addDownloadResource
:
licbagDownloadModel
];
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment