Skip to content

Commit

Permalink
refactor: use shared class property API
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjl-mux committed Nov 2, 2023
1 parent aa56265 commit 6676c0b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 57 deletions.
86 changes: 41 additions & 45 deletions Sources/MUXSDKStatsObjc/MUXSDKStats.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ + (nullable MUXSDKPlayerBinding *)monitorAVPlayerViewController:(nonnull AVPlaye
automaticErrorTracking:(BOOL)automaticErrorTracking
beaconCollectionDomain:(nullable NSString *)collectionDomain {

return [[MUXSDKMonitor sharedMonitor] startMonitoringPlayerViewController:player
withPlayerName:name
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:collectionDomain];
return [[MUXSDKMonitor shared] startMonitoringPlayerViewController:player
withPlayerName:name
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:collectionDomain];
}

+ (nullable MUXSDKPlayerBinding *)monitorAVPlayerViewController:(nonnull AVPlayerViewController *)player
Expand All @@ -38,7 +38,7 @@ + (nullable MUXSDKPlayerBinding *)monitorAVPlayerViewController:(nonnull AVPlaye
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:nil];

}

+ (nullable MUXSDKPlayerBinding *)monitorAVPlayerViewController:(nonnull AVPlayerViewController *)player
Expand All @@ -52,8 +52,8 @@ + (nullable MUXSDKPlayerBinding *)monitorAVPlayerViewController:(nonnull AVPlaye
}

+ (void)updateAVPlayerViewController:(nonnull AVPlayerViewController *)player withPlayerName:(nonnull NSString *)name {
[[MUXSDKMonitor sharedMonitor] updatePlayerViewController:player
withPlayerName:name];
[[MUXSDKMonitor shared] updatePlayerViewController:player
withPlayerName:name];
}

#pragma mark Monitor AVPlayerLayer
Expand All @@ -63,38 +63,38 @@ + (nullable MUXSDKPlayerBinding *)monitorAVPlayerLayer:(nonnull AVPlayerLayer *)
customerData:(nonnull MUXSDKCustomerData *)customerData
automaticErrorTracking:(BOOL)automaticErrorTracking
beaconCollectionDomain:(nullable NSString *)collectionDomain {
return [[MUXSDKMonitor sharedMonitor] startMonitoringPlayerLayer:player
withPlayerName:name
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:collectionDomain];
return [[MUXSDKMonitor shared] startMonitoringPlayerLayer:player
withPlayerName:name
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:collectionDomain];
}

+ (nullable MUXSDKPlayerBinding *)monitorAVPlayerLayer:(nonnull AVPlayerLayer *)player
withPlayerName:(nonnull NSString *)name
customerData:(nonnull MUXSDKCustomerData *)customerData
automaticErrorTracking:(BOOL)automaticErrorTracking {

return [self monitorAVPlayerLayer:player
withPlayerName:name
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:nil];
beaconCollectionDomain:nil];
}

+ (nullable MUXSDKPlayerBinding *)monitorAVPlayerLayer:(nonnull AVPlayerLayer *)player
withPlayerName:(nonnull NSString *)name
customerData:(nonnull MUXSDKCustomerData *)customerData {

return [self monitorAVPlayerLayer:player
withPlayerName:name
customerData:customerData
automaticErrorTracking:true];
}

+ (void)updateAVPlayerLayer:(AVPlayerLayer *)player withPlayerName:(NSString *)name {
[[MUXSDKMonitor sharedMonitor] updatePlayerLayer:player
withPlayerName:name];
[[MUXSDKMonitor shared] updatePlayerLayer:player
withPlayerName:name];
}

#pragma mark Monitor AVPlayer
Expand Down Expand Up @@ -130,78 +130,74 @@ + (nullable MUXSDKPlayerBinding *)monitorAVPlayer:(nonnull AVPlayer *)player
customerData:(nonnull MUXSDKCustomerData *)customerData
automaticErrorTracking:(BOOL)automaticErrorTracking
beaconCollectionDomain:(nullable NSString *)collectionDomain {
return [[MUXSDKMonitor sharedMonitor] startMonitoringPlayer:player
withPlayerName:name
fixedPlayerSize:fixedPlayerSize
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:collectionDomain];
return [[MUXSDKMonitor shared] startMonitoringPlayer:player
withPlayerName:name
fixedPlayerSize:fixedPlayerSize
customerData:customerData
automaticErrorTracking:automaticErrorTracking
beaconCollectionDomain:collectionDomain];
}

+ (void)updateAVPlayer:(AVPlayer *)player
withPlayerName:(NSString *)name
fixedPlayerSize:(CGSize)fixedPlayerSize {
[[MUXSDKMonitor sharedMonitor] updatePlayer:player
withPlayerName:name
fixedPlayerSize:fixedPlayerSize];
[[MUXSDKMonitor shared] updatePlayer:player
withPlayerName:name
fixedPlayerSize:fixedPlayerSize];
}

#pragma mark Destroy Player

+ (void)destroyPlayer:(NSString *)name {
[[MUXSDKMonitor sharedMonitor] stopMonitoringWithPlayerName:name];
[[MUXSDKMonitor shared] stopMonitoringWithPlayerName:name];
}

#pragma mark Video Change

+ (void)videoChangeForPlayer:(nonnull NSString *)name
withCustomerData:(nullable MUXSDKCustomerData *)customerData {

[[MUXSDKMonitor sharedMonitor] signalVideoChangeForPlayerName:name
withUpdatedCustomerData:customerData];
[[MUXSDKMonitor shared] signalVideoChangeForPlayerName:name
withUpdatedCustomerData:customerData];
}

#pragma mark Program Change

