Skip to content

Commit

Permalink
Releases/v4.2.0 (#255)
Browse files Browse the repository at this point in the history
* fix: send `ended` when an AVPlayerItem finishes playing to completion (#254)

* fix: remove NSLog and comment lines
---------

Co-authored-by: Emily Dixon <[email protected]>
  • Loading branch information
andrewjl-mux and daytime-em committed Nov 23, 2024
1 parent 9d4d186 commit 7f597bd
Show file tree
Hide file tree
Showing 33 changed files with 130 additions and 110 deletions.
3 changes: 2 additions & 1 deletion MUXSDKStats.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"4.0.0": "https://github.com/muxinc/mux-stats-sdk-avplayer/releases/download/v4.0.0/MUXSDKStats.xcframework.zip",
"4.1.0": "https://github.com/muxinc/mux-stats-sdk-avplayer/releases/download/v4.1.0/MUXSDKStats.xcframework.zip",
"4.1.1": "https://github.com/muxinc/mux-stats-sdk-avplayer/releases/download/v4.1.1/MUXSDKStats.xcframework.zip",
"4.1.2": "https://github.com/muxinc/mux-stats-sdk-avplayer/releases/download/v4.1.2/MUXSDKStats.xcframework.zip"
"4.1.2": "https://github.com/muxinc/mux-stats-sdk-avplayer/releases/download/v4.1.2/MUXSDKStats.xcframework.zip",
"4.2.0": "https://github.com/muxinc/mux-stats-sdk-avplayer/releases/download/v4.2.0/MUXSDKStats.xcframework.zip"
}
2 changes: 1 addition & 1 deletion MUXSDKStats/BuildConfiguration/MUXSDKStatsBase.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
// they are intended for, excluding the MUXSDKStatsBase
// which is where configs common to all targets are placed.

MARKETING_VERSION = 4.1.2
MARKETING_VERSION = 4.2.0
CURRENT_PROJECT_VERSION = 1
37 changes: 27 additions & 10 deletions MUXSDKStats/MUXSDKStats/MUXSDKPlayerBinding.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// SDK constants.
NSString *const MUXSDKPluginName = @"apple-mux";
NSString *const MUXSDKPluginVersion = @"4.1.2";
NSString *const MUXSDKPluginVersion = @"4.2.0";
NSString *const MUXSessionDataPrefix = @"io.litix.data.";

// Min number of seconds between timeupdate events. (100ms)
Expand Down Expand Up @@ -129,15 +129,18 @@ - (void)attachAVPlayer:(AVPlayer *)player {
forKeyPath:@"status"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:MUXSDKAVPlayerStatusObservationContext];

[_player addObserver:self
forKeyPath:@"currentItem"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:MUXSDKAVPlayerCurrentItemObservationContext];

[_player addObserver:self
forKeyPath:@"timeControlStatus"
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:MUXSDKAVPlayerTimeControlStatusObservationContext];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleDidPlayToEndTimeNotification:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAVPlayerAccess:) name:AVPlayerItemNewAccessLogEntryNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleRenditionChange:) name:RenditionChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAVPlayerError:) name:AVPlayerItemNewErrorLogEntryNotification object:nil];
Expand Down Expand Up @@ -168,9 +171,8 @@ -(NSString *)getHostName:(NSString *)urlString {
// Check that the item in the notification matches the item that we are monitoring
// This matters when there are multiple AVPlayer instances running simultaneously
//
- (BOOL) checkIfNotificationIsRelevant:(NSNotification *)notif {
AVPlayerItem *notificationItem = (AVPlayerItem *)notif.object;
return notificationItem == _playerItem;
- (BOOL) isNotificationAboutCurrentPlayerItem:(NSNotification *)notif {
return notif.object == _playerItem;
}

- (void)handleConnectionTypeDetected:(NSNotification *)notif {
Expand All @@ -185,12 +187,30 @@ - (void)handleConnectionTypeDetected:(NSNotification *)notif {
}
});
}
- (void)handleApplicationWillTerminate:(NSNotification *)notification {
[self dispatchViewEnd];
[self stopMonitoringAVPlayerItem];

[MUXSDKCore destroyPlayer:self.name];

}

# pragma mark AVPlayerItemDidPlayToEndTimeNotification

- (void)handleDidPlayToEndTimeNotification:(NSNotification *)notification {
if ([self isNotificationAboutCurrentPlayerItem:notification]) {
MUXSDKEndedEvent *endedEvent = [[MUXSDKEndedEvent alloc] init];
MUXSDKPlayerData *playerData = [self getPlayerData];
endedEvent.playerData = playerData;
[MUXSDKCore dispatchEvent:endedEvent forPlayer:_name];
}
}

# pragma mark AVPlayerItemAccessLog

