Skip to content

Commit

Permalink
SGPlayer: Platform.
Browse files Browse the repository at this point in the history
  • Loading branch information
libobjc committed Aug 15, 2019
1 parent 5a0320a commit 491df7f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions SGPlayer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@
9C6F902D219BE154001051CE /* SGMutableAsset.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C6F9028219BE154001051CE /* SGMutableAsset.m */; };
9C6F902E219BE154001051CE /* SGMutableAsset.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C6F9028219BE154001051CE /* SGMutableAsset.m */; };
9C82EEB121AE356D00E9D523 /* SGAudioProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C82EEAF21AE356D00E9D523 /* SGAudioProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; };
9C82EEB221AE356D00E9D523 /* SGAudioProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C82EEAF21AE356D00E9D523 /* SGAudioProcessor.h */; };
9C82EEB321AE356D00E9D523 /* SGAudioProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C82EEAF21AE356D00E9D523 /* SGAudioProcessor.h */; };
9C82EEB221AE356D00E9D523 /* SGAudioProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C82EEAF21AE356D00E9D523 /* SGAudioProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; };
9C82EEB321AE356D00E9D523 /* SGAudioProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C82EEAF21AE356D00E9D523 /* SGAudioProcessor.h */; settings = {ATTRIBUTES = (Public, ); }; };
9C82EEB421AE356D00E9D523 /* SGAudioProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C82EEB021AE356D00E9D523 /* SGAudioProcessor.m */; };
9C82EEB521AE356D00E9D523 /* SGAudioProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C82EEB021AE356D00E9D523 /* SGAudioProcessor.m */; };
9C82EEB621AE356D00E9D523 /* SGAudioProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C82EEB021AE356D00E9D523 /* SGAudioProcessor.m */; };
Expand Down Expand Up @@ -1410,6 +1410,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
9C82EEB221AE356D00E9D523 /* SGAudioProcessor.h in Headers */,
9C86385721904A0900D730EC /* SGPLFScreen.h in Headers */,
9C86388721904A0900D730EC /* SGDemuxable.h in Headers */,
9C86385F21904A0900D730EC /* SGURLDemuxer.h in Headers */,
Expand All @@ -1436,7 +1437,6 @@
9C525D5221AEC421005C5708 /* SGAudioDescriptor.h in Headers */,
9C55337221B25EC000119235 /* SGData.h in Headers */,
9C4190FE21B00FC600134099 /* SGMutableTrack.h in Headers */,
9C82EEB221AE356D00E9D523 /* SGAudioProcessor.h in Headers */,
9C8D6B8522C4A19500985D55 /* SGMetalPlaneModel.h in Headers */,
9CE71916219C3F7900256485 /* SGURLSegment.h in Headers */,
9CE7191E219C408300256485 /* SGSegment.h in Headers */,
Expand Down Expand Up @@ -1519,6 +1519,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
9C82EEB321AE356D00E9D523 /* SGAudioProcessor.h in Headers */,
9CD79F032190068E00E39A7D /* SGPLFScreen.h in Headers */,
9CD79F6B2190068E00E39A7D /* SGDemuxable.h in Headers */,
9CD79F0C2190068E00E39A7D /* SGURLDemuxer.h in Headers */,
Expand All @@ -1545,7 +1546,6 @@
9C525D5321AEC421005C5708 /* SGAudioDescriptor.h in Headers */,
9C55337321B25EC000119235 /* SGData.h in Headers */,
9C4190FF21B00FC600134099 /* SGMutableTrack.h in Headers */,
9C82EEB321AE356D00E9D523 /* SGAudioProcessor.h in Headers */,
9C8D6B8622C4A19500985D55 /* SGMetalPlaneModel.h in Headers */,
9CE71917219C3F7900256485 /* SGURLSegment.h in Headers */,
9CE7191F219C408300256485 /* SGSegment.h in Headers */,
Expand Down
2 changes: 1 addition & 1 deletion SGPlayer/Classes/Core/SGAudio/SGAudioPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ + (AudioComponentDescription)outputACD
AudioComponentDescription acd;
acd.componentType = kAudioUnitType_Output;
#if SGPLATFORM_TARGET_OS_MAC
acd.componentSuype = kAudioUnitSubType_DefaultOutput;
acd.componentSubType = kAudioUnitSubType_DefaultOutput;
#elif SGPLATFORM_TARGET_OS_IPHONE_OR_TV
acd.componentSubType = kAudioUnitSubType_RemoteIO;
#endif
Expand Down
2 changes: 2 additions & 0 deletions SGPlayer/Classes/SGPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
/**
*
*/
#if SGPLATFORM_TARGET_OS_IPHONE_OR_TV
@property (nonatomic) BOOL pausesWhenInterrupted;
#endif

/**
*
Expand Down
15 changes: 8 additions & 7 deletions SGPlayer/Classes/SGPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ - (instancetype)init
[self stop];
self->_options = [SGOptions sharedOptions].copy;
self->_rate = 1.0;
self->_pausesWhenInterrupted = YES;
self->_lock = [[NSLock alloc] init];
self->_clock = [[SGClock alloc] init];
self->_clock.delegate = self;
Expand All @@ -70,17 +69,19 @@ - (instancetype)init
self->_actionMask = SGInfoActionNone;
self->_minimumTimeInfoInterval = 1.0;
self->_notificationQueue = [NSOperationQueue mainQueue];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(interruptionHandler:)
name:AVAudioSessionInterruptionNotification
object:nil];
#if SGPLATFORM_TARGET_OS_IPHONE_OR_TV
self->_pausesWhenInterrupted = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(interruptionHandler:) name:AVAudioSessionInterruptionNotification object:nil];
#endif
}
return self;
}

- (void)dealloc
{
#if SGPLATFORM_TARGET_OS_IPHONE_OR_TV
[[NSNotificationCenter defaultCenter] removeObserver:self];
#endif
[SGActivity removeTarget:self];
[self->_currentItem close];
[self->_clock close];
Expand Down Expand Up @@ -635,8 +636,7 @@ + (SGInfoAction)infoActionFromUserInfo:(NSDictionary *)userInfo
return [userInfo[SGPlayerInfoActionUserInfoKey] unsignedIntegerValue];
}

#pragma mark - AVAudioSession

#if SGPLATFORM_TARGET_OS_IPHONE_OR_TV
- (void)interruptionHandler:(NSNotification *)notification
{
if (self->_pausesWhenInterrupted == NO) {
Expand All @@ -647,5 +647,6 @@ - (void)interruptionHandler:(NSNotification *)notification
[self pause];
}
}
#endif

@end

0 comments on commit 491df7f

Please sign in to comment.