The Mux Objective-C SDK is available either via CocoaPods or you can manually install it. If you have any problems, feel free to get in touch.
Installing with CocoaPods
Podfile to use frameworks by including
use_frameworks! and then add
pod "Mux-Stats-SDK", "~> 0.0". This will use our current release which is version
0.0.3. There will no be API breaking changes within our
0.0 releases, so you can safely run
Include the correct Mux Objective-C SDK for your project by cloning our repository and dragging the framework into your Xcode project. The
Frameworks folder contains two folders, one for iOS and one for tvOS. Inside these folders, there are 3 additional folders containing different architecture combinations. The
fat folder contains a library with all architectures in one.
You can use the
fat library when developing but this library cannot be used when compiling for submission to the App Store as it contains the simulator architectures that are not used by any Apple devices (the community believes this is a bug). You can use the framework in the
release folder when building a release version of your application, or you can run a script to strip unneeded architectures.
$ git clone https://github.com/muxinc/stats-sdk-objc.git
Adding the monitor
Add the correct import statement for your target platform;
// for iOS @import MUXSDKStats; // for tvOS @import MUXSDKStatsTv;
To monitor the performance of an AVPlayer, call either
monitorAVPlayerLayer:withPlayerName:playerData:videoData:, passing a pointer to your AVPlayer container (either the
AVPlayerViewController) to the SDK. When calling
videoChangeForPlayer:withVideoData: to change the video the same player name used for the monitor call must be used.
// Property and player data that persists until the player is destroyed MUXSDKCustomerPlayerData *playerData = [[MUXSDKCustomerPlayerData alloc] initWithPropertyKey:@"EXAMPLE_PROPERTY_KEY"]; playerData.viewerUserId = @"1234"; playerData.experimentName = @"player_test_A"; playerData.playerName = @"My Main Player"; playerData.playerVersion = @"1.0.0"; // Video metadata (cleared with videoChangeForPlayer:withVideoData:) MUXSDKCustomerVideoData *videoData = [MUXSDKCustomerVideoData new]; videoData.videoId = @"abcd123"; videoData.videoTitle = @"My Great Video"; videoData.videoSeries = @"Weekly Great Videos"; videoData.videoProducer = @"Bob the Producer"; videoData.videoContentType = @"type"; videoData.videoLanguageCode = @"en"; videoData.videoVariantName = @"Spanish Hard Subs"; videoData.videoVariantId = @"abcd1234"; videoData.videoDuration = @(120000); // in milliseconds videoData.videoIsLive = @NO; videoData.videoEncodingVariant = @"Variant 1"; videoData.videoCdn = @"cdn"; AVPlayerLayer *player = [AVPlayerLayer new]; [MUXSDKStats monitorAVPlayerViewController:player withPlayerName:@"awesome" playerData:playerData videoData:videoData];
Confirming it works
After you've integrated, start playing a video in the player you've integrated with. Then for your viewing session (called a "video view") to show up in the Mux dashboard, you need to stop watching the video. In a few minutes you'll see the results in your Mux account. We'll also email you when the first video view has been recorded.