diff --git a/AsyncDisplayKit/ASVideoNode.h b/AsyncDisplayKit/ASVideoNode.h index 4ea0006877..f54a8cb149 100644 --- a/AsyncDisplayKit/ASVideoNode.h +++ b/AsyncDisplayKit/ASVideoNode.h @@ -12,6 +12,14 @@ @class AVAsset, AVPlayer, AVPlayerItem; @protocol ASVideoNodeDelegate; +typedef enum { + ASVideoNodePlayerStateUnknown, + ASVideoNodePlayerStatePlaying, + ASVideoNodePlayerStateLoading, + ASVideoNodePlayerStatePaused, + ASVideoNodePlayerStateFinished +} ASVideoNodePlayerState; + NS_ASSUME_NONNULL_BEGIN // IMPORTANT NOTES: @@ -40,6 +48,10 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign, readwrite) BOOL muted; +@property (nonatomic, assign, readonly) ASVideoNodePlayerState playerState; +//! Defaults to 100 +@property (nonatomic, assign, readwrite) int32_t periodicTimeObserverTimescale; + //! Defaults to AVLayerVideoGravityResizeAspect @property (atomic) NSString *gravity; @@ -63,6 +75,31 @@ NS_ASSUME_NONNULL_BEGIN * @discussion The video's play state is toggled if this method is not implemented. */ - (void)videoNodeWasTapped:(ASVideoNode *)videoNode; +/** + * @abstract Delegate method invoked when player changes state. + * @param videoNode The video node that was tapped. + * @param state player state before this change. + * @param toSate player new state. + * @discussion This method is called after each state change + */ +- (void)videoNode:(ASVideoNode *)videoNode willChangePlayerState:(ASVideoNodePlayerState)state toState:(ASVideoNodePlayerState)toSate; +/** + * @abstract Ssks delegate if state change is allowed + * ASVideoNodePlayerStatePlaying or ASVideoNodePlayerStatePaused. + * asks delegate if state change is allowed. + * @param videoNode The video node that was tapped. + * @param state player state that is going to be set. + * @discussion Delegate method invoked when player changes it's state to + * ASVideoNodePlayerStatePlaying or ASVideoNodePlayerStatePaused + * and asks delegate if state change is valid + */ +- (BOOL)videoNode:(ASVideoNode*)videoNode shouldChangePlayerStateTo:(ASVideoNodePlayerState)state; +/** + * @abstract Delegate method invoked when player playback time is updated. + * @param videoNode The video node that was tapped. + * @param second current playback time in seconds. + */ +- (void)videoNode:(ASVideoNode *)videoNode didPlayToSecond:(NSTimeInterval)second; @end NS_ASSUME_NONNULL_END #endif diff --git a/AsyncDisplayKit/ASVideoNode.mm b/AsyncDisplayKit/ASVideoNode.mm index 3cf7b34c0e..ad417115e7 100644 --- a/AsyncDisplayKit/ASVideoNode.mm +++ b/AsyncDisplayKit/ASVideoNode.mm @@ -43,11 +43,17 @@ static NSString * const kStatus = @"status"; BOOL _muted; + ASVideoNodePlayerState _playerState; + AVAsset *_asset; AVPlayerItem *_currentPlayerItem; AVPlayer *_player; + id _timeObserver; + int32_t _periodicTimeObserverTimescale; + CMTime _timeObserverInterval; + ASImageNode *_placeholderImageNode; // TODO: Make ASVideoNode an ASImageNode subclass; remove this. ASButtonNode *_playButton; @@ -72,6 +78,7 @@ static NSString * const kStatus = @"status"; self.playButton = [[ASDefaultPlayButton alloc] init]; self.gravity = AVLayerVideoGravityResizeAspect; + _periodicTimeObserverTimescale = 10000; [self addTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside]; return self; @@ -231,11 +238,13 @@ static NSString * const kStatus = @"status"; if ([change[NSKeyValueChangeNewKey] integerValue] == AVPlayerItemStatusReadyToPlay) { [_spinner removeFromSupernode]; _spinner = nil; - // If we don't yet have a placeholder image update it now that we should have data available for it if (_placeholderImageNode.image == nil) { [self generatePlaceholderImage]; } + if(_shouldBePlaying) { + self.playerState = ASVideoNodePlayerStatePlaying; + } } } else if ([keyPath isEqualToString:kPlaybackLikelyToKeepUpKey]) { if (_shouldBePlaying && [change[NSKeyValueChangeNewKey] boolValue] == true && ASInterfaceStateIncludesVisible(self.interfaceState)) { @@ -276,6 +285,24 @@ static NSString * const kStatus = @"status"; if (_placeholderImageNode.image == nil) { [self generatePlaceholderImage]; } + + __weak __typeof(self) weakSelf = self; + _timeObserverInterval = CMTimeMake(1, _periodicTimeObserverTimescale); + _timeObserver = [_player addPeriodicTimeObserverForInterval:_timeObserverInterval queue:NULL usingBlock:^(CMTime time){ + [weakSelf periodicTimeObserver:time]; + }]; + } +} + +- (void)periodicTimeObserver:(CMTime)time +{ + NSTimeInterval timeInSeconds = CMTimeGetSeconds(time); + if (timeInSeconds <= 0) { + return; + } + + if(_delegate && [_delegate respondsToSelector:@selector(videoNode:didPlayToSecond:)]){ + [_delegate videoNode:self didPlayToSecond:timeInSeconds]; } } @@ -310,6 +337,23 @@ static NSString * const kStatus = @"status"; #pragma mark - Video Properties +- (void)setPlayerState:(ASVideoNodePlayerState)playerState +{ + ASDN::MutexLocker l(_videoLock); + + ASVideoNodePlayerState oldState = _playerState; + + if(oldState == playerState) { + return; + } + + if ([_delegate respondsToSelector:@selector(videoNode:willChangePlayerState:toState:)]) { + [_delegate videoNode:self willChangePlayerState:oldState toState:playerState]; + } + + _playerState = playerState; + +} - (void)setPlayButton:(ASButtonNode *)playButton { @@ -400,6 +444,10 @@ static NSString * const kStatus = @"status"; - (void)play { ASDN::MutexLocker l(_videoLock); + + if(![self isStateChangeValid:ASVideoNodePlayerStatePlaying]){ + return; + } if (_player == nil) { [self setNeedsDataFetch]; @@ -415,13 +463,13 @@ static NSString * const kStatus = @"status"; } } + [_player play]; _shouldBePlaying = YES; [UIView animateWithDuration:0.15 animations:^{ _playButton.alpha = 0.0; }]; - if (![self ready]) { if (!_spinner) { _spinner = [[ASDisplayNode alloc] initWithViewBlock:^UIView *{ @@ -433,8 +481,10 @@ static NSString * const kStatus = @"status"; [self addSubnode:_spinner]; } - + self.playerState = ASVideoNodePlayerStateLoading; [(UIActivityIndicatorView *)_spinner.view startAnimating]; + }else{ + self.playerState = ASVideoNodePlayerStatePlaying; } } @@ -446,7 +496,10 @@ static NSString * const kStatus = @"status"; - (void)pause { ASDN::MutexLocker l(_videoLock); - + if(![self isStateChangeValid:ASVideoNodePlayerStatePaused]){ + return; + } + self.playerState = ASVideoNodePlayerStatePaused; [_player pause]; [((UIActivityIndicatorView *)_spinner.view) stopAnimating]; _shouldBePlaying = NO; @@ -462,11 +515,22 @@ static NSString * const kStatus = @"status"; return (_player.rate > 0 && !_player.error); } +- (BOOL)isStateChangeValid:(ASVideoNodePlayerState)state +{ + if([_delegate respondsToSelector:@selector(videoNode:shouldChangePlayerStateTo:)]){ + if(![_delegate videoNode:self shouldChangePlayerStateTo:state]){ + return NO; + } + } + return YES; +} + #pragma mark - Playback observers - (void)didPlayToEnd:(NSNotification *)notification { + self.playerState = ASVideoNodePlayerStateFinished; if ([_delegate respondsToSelector:@selector(videoPlaybackDidFinish:)]) { [_delegate videoPlaybackDidFinish:self]; } @@ -563,6 +627,8 @@ static NSString * const kStatus = @"status"; - (void)dealloc { + [_player removeTimeObserver:_timeObserver]; + _timeObserver = nil; [_playButton removeTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside]; [self removePlayerItemObservers:_currentPlayerItem]; } diff --git a/examples/Videos/Sample.xcodeproj/project.pbxproj b/examples/Videos/Sample.xcodeproj/project.pbxproj index 9db006ee2b..b43c7e7fc8 100644 --- a/examples/Videos/Sample.xcodeproj/project.pbxproj +++ b/examples/Videos/Sample.xcodeproj/project.pbxproj @@ -1,806 +1,377 @@ - - - - - archiveVersion - 1 - classes - - objectVersion - 46 - objects - - 0585427F19D4DBE100606EA6 - - isa - PBXFileReference - lastKnownFileType - image.png - name - Default-568h@2x.png - path - ../Default-568h@2x.png - sourceTree - <group> - - 0585428019D4DBE100606EA6 - - fileRef - 0585427F19D4DBE100606EA6 - isa - PBXBuildFile - - 05E2127819D4DB510098F589 - - children - - 05E2128319D4DB510098F589 - 05E2128219D4DB510098F589 - 1A943BF0259746F18D6E423F - 1AE410B73DA5C3BD087ACDD7 - - indentWidth - 2 - isa - PBXGroup - sourceTree - <group> - tabWidth - 2 - usesTabs - 0 - - 05E2127919D4DB510098F589 - - attributes - - LastUpgradeCheck - 0600 - ORGANIZATIONNAME - Facebook - TargetAttributes - - 05E2128019D4DB510098F589 - - CreatedOnToolsVersion - 6.0.1 - - - - buildConfigurationList - 05E2127C19D4DB510098F589 - compatibilityVersion - Xcode 3.2 - developmentRegion - English - hasScannedForEncodings - 0 - isa - PBXProject - knownRegions - - en - Base - - mainGroup - 05E2127819D4DB510098F589 - productRefGroup - 05E2128219D4DB510098F589 - projectDirPath - - projectReferences - - projectRoot - - targets - - 05E2128019D4DB510098F589 - - - 05E2127C19D4DB510098F589 - - buildConfigurations - - 05E212A219D4DB510098F589 - 05E212A319D4DB510098F589 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 05E2127D19D4DB510098F589 - - buildActionMask - 2147483647 - files - - 05E2128D19D4DB510098F589 - 05E2128A19D4DB510098F589 - 05E2128719D4DB510098F589 - - isa - PBXSourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 05E2127E19D4DB510098F589 - - buildActionMask - 2147483647 - files - - 5791C5525B690FA54F26ACE8 - - isa - PBXFrameworksBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 05E2127F19D4DB510098F589 - - buildActionMask - 2147483647 - files - - AE8E41191C228A4A00913AC4 - AED850671C22679200183ED3 - 0585428019D4DBE100606EA6 - 6C2C82AC19EE274300767484 - AE8E411B1C23634C00913AC4 - 6C2C82AD19EE274300767484 - AEE1F2C01C293CF1005E0577 - - isa - PBXResourcesBuildPhase - runOnlyForDeploymentPostprocessing - 0 - - 05E2128019D4DB510098F589 - - buildConfigurationList - 05E212A419D4DB510098F589 - buildPhases - - E080B80F89C34A25B3488E26 - 05E2127D19D4DB510098F589 - 05E2127E19D4DB510098F589 - 05E2127F19D4DB510098F589 - F012A6F39E0149F18F564F50 - 93B7780A33739EF25F20366B - - buildRules - - dependencies - - isa - PBXNativeTarget - name - Sample - productName - Sample - productReference - 05E2128119D4DB510098F589 - productType - com.apple.product-type.application - - 05E2128119D4DB510098F589 - - explicitFileType - wrapper.application - includeInIndex - 0 - isa - PBXFileReference - path - Sample.app - sourceTree - BUILT_PRODUCTS_DIR - - 05E2128219D4DB510098F589 - - children - - 05E2128119D4DB510098F589 - - isa - PBXGroup - name - Products - sourceTree - <group> - - 05E2128319D4DB510098F589 - - children - - AED850661C22679200183ED3 - AEE1F2BF1C293CF1005E0577 - AE8E41181C228A4A00913AC4 - AE8E411A1C235A6000913AC4 - 05E2128819D4DB510098F589 - 05E2128919D4DB510098F589 - 05E2128B19D4DB510098F589 - 05E2128C19D4DB510098F589 - 05E2128419D4DB510098F589 - - isa - PBXGroup - path - Sample - sourceTree - <group> - - 05E2128419D4DB510098F589 - - children - - 0585427F19D4DBE100606EA6 - 6C2C82AA19EE274300767484 - 6C2C82AB19EE274300767484 - 05E2128519D4DB510098F589 - 05E2128619D4DB510098F589 - - isa - PBXGroup - name - Supporting Files - sourceTree - <group> - - 05E2128519D4DB510098F589 - - isa - PBXFileReference - lastKnownFileType - text.plist.xml - path - Info.plist - sourceTree - <group> - - 05E2128619D4DB510098F589 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - main.m - sourceTree - <group> - - 05E2128719D4DB510098F589 - - fileRef - 05E2128619D4DB510098F589 - isa - PBXBuildFile - - 05E2128819D4DB510098F589 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - AppDelegate.h - sourceTree - <group> - - 05E2128919D4DB510098F589 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - AppDelegate.m - sourceTree - <group> - - 05E2128A19D4DB510098F589 - - fileRef - 05E2128919D4DB510098F589 - isa - PBXBuildFile - - 05E2128B19D4DB510098F589 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.h - path - ViewController.h - sourceTree - <group> - - 05E2128C19D4DB510098F589 - - isa - PBXFileReference - lastKnownFileType - sourcecode.c.objc - path - ViewController.m - sourceTree - <group> - - 05E2128D19D4DB510098F589 - - fileRef - 05E2128C19D4DB510098F589 - isa - PBXBuildFile - - 05E212A219D4DB510098F589 - - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - YES - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - CLANG_WARN_UNREACHABLE_CODE - YES - CLANG_WARN__DUPLICATE_METHOD_MATCH - YES - CODE_SIGN_IDENTITY[sdk=iphoneos*] - iPhone Developer - COPY_PHASE_STRIP - NO - ENABLE_STRICT_OBJC_MSGSEND - YES - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_DYNAMIC_NO_PIC - NO - GCC_OPTIMIZATION_LEVEL - 0 - GCC_PREPROCESSOR_DEFINITIONS - - DEBUG=1 - $(inherited) - - GCC_SYMBOLS_PRIVATE_EXTERN - NO - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES_AGGRESSIVE - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - IPHONEOS_DEPLOYMENT_TARGET - 8.0 - MTL_ENABLE_DEBUG_INFO - YES - ONLY_ACTIVE_ARCH - YES - SDKROOT - iphoneos - - isa - XCBuildConfiguration - name - Debug - - 05E212A319D4DB510098F589 - - buildSettings - - ALWAYS_SEARCH_USER_PATHS - NO - CLANG_CXX_LANGUAGE_STANDARD - gnu++0x - CLANG_CXX_LIBRARY - libc++ - CLANG_ENABLE_MODULES - YES - CLANG_ENABLE_OBJC_ARC - YES - CLANG_WARN_BOOL_CONVERSION - YES - CLANG_WARN_CONSTANT_CONVERSION - YES - CLANG_WARN_DIRECT_OBJC_ISA_USAGE - YES_ERROR - CLANG_WARN_EMPTY_BODY - YES - CLANG_WARN_ENUM_CONVERSION - YES - CLANG_WARN_INT_CONVERSION - YES - CLANG_WARN_OBJC_ROOT_CLASS - YES_ERROR - CLANG_WARN_UNREACHABLE_CODE - YES - CLANG_WARN__DUPLICATE_METHOD_MATCH - YES - CODE_SIGN_IDENTITY[sdk=iphoneos*] - iPhone Developer - COPY_PHASE_STRIP - YES - ENABLE_NS_ASSERTIONS - NO - ENABLE_STRICT_OBJC_MSGSEND - YES - GCC_C_LANGUAGE_STANDARD - gnu99 - GCC_WARN_64_TO_32_BIT_CONVERSION - YES - GCC_WARN_ABOUT_RETURN_TYPE - YES_ERROR - GCC_WARN_UNDECLARED_SELECTOR - YES - GCC_WARN_UNINITIALIZED_AUTOS - YES_AGGRESSIVE - GCC_WARN_UNUSED_FUNCTION - YES - GCC_WARN_UNUSED_VARIABLE - YES - IPHONEOS_DEPLOYMENT_TARGET - 8.0 - MTL_ENABLE_DEBUG_INFO - NO - SDKROOT - iphoneos - VALIDATE_PRODUCT - YES - - isa - XCBuildConfiguration - name - Release - - 05E212A419D4DB510098F589 - - buildConfigurations - - 05E212A519D4DB510098F589 - 05E212A619D4DB510098F589 - - defaultConfigurationIsVisible - 0 - defaultConfigurationName - Release - isa - XCConfigurationList - - 05E212A519D4DB510098F589 - - baseConfigurationReference - CFD6AA1D30516C27DEE5602B - buildSettings - - ASSETCATALOG_COMPILER_APPICON_NAME - AppIcon - INFOPLIST_FILE - Sample/Info.plist - LD_RUNPATH_SEARCH_PATHS - $(inherited) @executable_path/Frameworks - PRODUCT_NAME - $(TARGET_NAME) - - isa - XCBuildConfiguration - name - Debug - - 05E212A619D4DB510098F589 - - baseConfigurationReference - E51646FF8D3676A1D826A5AE - buildSettings - - ASSETCATALOG_COMPILER_APPICON_NAME - AppIcon - INFOPLIST_FILE - Sample/Info.plist - LD_RUNPATH_SEARCH_PATHS - $(inherited) @executable_path/Frameworks - PRODUCT_NAME - $(TARGET_NAME) - - isa - XCBuildConfiguration - name - Release - - 1A943BF0259746F18D6E423F - - children - - A2092CAF5607B3863A3700A2 - - isa - PBXGroup - name - Frameworks - sourceTree - <group> - - 1AE410B73DA5C3BD087ACDD7 - - children - - CFD6AA1D30516C27DEE5602B - E51646FF8D3676A1D826A5AE - - isa - PBXGroup - name - Pods - sourceTree - <group> - - 5791C5525B690FA54F26ACE8 - - fileRef - A2092CAF5607B3863A3700A2 - isa - PBXBuildFile - - 6C2C82AA19EE274300767484 - - isa - PBXFileReference - lastKnownFileType - image.png - path - Default-667h@2x.png - sourceTree - SOURCE_ROOT - - 6C2C82AB19EE274300767484 - - isa - PBXFileReference - lastKnownFileType - image.png - path - Default-736h@3x.png - sourceTree - SOURCE_ROOT - - 6C2C82AC19EE274300767484 - - fileRef - 6C2C82AA19EE274300767484 - isa - PBXBuildFile - - 6C2C82AD19EE274300767484 - - fileRef - 6C2C82AB19EE274300767484 - isa - PBXBuildFile - - 93B7780A33739EF25F20366B - - buildActionMask - 2147483647 - files - - inputPaths - - isa - PBXShellScriptBuildPhase - name - Embed Pods Frameworks - outputPaths - - runOnlyForDeploymentPostprocessing - 0 - shellPath - /bin/sh - shellScript - "${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh" - - showEnvVarsInLog - 0 - - A2092CAF5607B3863A3700A2 - - explicitFileType - archive.ar - includeInIndex - 0 - isa - PBXFileReference - path - libPods-Sample.a - sourceTree - BUILT_PRODUCTS_DIR - - AE8E41181C228A4A00913AC4 - - isa - PBXFileReference - lastKnownFileType - image.jpeg - path - bearacrat@2x.jpg - sourceTree - <group> - - AE8E41191C228A4A00913AC4 - - fileRef - AE8E41181C228A4A00913AC4 - isa - PBXBuildFile - - AE8E411A1C235A6000913AC4 - - isa - PBXFileReference - lastKnownFileType - file - path - simon.mp4 - sourceTree - <group> - - AE8E411B1C23634C00913AC4 - - fileRef - AE8E411A1C235A6000913AC4 - isa - PBXBuildFile - - AED850661C22679200183ED3 - - isa - PBXFileReference - lastKnownFileType - image.png - path - playButton@2x.png - sourceTree - <group> - - AED850671C22679200183ED3 - - fileRef - AED850661C22679200183ED3 - isa - PBXBuildFile - - AEE1F2BF1C293CF1005E0577 - - isa - PBXFileReference - lastKnownFileType - image.png - path - playButtonSelected@2x.png - sourceTree - <group> - - AEE1F2C01C293CF1005E0577 - - fileRef - AEE1F2BF1C293CF1005E0577 - isa - PBXBuildFile - - CFD6AA1D30516C27DEE5602B - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - text.xcconfig - name - Pods-Sample.debug.xcconfig - path - Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig - sourceTree - <group> - - E080B80F89C34A25B3488E26 - - buildActionMask - 2147483647 - files - - inputPaths - - isa - PBXShellScriptBuildPhase - name - Check Pods Manifest.lock - outputPaths - - runOnlyForDeploymentPostprocessing - 0 - shellPath - /bin/sh - shellScript - diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null -if [[ $? != 0 ]] ; then - cat << EOM -error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. -EOM - exit 1 -fi - - showEnvVarsInLog - 0 - - E51646FF8D3676A1D826A5AE - - includeInIndex - 1 - isa - PBXFileReference - lastKnownFileType - text.xcconfig - name - Pods-Sample.release.xcconfig - path - Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig - sourceTree - <group> - - F012A6F39E0149F18F564F50 - - buildActionMask - 2147483647 - files - - inputPaths - - isa - PBXShellScriptBuildPhase - name - Copy Pods Resources - outputPaths - - runOnlyForDeploymentPostprocessing - 0 - shellPath - /bin/sh - shellScript - "${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh" - - showEnvVarsInLog - 0 - - - rootObject - 05E2127919D4DB510098F589 - - +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 0585428019D4DBE100606EA6 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 0585427F19D4DBE100606EA6 /* Default-568h@2x.png */; }; + 05E2128719D4DB510098F589 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128619D4DB510098F589 /* main.m */; }; + 05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128919D4DB510098F589 /* AppDelegate.m */; }; + 05E2128D19D4DB510098F589 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 05E2128C19D4DB510098F589 /* ViewController.m */; }; + 5791C5525B690FA54F26ACE8 /* libPods-Sample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A2092CAF5607B3863A3700A2 /* libPods-Sample.a */; }; + 6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AA19EE274300767484 /* Default-667h@2x.png */; }; + 6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6C2C82AB19EE274300767484 /* Default-736h@3x.png */; }; + AE8E41191C228A4A00913AC4 /* bearacrat@2x.jpg in Resources */ = {isa = PBXBuildFile; fileRef = AE8E41181C228A4A00913AC4 /* bearacrat@2x.jpg */; }; + AE8E411B1C23634C00913AC4 /* simon.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = AE8E411A1C235A6000913AC4 /* simon.mp4 */; }; + AED850671C22679200183ED3 /* playButton@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = AED850661C22679200183ED3 /* playButton@2x.png */; }; + AEE1F2C01C293CF1005E0577 /* playButtonSelected@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = AEE1F2BF1C293CF1005E0577 /* playButtonSelected@2x.png */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0585427F19D4DBE100606EA6 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "../Default-568h@2x.png"; sourceTree = ""; }; + 05E2128119D4DB510098F589 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 05E2128519D4DB510098F589 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 05E2128619D4DB510098F589 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 05E2128819D4DB510098F589 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 05E2128919D4DB510098F589 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 05E2128B19D4DB510098F589 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 05E2128C19D4DB510098F589 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 6C2C82AA19EE274300767484 /* Default-667h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-667h@2x.png"; sourceTree = SOURCE_ROOT; }; + 6C2C82AB19EE274300767484 /* Default-736h@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-736h@3x.png"; sourceTree = SOURCE_ROOT; }; + A2092CAF5607B3863A3700A2 /* libPods-Sample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Sample.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + AE8E41181C228A4A00913AC4 /* bearacrat@2x.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "bearacrat@2x.jpg"; sourceTree = ""; }; + AE8E411A1C235A6000913AC4 /* simon.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = simon.mp4; sourceTree = ""; }; + AED850661C22679200183ED3 /* playButton@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "playButton@2x.png"; sourceTree = ""; }; + AEE1F2BF1C293CF1005E0577 /* playButtonSelected@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "playButtonSelected@2x.png"; sourceTree = ""; }; + CFD6AA1D30516C27DEE5602B /* Pods-Sample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.debug.xcconfig"; sourceTree = ""; }; + E51646FF8D3676A1D826A5AE /* Pods-Sample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Sample.release.xcconfig"; path = "Pods/Target Support Files/Pods-Sample/Pods-Sample.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 05E2127E19D4DB510098F589 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 5791C5525B690FA54F26ACE8 /* libPods-Sample.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 05E2127819D4DB510098F589 = { + isa = PBXGroup; + children = ( + 05E2128319D4DB510098F589 /* Sample */, + 05E2128219D4DB510098F589 /* Products */, + 1A943BF0259746F18D6E423F /* Frameworks */, + 1AE410B73DA5C3BD087ACDD7 /* Pods */, + ); + indentWidth = 2; + sourceTree = ""; + tabWidth = 2; + usesTabs = 0; + }; + 05E2128219D4DB510098F589 /* Products */ = { + isa = PBXGroup; + children = ( + 05E2128119D4DB510098F589 /* Sample.app */, + ); + name = Products; + sourceTree = ""; + }; + 05E2128319D4DB510098F589 /* Sample */ = { + isa = PBXGroup; + children = ( + AED850661C22679200183ED3 /* playButton@2x.png */, + AEE1F2BF1C293CF1005E0577 /* playButtonSelected@2x.png */, + AE8E41181C228A4A00913AC4 /* bearacrat@2x.jpg */, + AE8E411A1C235A6000913AC4 /* simon.mp4 */, + 05E2128819D4DB510098F589 /* AppDelegate.h */, + 05E2128919D4DB510098F589 /* AppDelegate.m */, + 05E2128B19D4DB510098F589 /* ViewController.h */, + 05E2128C19D4DB510098F589 /* ViewController.m */, + 05E2128419D4DB510098F589 /* Supporting Files */, + ); + path = Sample; + sourceTree = ""; + }; + 05E2128419D4DB510098F589 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 0585427F19D4DBE100606EA6 /* Default-568h@2x.png */, + 6C2C82AA19EE274300767484 /* Default-667h@2x.png */, + 6C2C82AB19EE274300767484 /* Default-736h@3x.png */, + 05E2128519D4DB510098F589 /* Info.plist */, + 05E2128619D4DB510098F589 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 1A943BF0259746F18D6E423F /* Frameworks */ = { + isa = PBXGroup; + children = ( + A2092CAF5607B3863A3700A2 /* libPods-Sample.a */, + ); + name = Frameworks; + sourceTree = ""; + }; + 1AE410B73DA5C3BD087ACDD7 /* Pods */ = { + isa = PBXGroup; + children = ( + CFD6AA1D30516C27DEE5602B /* Pods-Sample.debug.xcconfig */, + E51646FF8D3676A1D826A5AE /* Pods-Sample.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 05E2128019D4DB510098F589 /* Sample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */; + buildPhases = ( + E080B80F89C34A25B3488E26 /* 📦 Check Pods Manifest.lock */, + 05E2127D19D4DB510098F589 /* Sources */, + 05E2127E19D4DB510098F589 /* Frameworks */, + 05E2127F19D4DB510098F589 /* Resources */, + F012A6F39E0149F18F564F50 /* 📦 Copy Pods Resources */, + 93B7780A33739EF25F20366B /* 📦 Embed Pods Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Sample; + productName = Sample; + productReference = 05E2128119D4DB510098F589 /* Sample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 05E2127919D4DB510098F589 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0600; + ORGANIZATIONNAME = Facebook; + TargetAttributes = { + 05E2128019D4DB510098F589 = { + CreatedOnToolsVersion = 6.0.1; + }; + }; + }; + buildConfigurationList = 05E2127C19D4DB510098F589 /* Build configuration list for PBXProject "Sample" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 05E2127819D4DB510098F589; + productRefGroup = 05E2128219D4DB510098F589 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 05E2128019D4DB510098F589 /* Sample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 05E2127F19D4DB510098F589 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AE8E41191C228A4A00913AC4 /* bearacrat@2x.jpg in Resources */, + AED850671C22679200183ED3 /* playButton@2x.png in Resources */, + 0585428019D4DBE100606EA6 /* Default-568h@2x.png in Resources */, + 6C2C82AC19EE274300767484 /* Default-667h@2x.png in Resources */, + AE8E411B1C23634C00913AC4 /* simon.mp4 in Resources */, + 6C2C82AD19EE274300767484 /* Default-736h@3x.png in Resources */, + AEE1F2C01C293CF1005E0577 /* playButtonSelected@2x.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 93B7780A33739EF25F20366B /* 📦 Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "📦 Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + E080B80F89C34A25B3488E26 /* 📦 Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "📦 Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + F012A6F39E0149F18F564F50 /* 📦 Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "📦 Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Sample/Pods-Sample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 05E2127D19D4DB510098F589 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 05E2128D19D4DB510098F589 /* ViewController.m in Sources */, + 05E2128A19D4DB510098F589 /* AppDelegate.m in Sources */, + 05E2128719D4DB510098F589 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 05E212A219D4DB510098F589 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 05E212A319D4DB510098F589 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = YES; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 05E212A519D4DB510098F589 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = CFD6AA1D30516C27DEE5602B /* Pods-Sample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Sample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 05E212A619D4DB510098F589 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E51646FF8D3676A1D826A5AE /* Pods-Sample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = Sample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 05E2127C19D4DB510098F589 /* Build configuration list for PBXProject "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 05E212A219D4DB510098F589 /* Debug */, + 05E212A319D4DB510098F589 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 05E212A419D4DB510098F589 /* Build configuration list for PBXNativeTarget "Sample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 05E212A519D4DB510098F589 /* Debug */, + 05E212A619D4DB510098F589 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 05E2127919D4DB510098F589 /* Project object */; +} diff --git a/examples/Videos/Sample.xcworkspace/contents.xcworkspacedata b/examples/Videos/Sample.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..7b5a2f3050 --- /dev/null +++ b/examples/Videos/Sample.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/examples/Videos/Sample/ViewController.m b/examples/Videos/Sample/ViewController.m index 74e4ced00f..159f3ac53b 100644 --- a/examples/Videos/Sample/ViewController.m +++ b/examples/Videos/Sample/ViewController.m @@ -12,7 +12,7 @@ #import "ViewController.h" @interface ViewController() -@property (nonatomic) ASVideoNode *videoNode; +@property (nonatomic,strong) ASVideoNode *guitarVideoNode; @end @implementation ViewController @@ -20,9 +20,8 @@ - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; - - ASVideoNode *guitarVideo = [self guitarVideo]; - [self.view addSubnode:guitarVideo]; + + [self.view addSubnode:self.guitarVideoNode]; ASVideoNode *nicCageVideo = [self nicCageVideo]; [self.view addSubnode:nicCageVideo]; @@ -31,19 +30,26 @@ [self.view addSubnode:simonVideo]; } -- (ASVideoNode *)guitarVideo; +- (ASVideoNode *)guitarVideoNode; { - ASVideoNode *videoNode = [[ASVideoNode alloc] init]; + if(_guitarVideoNode){ + return _guitarVideoNode; + } + _guitarVideoNode = [[ASVideoNode alloc] init]; - videoNode.asset = [AVAsset assetWithURL:[NSURL URLWithString:@"https://files.parsetfss.com/8a8a3b0c-619e-4e4d-b1d5-1b5ba9bf2b42/tfss-3045b261-7e93-4492-b7e5-5d6358376c9f-editedLiveAndDie.mov"]]; + _guitarVideoNode.asset = [AVAsset assetWithURL:[NSURL URLWithString:@"https://files.parsetfss.com/8a8a3b0c-619e-4e4d-b1d5-1b5ba9bf2b42/tfss-3045b261-7e93-4492-b7e5-5d6358376c9f-editedLiveAndDie.mov"]]; - videoNode.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height/3); + _guitarVideoNode.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height/3); - videoNode.gravity = AVLayerVideoGravityResizeAspectFill; + _guitarVideoNode.gravity = AVLayerVideoGravityResizeAspectFill; - videoNode.backgroundColor = [UIColor lightGrayColor]; + _guitarVideoNode.backgroundColor = [UIColor lightGrayColor]; - return videoNode; + _guitarVideoNode.periodicTimeObserverTimescale = 1; //Default is 100 + + _guitarVideoNode.delegate = self; + + return _guitarVideoNode; } - (ASVideoNode *)nicCageVideo; @@ -62,7 +68,7 @@ nicCageVideo.shouldAutorepeat = YES; nicCageVideo.shouldAutoplay = YES; nicCageVideo.muted = YES; - + return nicCageVideo; } @@ -80,6 +86,7 @@ simonVideo.backgroundColor = [UIColor lightGrayColor]; simonVideo.shouldAutorepeat = YES; simonVideo.shouldAutoplay = YES; + simonVideo.muted = YES; return simonVideo; } @@ -94,12 +101,20 @@ playButton.bounds = CGRectMake(0, 0, playButton.calculatedSize.width, playButton.calculatedSize.height); playButton.position = CGPointMake([UIScreen mainScreen].bounds.size.width/4, ([UIScreen mainScreen].bounds.size.height/3)/2); [playButton setImage:[UIImage imageNamed:@"playButtonSelected@2x.png"] forState:ASControlStateHighlighted]; - + return playButton; } - (void)videoNodeWasTapped:(ASVideoNode *)videoNode { + if(videoNode == self.guitarVideoNode){ + if(videoNode.playerState == ASVideoNodePlayerStatePlaying){ + [videoNode pause]; + }else{ + [videoNode play]; + } + return; + } if (videoNode.player.muted == YES) { videoNode.player.muted = NO; } else { @@ -107,4 +122,28 @@ } } -@end +#pragma mark - ASVideoNodeDelegate +- (void)videoNode:(ASVideoNode *)videoNode willChangePlayerState:(ASVideoNodePlayerState)state toState:(ASVideoNodePlayerState)toSate{ + //Ignore nicCageVideo + if(videoNode != _guitarVideoNode){ + return; + } + + if(toSate == ASVideoNodePlayerStatePlaying){ + NSLog(@"guitarVideoNode is playing"); + }else if(toSate == ASVideoNodePlayerStateFinished){ + NSLog(@"guitarVideoNode finished"); + }else if(toSate == ASVideoNodePlayerStateLoading){ + NSLog(@"guitarVideoNode is buffering"); + } +} + +- (void)videoNode:(ASVideoNode *)videoNode didPlayToSecond:(NSTimeInterval)second{ + if(videoNode != _guitarVideoNode){ + return; + } + + NSLog(@"guitarVideoNode playback time is: %f",second); +} + +@end \ No newline at end of file