From 0967563642e0d837cd1df6334bf3ad564a3225a1 Mon Sep 17 00:00:00 2001 From: alan <284051099@qq.com> Date: Fri, 16 Jul 2021 10:05:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E6=92=AD=E6=94=BE=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E5=87=BA=E7=BD=91=E7=BB=9C=E7=8A=B6=E6=80=81=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SJVideoPlayer/SJVideoPlayer.m | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/SJVideoPlayer/SJVideoPlayer.m b/SJVideoPlayer/SJVideoPlayer.m index 4490943b4..8db4d705f 100644 --- a/SJVideoPlayer/SJVideoPlayer.m +++ b/SJVideoPlayer/SJVideoPlayer.m @@ -16,6 +16,8 @@ #import #import #import +#import +#import #else #import "SJReachability.h" #import "SJBaseVideoPlayer.h" @@ -445,8 +447,37 @@ - (BOOL)_whetherToSupportOnlyOneOrientation { return NO; } +// 播放器链接是否为本地URL +- (BOOL)isLocalFileUrl { + if (self.assetURL != nil && self.assetURL.isFileURL) { + return YES; + } + if (self.URLAsset != nil) { + if (self.URLAsset.mediaURL != nil && self.URLAsset.mediaURL.isFileURL) { + return YES; + } + if (self.URLAsset.avAsset != nil + && [self.URLAsset.avAsset isKindOfClass:[AVURLAsset class]] + && [((AVURLAsset *)self.URLAsset.avAsset).URL isFileURL]) { + return YES; + } + if (self.URLAsset.avPlayerItem != nil + && self.URLAsset.avPlayerItem.asset != nil + && [self.URLAsset.avPlayerItem.asset isKindOfClass:[AVURLAsset class]] + && [((AVURLAsset *)self.URLAsset.avPlayerItem.asset).URL isFileURL]) { + return YES; + } + if (self.URLAsset.source != nil + && [self.URLAsset.source isKindOfClass:[AVPUrlSource class]] + && [((AVPUrlSource *)self.URLAsset.source).playerUrl isFileURL]) { + return YES; + } + } + return NO; +} + - (void)_resumeOrStopTimeoutTimer { - if ( self.isBuffering || self.isEvaluating ) { + if ((self.isBuffering || self.isEvaluating) && ![self isLocalFileUrl]) { if ( SJReachability.shared.networkStatus == SJNetworkStatus_NotReachable && _sj_timeoutTimer == nil ) { __weak typeof(self) _self = self; _sj_timeoutTimer = [NSTimer sj_timerWithTimeInterval:3 repeats:YES usingBlock:^(NSTimer * _Nonnull timer) {