- (void)handleAVPlayerAccess:(NSNotification *)notif {
dispatch_async(dispatch_get_main_queue(), ^{
BOOL isNotificationRelevant = [self checkIfNotificationIsRelevant:notif];
BOOL isNotificationRelevant = [self isNotificationAboutCurrentPlayerItem:notif];
if (isNotificationRelevant) {
AVPlayerItemAccessLog *accessLog = [((AVPlayerItem *)notif.object) accessLog];
[self handleRenditionChangeInAccessLog:accessLog];
Expand Down Expand Up @@ -288,7 +308,7 @@ - (void) updateViewingLivestream:(AVPlayerItemAccessLog *) log {
# pragma mark AVPlayerItemErrorLog

- (void)handleAVPlayerError:(NSNotification *)notif {
BOOL isNotificationRelevant = [self checkIfNotificationIsRelevant:notif];
BOOL isNotificationRelevant = [self isNotificationAboutCurrentPlayerItem:notif];
if (isNotificationRelevant) {
AVPlayerItemErrorLog *log = [((AVPlayerItem *)notif.object) errorLog];
if (log != nil && log.events.count > 0) {
Expand All @@ -314,6 +334,7 @@ - (void)timeUpdateTimer:(NSTimer *)timer {

- (void)dealloc {
[self detachAVPlayer];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemNewAccessLogEntryNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:RenditionChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemNewErrorLogEntryNotification object:nil];
Expand Down Expand Up @@ -367,7 +388,6 @@ - (void) safelyRemovePlayerItemObserverForKeyPath:(NSString *)keyPath {
}

- (void)detachAVPlayer {
// NSLog(@"%s: Detaching AVPlayer", __PRETTY_FUNCTION__);
if (_playerItem) {
[self stopMonitoringAVPlayerItem];
}
Expand All @@ -391,12 +411,10 @@ - (void)monitorAVPlayerItem {
if (_didTriggerManualVideoChange) {
_didTriggerManualVideoChange = false;
}
// NSLog(@"%s: Dispatching View End", __PRETTY_FUNCTION__);
[self dispatchViewEnd];
[self stopMonitoringAVPlayerItem];

if (_player.currentItem) {
NSLog(@"Player: %@ Current Item: %@", _player, _player.currentItem);
[self.playDispatchDelegate videoChangedForPlayer:_name];
}

Expand Down Expand Up @@ -471,7 +489,6 @@ - (void)stopMonitoringAVPlayerItem {
[self safelyRemovePlayerItemObserverForKeyPath:@"playbackBufferEmpty"];
_playerItem = nil;
if (!_isAdPlaying) {
// NSLog(@"%s: MUXSDKCore destroyPlayer", __PRETTY_FUNCTION__);
[MUXSDKCore destroyPlayer: _name];
}
}
Expand Down
2 changes: 1 addition & 1 deletion Mux-Stats-AVPlayer.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'Mux-Stats-AVPlayer'

s.version = '4.1.2'
s.version = '4.2.0'
s.source = { :git => 'https://github.com/muxinc/mux-stats-sdk-avplayer.git',
:tag => "v#{s.version}" }

Expand Down
34 changes: 17 additions & 17 deletions XCFramework/MUXSDKStats.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@
<key>BinaryPath</key>
<string>MUXSDKStats.framework/MUXSDKStats</string>
<key>LibraryIdentifier</key>
<string>tvos-arm64</string>
<string>tvos-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>MUXSDKStats.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>tvos</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>MUXSDKStats.framework/MUXSDKStats</string>
<string>MUXSDKStats.framework/Versions/A/MUXSDKStats</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64_x86_64-maccatalyst</string>
<key>LibraryPath</key>
<string>MUXSDKStats.framework</string>
<key>SupportedArchitectures</key>
Expand All @@ -33,52 +36,52 @@
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
<string>maccatalyst</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>MUXSDKStats.framework/MUXSDKStats</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>xros-arm64</string>
<key>LibraryPath</key>
<string>MUXSDKStats.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<string>xros</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>MUXSDKStats.framework/MUXSDKStats</string>
<key>LibraryIdentifier</key>
<string>xros-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>MUXSDKStats.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>xros</string>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>MUXSDKStats.framework/MUXSDKStats</string>
<key>LibraryIdentifier</key>
<string>tvos-arm64_x86_64-simulator</string>
<string>tvos-arm64</string>
<key>LibraryPath</key>
<string>MUXSDKStats.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>tvos</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
Expand All @@ -99,20 +102,17 @@
</dict>
<dict>
<key>BinaryPath</key>
<string>MUXSDKStats.framework/Versions/A/MUXSDKStats</string>
<string>MUXSDKStats.framework/MUXSDKStats</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-maccatalyst</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>MUXSDKStats.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file modified XCFramework/MUXSDKStats.xcframework/_CodeSignature/CodeDirectory
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 7f597bd

Please sign in to comment.