+ (void)programChangeForPlayer:(nonnull NSString *)name
withCustomerData:(nullable MUXSDKCustomerData *)customerData {
[[MUXSDKMonitor sharedMonitor] signalProgramChangeForPlayerName:name
withUpdatedCustomerData:customerData];
[[MUXSDKMonitor shared] signalProgramChangeForPlayerName:name
withUpdatedCustomerData:customerData];
}

+ (void)setAutomaticVideoChange:(NSString *)name
enabled:(Boolean)enabled {
if (enabled) {
[[MUXSDKMonitor sharedMonitor] enableAutomaticVideoChangeDetectionForPlayerName:name];
} else {
[[MUXSDKMonitor sharedMonitor] disableAutomaticVideoChangeDetectionForPlayerName:name];
}
[[MUXSDKMonitor shared] updateAutomaticVideoChangeForPlayerName:name enabled:enabled];
}

#pragma mark Update Customer Data

+ (void)setCustomerData:(nullable MUXSDKCustomerData *)customerData
forPlayer:(nonnull NSString *)name {
[[MUXSDKMonitor sharedMonitor] updatePlayerName:name
withCustomerData:customerData];
[[MUXSDKMonitor shared] updatePlayerName:name
withCustomerData:customerData];
}

#pragma mark Orientation Change

+ (void)orientationChangeForPlayer:(nonnull NSString *)name
withOrientation:(MUXSDKViewOrientation)orientation {
[[MUXSDKMonitor sharedMonitor] signalOrientationChangeForPlayerName:name
updatedOrientation:orientation];
[[MUXSDKMonitor shared] signalOrientationChangeForPlayerName:name
updatedOrientation:orientation];
}

#pragma mark Error

+ (void)dispatchError:(nonnull NSString *)code
withMessage:(nonnull NSString *)message
forPlayer:(nonnull NSString *)name {
[[MUXSDKMonitor sharedMonitor] dispatchErrorForPlayerName:name
errorCode:code
errorMessage:message];
[[MUXSDKMonitor shared] dispatchErrorForPlayerName:name
errorCode:code
errorMessage:message];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AudioOnlyPlaybackExampleViewController: UIViewController {
viewData: nil
)!

MUXSDKMonitor.shared().startMonitoring(
MUXSDKMonitor.shared.startMonitoring(
player: player,
playerName: playerName,
fixedPlayerSize: CGSize.zero,
Expand All @@ -50,7 +50,7 @@ class AudioOnlyPlaybackExampleViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
MUXSDKMonitor.shared().stopMonitoring(
MUXSDKMonitor.shared.stopMonitoring(
playerName: playerName
)
player.pause()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BasicPlaybackExampleViewController: UIViewController {

displayPlayerViewController()

MUXSDKMonitor.shared().startMonitoring(
MUXSDKMonitor.shared.startMonitoring(
playerViewController: playerViewController,
playerName: playerName,
customerData: customerData!
Expand Down Expand Up @@ -98,7 +98,7 @@ class BasicPlaybackExampleViewController: UIViewController {
if !playerViewController.allowsPictureInPicturePlayback {
playerViewController.player?.pause()

MUXSDKMonitor.shared().stopMonitoring(
MUXSDKMonitor.shared.stopMonitoring(
playerName: playerName
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class VideoChangeExampleViewController: MultiplePlayerItemPlaybackExampleViewCon
customerData.customerVideoData = videoData
customerData.customData = customData

MUXSDKMonitor.shared().signalVideoChange(
MUXSDKMonitor.shared.signalVideoChange(
playerName: playerName,
updatedCustomerData: customerData
)
Expand Down Expand Up @@ -124,7 +124,7 @@ class MultiplePlayerItemPlaybackExampleViewController: UIViewController {
viewData: nil
)

MUXSDKMonitor.shared().startMonitoring(
MUXSDKMonitor.shared.startMonitoring(
playerViewController: playerViewController,
playerName: playerName,
customerData: customerData!
Expand All @@ -138,7 +138,7 @@ class MultiplePlayerItemPlaybackExampleViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
MUXSDKMonitor.shared().stopMonitoring(
MUXSDKMonitor.shared.stopMonitoring(
playerName: playerName
)

Expand Down Expand Up @@ -183,7 +183,7 @@ class MultiplePlayerItemPlaybackExampleViewController: UIViewController {
let customerData = MUXSDKCustomerData()
customerData.customerVideoData = videoData

MUXSDKMonitor.shared().signalVideoChange(
MUXSDKMonitor.shared.signalVideoChange(
playerName: playerName,
updatedCustomerData: customerData
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PlayerLayerExampleViewController: UIViewController {
return
}

MUXSDKMonitor.shared().startMonitoring(
MUXSDKMonitor.shared.startMonitoring(
playerLayer: playerLayer,
playerName: playerName,
customerData: customerData
Expand All @@ -97,7 +97,7 @@ class PlayerLayerExampleViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
MUXSDKMonitor.shared().stopMonitoring(
MUXSDKMonitor.shared.stopMonitoring(
playerName: playerName
)
playerView.player?.pause()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PlayerLayerScalingExampleViewController: UIViewController {
return
}

MUXSDKMonitor.shared().startMonitoring(
MUXSDKMonitor.shared.startMonitoring(
playerLayer: playerLayer,
playerName: playerName,
customerData: customerData
Expand All @@ -80,7 +80,7 @@ class PlayerLayerScalingExampleViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
MUXSDKMonitor.shared().stopMonitoring(
MUXSDKMonitor.shared.stopMonitoring(
playerName: playerName
)
playerView.player?.pause()
Expand Down

0 comments on commit 6676c0b

Please sign in to comment.