diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 22f976ab6..1dc0095b9 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -12,16 +12,16 @@ PODS: - SDWebImage (5.8.1): - SDWebImage/Core (= 5.8.1) - SDWebImage/Core (5.8.1) - - SJBaseVideoPlayer (3.3.3): + - SJBaseVideoPlayer (3.3.5): - Masonry - Reachability - - SJBaseVideoPlayer/AVPlayer (= 3.3.3) - - SJBaseVideoPlayer/Common (= 3.3.3) + - SJBaseVideoPlayer/AVPlayer (= 3.3.5) + - SJBaseVideoPlayer/Common (= 3.3.5) - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/AVPlayer (3.3.3): + - SJBaseVideoPlayer/AVPlayer (3.3.5): - Masonry - Reachability - SJBaseVideoPlayer/Common @@ -29,7 +29,7 @@ PODS: - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/Common (3.3.3): + - SJBaseVideoPlayer/Common (3.3.5): - Masonry - Reachability - SJBaseVideoPlayer/ResourceLoader @@ -37,7 +37,7 @@ PODS: - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/ResourceLoader (3.3.3): + - SJBaseVideoPlayer/ResourceLoader (3.3.5): - Masonry - Reachability - SJUIKit/AttributesFactory (>= 0.0.0.38) @@ -45,11 +45,11 @@ PODS: - SJUIKit/Queues - SJUIKit/SQLite3 - SJFullscreenPopGesture/ObjC (1.5.3) - - SJMediaCacheServer (1.0.5): + - SJMediaCacheServer (1.0.6): - CocoaHTTPServer - - SJMediaCacheServer/Core (= 1.0.5) + - SJMediaCacheServer/Core (= 1.0.6) - SJUIKit/SQLite3 - - SJMediaCacheServer/Core (1.0.5): + - SJMediaCacheServer/Core (1.0.6): - CocoaHTTPServer - SJUIKit/SQLite3 - SJPlaybackListController (0.0.5): @@ -177,9 +177,9 @@ SPEC CHECKSUMS: MJRefresh: 53e3e3219f204425ee6d3e62e8733d3295944cd6 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SDWebImage: e3eae2eda88578db0685a0c88597fdadd9433f05 - SJBaseVideoPlayer: 259d13f93937c7f92e888ba7107c3d47308ee37f + SJBaseVideoPlayer: ebe3f08587d1af6c98cd450ecea73b89ba68d9f8 SJFullscreenPopGesture: d4994917bc900e79cd686970866834b4c5883565 - SJMediaCacheServer: 50d5777adf64ae83254a4c1cedb19ec4a625eb15 + SJMediaCacheServer: cf3a26f4610941493c65e768e39b62319bdfb21b SJPlaybackListController: e135c789fcd63d63a62d5e2e2965ab1e6d52a2bd SJRouter: a866e7884fc9219bed523be0a0318c3a84e85022 SJUIKit: dd52a4c3879610d9382e5a26b01cb56bcf25e205 diff --git a/Example/Pods/Manifest.lock b/Example/Pods/Manifest.lock index 22f976ab6..1dc0095b9 100644 --- a/Example/Pods/Manifest.lock +++ b/Example/Pods/Manifest.lock @@ -12,16 +12,16 @@ PODS: - SDWebImage (5.8.1): - SDWebImage/Core (= 5.8.1) - SDWebImage/Core (5.8.1) - - SJBaseVideoPlayer (3.3.3): + - SJBaseVideoPlayer (3.3.5): - Masonry - Reachability - - SJBaseVideoPlayer/AVPlayer (= 3.3.3) - - SJBaseVideoPlayer/Common (= 3.3.3) + - SJBaseVideoPlayer/AVPlayer (= 3.3.5) + - SJBaseVideoPlayer/Common (= 3.3.5) - SJUIKit/AttributesFactory (>= 0.0.0.38) - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/AVPlayer (3.3.3): + - SJBaseVideoPlayer/AVPlayer (3.3.5): - Masonry - Reachability - SJBaseVideoPlayer/Common @@ -29,7 +29,7 @@ PODS: - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/Common (3.3.3): + - SJBaseVideoPlayer/Common (3.3.5): - Masonry - Reachability - SJBaseVideoPlayer/ResourceLoader @@ -37,7 +37,7 @@ PODS: - SJUIKit/ObserverHelper - SJUIKit/Queues - SJUIKit/SQLite3 - - SJBaseVideoPlayer/ResourceLoader (3.3.3): + - SJBaseVideoPlayer/ResourceLoader (3.3.5): - Masonry - Reachability - SJUIKit/AttributesFactory (>= 0.0.0.38) @@ -45,11 +45,11 @@ PODS: - SJUIKit/Queues - SJUIKit/SQLite3 - SJFullscreenPopGesture/ObjC (1.5.3) - - SJMediaCacheServer (1.0.5): + - SJMediaCacheServer (1.0.6): - CocoaHTTPServer - - SJMediaCacheServer/Core (= 1.0.5) + - SJMediaCacheServer/Core (= 1.0.6) - SJUIKit/SQLite3 - - SJMediaCacheServer/Core (1.0.5): + - SJMediaCacheServer/Core (1.0.6): - CocoaHTTPServer - SJUIKit/SQLite3 - SJPlaybackListController (0.0.5): @@ -177,9 +177,9 @@ SPEC CHECKSUMS: MJRefresh: 53e3e3219f204425ee6d3e62e8733d3295944cd6 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 SDWebImage: e3eae2eda88578db0685a0c88597fdadd9433f05 - SJBaseVideoPlayer: 259d13f93937c7f92e888ba7107c3d47308ee37f + SJBaseVideoPlayer: ebe3f08587d1af6c98cd450ecea73b89ba68d9f8 SJFullscreenPopGesture: d4994917bc900e79cd686970866834b4c5883565 - SJMediaCacheServer: 50d5777adf64ae83254a4c1cedb19ec4a625eb15 + SJMediaCacheServer: cf3a26f4610941493c65e768e39b62319bdfb21b SJPlaybackListController: e135c789fcd63d63a62d5e2e2965ab1e6d52a2bd SJRouter: a866e7884fc9219bed523be0a0318c3a84e85022 SJUIKit: dd52a4c3879610d9382e5a26b01cb56bcf25e205 diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJDeviceVolumeAndBrightnessManager.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJDeviceVolumeAndBrightnessManager.m index 981a7071c..ca8c464f0 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJDeviceVolumeAndBrightnessManager.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJDeviceVolumeAndBrightnessManager.m @@ -166,8 +166,9 @@ @implementation SJDeviceVolumeAndBrightnessManager @synthesize volumeTracking = _volumeTracking; @synthesize brightnessTracking = _brightnessTracking; -+ (void)load { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ ++ (void)initialize { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ [self shared]; }); } diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJVideoPlayerPresentView.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJVideoPlayerPresentView.m index 4943e8943..a724255e3 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJVideoPlayerPresentView.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/Common/Implements/SJVideoPlayerPresentView.m @@ -86,6 +86,10 @@ - (void)handlePan:(UIPanGestureRecognizer *)pan { CGPoint translate = [pan translationInView:pan.view]; switch (pan.state) { case UIGestureRecognizerStateBegan: { + if ( _gestureRecognizerShouldTrigger && !_gestureRecognizerShouldTrigger(self, SJPlayerGestureType_Pan, [_pan locationInView:_pan.view]) ) { + pan.state = UIGestureRecognizerStateFailed; + return; + } if ( _panHandler ) _panHandler(self, _triggeredPosition, _movingDirection, SJPanGestureRecognizerStateBegan, translate); } break; @@ -106,6 +110,13 @@ - (void)handlePan:(UIPanGestureRecognizer *)pan { - (void)handlePinch:(UIPinchGestureRecognizer *)pinch { switch ( pinch.state ) { + case UIGestureRecognizerStateBegan: { + if ( _gestureRecognizerShouldTrigger && !_gestureRecognizerShouldTrigger(self, SJPlayerGestureType_Pinch, [pinch locationInView:pinch.view]) ) { + pinch.state = UIGestureRecognizerStateFailed; + return; + } + } + break; case UIGestureRecognizerStateEnded: { if ( _pinchHandler ) _pinchHandler(self, pinch.scale); @@ -119,6 +130,10 @@ - (void)handlePinch:(UIPinchGestureRecognizer *)pinch { - (void)handleLongPress:(UILongPressGestureRecognizer *)longPress { switch ( longPress.state ) { case UIGestureRecognizerStateBegan: { + if ( _gestureRecognizerShouldTrigger && !_gestureRecognizerShouldTrigger(self, SJPlayerGestureType_LongPress, [longPress locationInView:longPress.view]) ) { + longPress.state = UIGestureRecognizerStateFailed; + return; + } if ( _longPressHandler ) _longPressHandler(self, SJLongPressGestureRecognizerStateBegan); } break; @@ -319,9 +334,6 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer { break; } - if ( _gestureRecognizerShouldTrigger && !_gestureRecognizerShouldTrigger(self, type, [gestureRecognizer locationInView:gestureRecognizer.view]) ) - return NO; - return YES; } diff --git a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m index cc675899b..2673233c1 100755 --- a/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m +++ b/Example/Pods/SJBaseVideoPlayer/SJBaseVideoPlayer/SJBaseVideoPlayer.m @@ -156,7 +156,7 @@ + (instancetype)player { } + (NSString *)version { - return @"v3.3.3"; + return @"v3.3.5"; } - (void)setVideoGravity:(SJVideoGravity)videoGravity { @@ -201,15 +201,10 @@ - (instancetype)init { [self _showOrHiddenPlaceholderImageViewIfNeeded]; [self rotationManager]; [self registrar]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.deviceVolumeAndBrightnessManager prepare]; - }); - - dispatch_async(dispatch_get_global_queue(0, 0), ^{ - [self reachability]; - [self gestureControl]; - [self _configAVAudioSession]; - }); + [self reachability]; + [self gestureControl]; + [self.deviceVolumeAndBrightnessManager prepare]; + [self performSelectorInBackground:@selector(_configAVAudioSession) withObject:nil]; return self; } diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.h b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.h index c29ee3fcf..a46262819 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.h +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.h @@ -23,7 +23,11 @@ UIKIT_EXTERN MCSFileExtension const MCSHLSAESKeyFileExtension; + (NSString *)getFilePathWithName:(NSString *)name inResource:(NSString *)resourceName; // HLS // -+ (nullable NSString *)hls_AESKeyFilenameInResource:(NSString *)resource; ++ (nullable NSString *)hls_AESKeyFilenameAtIndex:(NSInteger)index inResource:(NSString *)resource; + +// HLS +// ++ (nullable NSString *)hls_AESKeyFilePathForAESKeyProxyURL:(NSURL *)URL inResource:(NSString *)resource; // HLS // diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.m index ce0897b0d..dc0a25be8 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Common/MCSFileManager.m @@ -45,36 +45,34 @@ + (NSString *)getFilePathWithName:(NSString *)name inResource:(NSString *)resour return [[self getResourcePathWithName:resourceName] stringByAppendingPathComponent:name]; } -// format: resourceName_aes.key +// format: resourceName_aes_index.key // HLS -+ (nullable NSString *)hls_AESKeyFilenameInResource:(NSString *)resource { - return [NSString stringWithFormat:@"%@_aes.key", resource]; ++ (nullable NSString *)hls_AESKeyFilenameAtIndex:(NSInteger)index inResource:(NSString *)resource { + return [NSString stringWithFormat:@"%@_aes_%ld.key", resource, (long)index]; } -// format: resourceName_aes.key +// format: resourceName_aes_index.key // HLS + (nullable NSString *)hls_resourceNameForAESKeyProxyURL:(NSURL *)URL { return [URL.lastPathComponent componentsSeparatedByString:@"_"].firstObject; } +// format: resourceName_aes_index.key +// HLS ++ (nullable NSString *)hls_AESKeyFilePathForAESKeyProxyURL:(NSURL *)URL inResource:(NSString *)resource { + NSString *filename = [self _filenameForUrl:URL.absoluteString]; + return [self getFilePathWithName:filename inResource:resource]; +} + // format: resourceName_tsName // HLS + (nullable NSString *)hls_tsNameForUrl:(NSString *)url inResource:(nonnull NSString *)resource { - NSString *component = url.lastPathComponent; - NSRange range = [component rangeOfString:@"?"]; - if ( range.location != NSNotFound ) { - component = [component substringToIndex:range.location]; - } - return [NSString stringWithFormat:@"%@_%@", resource, component]; + NSString *filename = [self _filenameForUrl:url]; + return [NSString stringWithFormat:@"%@_%@", resource, filename]; } + (nullable NSString *)hls_tsNameForTsProxyURL:(NSURL *)URL { - NSString *component = URL.absoluteString.lastPathComponent; - NSRange range = [component rangeOfString:@"?"]; - if ( range.location != NSNotFound ) { - component = [component substringToIndex:range.location]; - } - return component; + return [self _filenameForUrl:URL.absoluteString]; } // format: resourceName_tsName @@ -191,6 +189,17 @@ + (NSString *)tsNameOfContent:(NSString *)name { + (NSUInteger)tsTotalLengthOfContent:(NSString *)name { return (NSUInteger)[[name componentsSeparatedByString:@"_"][1] longLongValue]; } + +#pragma mark - + ++ (NSString *)_filenameForUrl:(NSString *)url { + NSString *name = url.lastPathComponent; + NSRange range = [name rangeOfString:@"?"]; + if ( range.location != NSNotFound ) { + name = [name substringToIndex:range.location]; + } + return name; +} @end @implementation MCSFileManager (FileSize) diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSHLSPrefetcher.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSHLSPrefetcher.m index 491217ca6..72401d085 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSHLSPrefetcher.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSHLSPrefetcher.m @@ -76,8 +76,8 @@ - (void)close { if ( _isClosed ) return; - _isClosed = YES; [_reader close]; + _isClosed = YES; MCSLog(@"%@: <%p>.close { preloadSize: %lu };\n", NSStringFromClass(self.class), self, (unsigned long)self.preloadSize); } @catch (__unused NSException *exception) { diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSPrefetcherManager.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSPrefetcherManager.m index bdbe1bd96..c9a8ae304 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSPrefetcherManager.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSPrefetcherManager.m @@ -113,6 +113,7 @@ - (void)_completeOperation { [self willChangeValueForKey:@"isExecuting"]; [_prefetcher close]; + _prefetcher = nil; _isExecuting = NO; _isFinished = YES; diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSVODPrefetcher.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSVODPrefetcher.m index 0acc2e408..375787afe 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSVODPrefetcher.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Prefetch/MCSVODPrefetcher.m @@ -72,8 +72,8 @@ - (void)close { if ( _isClosed ) return; - _isClosed = YES; [_reader close]; + _isClosed = YES; MCSLog(@"%@: <%p>.close { preloadSize: %lu };\n", NSStringFromClass(self.class), self, (unsigned long)self.preloadSize); } @catch (__unused NSException *exception) { diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSAESKeyDataReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSAESKeyDataReader.m index 7560b99ec..058bde7af 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSAESKeyDataReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSAESKeyDataReader.m @@ -18,7 +18,7 @@ @interface MCSHLSAESKeyDataReader () @implementation MCSHLSAESKeyDataReader - (instancetype)initWithResource:(MCSHLSResource *)resource URL:(nonnull NSURL *)URL delegate:(id)delegate delegateQueue:(dispatch_queue_t)queue { - NSString *path = [resource AESKeyFilePath]; + NSString *path = [resource AESKeyFilePathForAESKeyProxyURL:URL]; NSRange range = NSMakeRange(0, [MCSFileManager fileSizeAtPath:path]); NSRange readRange = range; self = [super initWithRange:range path:path readRange:readRange delegate:delegate delegateQueue:queue]; diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSIndexDataReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSIndexDataReader.m index 6856a697c..ef7e9625d 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSIndexDataReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSIndexDataReader.m @@ -175,8 +175,8 @@ - (void)_onError:(NSError *)error { - (void)_close { if ( _isClosed ) return; - _isClosed = YES; [_reader close]; + _isClosed = YES; MCSLog(@"%@: <%p>.close { URL: %@ };\n", NSStringFromClass(self.class), self, _URL); } diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSParser.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSParser.m index c3a511b13..7f3f87c91 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSParser.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSParser.m @@ -55,6 +55,7 @@ - (void)downloadTask:(NSURLSessionTask *)task didCompleteWithError:(NSError *)er @interface NSString (MCSRegexMatching) - (nullable NSArray *)mcs_rangesByMatchingPattern:(NSString *)pattern; +- (nullable NSArray *)mcs_textCheckingResultsByMatchPattern:(NSString *)pattern; @end @interface MCSHLSParser () { @@ -205,7 +206,7 @@ - (void)_parse { break; // 是否重定向 - url = [self _urlsWithPattern:@"(?:.*\\.m3u8[^\\s]*)" url:url source:contents].firstObject; + url = [self _urlsWithPattern:@".*\\.m3u8[^\\s]*" url:url source:contents].firstObject; } while ( url != nil ); if ( error != nil || contents == nil || ![contents hasPrefix:@"#"] ) { @@ -216,7 +217,7 @@ - (void)_parse { NSMutableString *indexFileContents = contents.mutableCopy; NSMutableDictionary *tsFragments = NSMutableDictionary.dictionary; NSMutableArray *reversedTsNames = NSMutableArray.array; - [[contents mcs_rangesByMatchingPattern:@"(?:.*\\.ts[^\\s]*)"] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(NSValue * _Nonnull range, NSUInteger idx, BOOL * _Nonnull stop) { + [[contents mcs_rangesByMatchingPattern:@".*\\.ts[^\\s]*"] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(NSValue * _Nonnull range, NSUInteger idx, BOOL * _Nonnull stop) { NSRange rangeValue = range.rangeValue; NSString *matched = [contents substringWithRange:rangeValue]; NSString *url = [self _urlWithMatchedString:matched]; @@ -229,27 +230,23 @@ - (void)_parse { /// /// #EXT-X-KEY:METHOD=AES-128,URI="...",IV=... /// - [[indexFileContents mcs_rangesByMatchingPattern:@"#EXT-X-KEY:METHOD=AES-128,URI=\".*\""] enumerateObjectsUsingBlock:^(NSValue * _Nonnull range, NSUInteger idx, BOOL * _Nonnull stop) { - NSRange rangeValue = range.rangeValue; - NSString *matched = [contents substringWithRange:rangeValue]; - NSInteger URILocation = [matched rangeOfString:@"\""].location + 1; - NSRange URIRange = NSMakeRange(URILocation, matched.length-URILocation-1); - NSString *URI = [matched substringWithRange:URIRange]; + [[indexFileContents mcs_textCheckingResultsByMatchPattern:@"#EXT-X-KEY:METHOD=AES-128,URI=\"(.*)\""] enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(NSTextCheckingResult * _Nonnull result, NSUInteger idx, BOOL * _Nonnull stop) { + NSRange URIRange = [result rangeAtIndex:1]; + NSString *URI = [indexFileContents substringWithRange:URIRange]; NSString *url = [self _urlWithMatchedString:URI]; NSData *keyData = [MCSData dataWithContentsOfURL:[NSURL URLWithString:url] error:&error]; if ( error != nil ) { *stop = YES; return ; } - NSString *filename = [MCSFileManager hls_AESKeyFilenameInResource:self.resourceName]; + NSString *filename = [MCSFileManager hls_AESKeyFilenameAtIndex:idx inResource:self.resourceName]; NSString *filepath = [MCSFileManager getFilePathWithName:filename inResource:self.resourceName]; [keyData writeToFile:filepath options:0 error:&error]; if ( error != nil ) { *stop = YES; return ; } - NSString *reset = [matched stringByReplacingCharactersInRange:URIRange withString:filename]; - [indexFileContents replaceCharactersInRange:rangeValue withString:reset]; + [indexFileContents replaceCharactersInRange:URIRange withString:filename]; }]; if ( error != nil ) { @@ -335,11 +332,18 @@ - (void)unlock { @implementation NSString (MCSRegexMatching) - (nullable NSArray *)mcs_rangesByMatchingPattern:(NSString *)pattern { - NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:NULL]; NSMutableArray *m = NSMutableArray.array; - [regex enumerateMatchesInString:self options:NSMatchingWithoutAnchoringBounds range:NSMakeRange(0, self.length) usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) { + for ( NSTextCheckingResult *result in [self mcs_textCheckingResultsByMatchPattern:pattern]) + [m addObject:[NSValue valueWithRange:result.range]]; + return m.count != 0 ? m.copy : nil; +} + +- (nullable NSArray *)mcs_textCheckingResultsByMatchPattern:(NSString *)pattern { + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern options:kNilOptions error:NULL]; + NSMutableArray *m = NSMutableArray.array; + [regex enumerateMatchesInString:self options:kNilOptions range:NSMakeRange(0, self.length) usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) { if ( result != nil ) { - [m addObject:[NSValue valueWithRange:result.range]]; + [m addObject:result]; } }]; return m.count != 0 ? m.copy : nil; diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSReader.m index bb0e2a4d7..f3c309b7e 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSReader.m @@ -125,15 +125,8 @@ - (NSData *)readDataOfLength:(NSUInteger)length { - (void)close { [self lock]; - @try { - [self _close]; - } @catch (__unused NSException *exception) { - - } @finally { - [self unlock]; - } - -// MCSLog(@"%@: <%p>.close { range: %@ };\n", NSStringFromClass(self.class), self, NSStringFromRange(_request.mcs_range)); + [self _close]; + [self unlock]; } - (BOOL)isReadingEndOfData { @@ -176,8 +169,8 @@ - (void)_close { if ( _isClosed ) return; - _isClosed = YES; [_reader close]; + _isClosed = YES; MCSLog(@"%@: <%p>.close { URL: %@ };\n", NSStringFromClass(self.class), self, _request.URL); } diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.h b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.h index ddd9a1243..bccc2bed1 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.h +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.h @@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSUInteger tsCount; @property (nonatomic, strong, nullable) MCSHLSParser *parser; -- (NSString *)AESKeyFilePath; +- (NSString *)AESKeyFilePathForAESKeyProxyURL:(NSURL *)URL; - (NSString *)tsNameForTsProxyURL:(NSURL *)URL; - (nullable MCSResourcePartialContent *)contentForTsProxyURL:(NSURL *)URL; - (MCSResourcePartialContent *)createContentWithTsProxyURL:(NSURL *)URL tsTotalLength:(NSUInteger)totalLength; diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.m index b4333ed5e..2ff054fc6 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSResource.m @@ -35,9 +35,8 @@ - (NSURL *)playbackURLForCacheWithURL:(NSURL *)URL { return [MCSURLRecognizer.shared proxyURLWithURL:URL]; } -- (NSString *)AESKeyFilePath { - NSString *filename = [MCSFileManager hls_AESKeyFilenameInResource:self.name]; - return [MCSFileManager getFilePathWithName:filename inResource:self.name]; +- (NSString *)AESKeyFilePathForAESKeyProxyURL:(NSURL *)URL { + return [MCSFileManager hls_AESKeyFilePathForAESKeyProxyURL:URL inResource:self.name]; } - (NSString *)tsNameForTsProxyURL:(NSURL *)URL { diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSTSDataReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSTSDataReader.m index 0e700c37f..dfc108472 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSTSDataReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/HLS/MCSHLSTSDataReader.m @@ -263,7 +263,6 @@ - (void)_close { return; @try { - _isClosed = YES; if ( _task.state == NSURLSessionTaskStateRunning ) [_task cancel]; _task = nil; [_writer synchronizeFile]; @@ -272,6 +271,7 @@ - (void)_close { [_reader closeFile]; _reader = nil; [_content readWrite_release]; + _isClosed = YES; MCSLog(@"%@: <%p>.close;\n", NSStringFromClass(self.class), self); } @catch (__unused NSException *exception) { diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/MCSResourceFileDataReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/MCSResourceFileDataReader.m index 883931296..b220d7aa2 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/MCSResourceFileDataReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/MCSResourceFileDataReader.m @@ -149,9 +149,9 @@ - (void)_close { return; @try { - _isClosed = YES; [_reader closeFile]; _reader = nil; + _isClosed = YES; MCSLog(@"%@: <%p>.close;\n", NSStringFromClass(self.class), self); } @catch (__unused NSException *exception) { diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODNetworkDataReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODNetworkDataReader.m index 60a606fd5..9100b5004 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODNetworkDataReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODNetworkDataReader.m @@ -229,7 +229,6 @@ - (void)_close { return; @try { - _isClosed = YES; if ( _task.state == NSURLSessionTaskStateRunning ) [_task cancel]; _task = nil; [_writer synchronizeFile]; @@ -237,6 +236,7 @@ - (void)_close { _writer = nil; [_reader closeFile]; _reader = nil; + _isClosed = YES; MCSLog(@"%@: <%p>.close;\n", NSStringFromClass(self.class), self); } @catch (__unused NSException *exception) { diff --git a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODReader.m b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODReader.m index a96e242db..5e6ea4af4 100644 --- a/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODReader.m +++ b/Example/Pods/SJMediaCacheServer/SJMediaCacheServer/Core/Resource/VOD/MCSVODReader.m @@ -55,7 +55,8 @@ - (instancetype)initWithResource:(__weak MCSVODResource *)resource request:(NSUR _resource = resource; _request = request; - + _offset = _request.mcs_range.location; + [_resource readWrite_retain]; [MCSResourceManager.shared reader:self willReadResource:_resource]; @@ -158,7 +159,7 @@ - (NSData *)readDataOfLength:(NSUInteger)length { - (NSUInteger)offset { [self lock]; @try { - return _offset + _request.mcs_range.location; + return _offset; } @catch (__unused NSException *exception) { } @finally { @@ -201,13 +202,8 @@ - (BOOL)isClosed { - (void)close { [self lock]; - @try { - [self _close]; - } @catch (__unused NSException *exception) { - - } @finally { - [self unlock]; - } + [self _close]; + [self unlock]; } #pragma mark - @@ -307,7 +303,6 @@ - (void)_close { if ( _isClosed ) return; - _isClosed = YES; for ( id reader in _readers ) { [reader close]; } @@ -316,6 +311,7 @@ - (void)_close { [content readWrite_release]; } + _isClosed = YES; MCSLog(@"%@: <%p>.close { range: %@ };\n", NSStringFromClass(self.class), self, NSStringFromRange(_request.mcs_range)); } @@ -332,16 +328,21 @@ - (void)unlock { #pragma mark - MCSVODMetaDataReaderDelegate - (void)metaDataReader:(MCSVODMetaDataReader *)reader didCompleteWithError:(NSError *_Nullable)error { - if ( error ) { - [self lock]; - [self _onError:error]; + [self lock]; + @try { + if ( error ) { + [self _onError:error]; + return; + } + + [_resource updateServer:reader.server contentType:reader.contentType totalLength:reader.totalLength pathExtension:reader.pathExtension]; + + [self _prepare]; + } @catch (__unused NSException *exception) { + + } @finally { [self unlock]; - return; } - - [_resource updateServer:reader.server contentType:reader.contentType totalLength:reader.totalLength pathExtension:reader.pathExtension]; - - [self _prepare]; } #pragma mark - MCSResourceDataReaderDelegate diff --git a/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate b/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate index 1349eecef..062d8fbd1 100644 Binary files a/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate and b/Example/SJVideoPlayer.xcworkspace/xcuserdata/bluedancer.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SJVideoPlayer/Common/Implements/SJLoadingView.m b/SJVideoPlayer/Common/Implements/SJLoadingView.m index 7886d9667..a25c43d26 100644 --- a/SJVideoPlayer/Common/Implements/SJLoadingView.m +++ b/SJVideoPlayer/Common/Implements/SJLoadingView.m @@ -171,7 +171,7 @@ - (void)setShowNetworkSpeed:(BOOL)showNetworkSpeed { _speedLabel.hidden = !showNetworkSpeed; } - (BOOL)showNetworkSpeed { - return _speedLabel.isHidden; + return !_speedLabel.isHidden; } - (void)setNetworkSpeedStr:(nullable NSAttributedString *)networkSpeedStr {