Mux

The Mux Developer Hub

Welcome to the Mux developer hub. You'll find comprehensive guides and documentation to help you start working with Mux as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started

JWPlayer SDK for iOS

JWPlayer's native SDK for iOS can be integrated with Mux Data. If you are using JWAdConfig for inserting ads the ad events will also be tracked. Github repo (demo app included): muxinc/mux-stats-sdk-jwplayer-ios

Requirements

  • JWPlayer SDK for iOS (> 3.0)
  • A valid JWPlayer license key (sign up at https://www.jwplayer.com/)
  • A working implementation of JWPlayer-SDK in your iOS app

Before integrating Mux-Stats-JWPlayer into your player, first make sure your JWPlayer implementation is working as expected.

Integration instructions

  1. Add pod 'Mux-Stats-JWPlayer', '~> 0.3' to your Podfile and run pod install.
  2. Import the module MUXSDKStatsJWPlayer module into your app
  3. Before initializing JWPlayerController with a config, follow JWPlayer's instructions to setPlayerKey with your API key.

Below is an example configuration for a simple JWPlayer implementation. The key part to pay attention to is monitorJWPlayerController

@import MUXSDKStatsJWPlayer;


@implementation ViewController

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    JWConfig *config = [JWConfig new];
    //
    // set the rest of your properties on your JWConfig
    //
    self.player = [[JWPlayerController alloc] initWithConfig:config];

    MUXSDKCustomerPlayerData *playerData = [[MUXSDKCustomerPlayerData alloc] initWithEnvironmentKey:@"EXAMPLE_ENV_KEY"];
    // ...insert player metadata

    // Video metadata (cleared with videoChangeForPlayer:withVideoData:)
    MUXSDKCustomerVideoData *videoData = [MUXSDKCustomerVideoData new];
    // ...insert video metadata

    [MUXSDKStatsJWPlayer monitorJWPlayerController:self.player
                                                  name:@"awesome"
                                              delegate:nil
                                            playerData:playerData
                                             videoData:videoData];

    [self.player play]
}
import MUXSDKStatsJWPlayer;

class VideoPlayerController: UIViewController {
    var player: JWPlayerController?

  override func viewDidLoad () 
      super.viewDidLoad()
    let config = JWConfig()
    config.file = "http://example.com/hls.m3u8"
    player = JWPlayerController(config: config)
  }

  override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(animated)
        player!.view!.frame = self.view.bounds
      view.addSubview(player!.view)
 
      let playName = "awesome"
      let playerData = MUXSDKCustomerPlayerData(environmentKey: "YOUR_ENVIRONMENT_KEY");
      // insert player metadata
      let videoData = MUXSDKCustomerVideoData();
      // insert video metada
      MUXSDKStatsJWPlayer.monitorJWPlayerController(player!, name: playName, delegate: nil, playerData: playerData!, videoData: videoData)
            player!.play()
  }
}

(Optional) Registering Your Own JWPlayerDelegate

If your own ViewController implements <JWPlayerDelegate> and you want to use it, then pass that in as the delegate argument to monitorJWPlayerController. See the example below:

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController  <JWPlayerDelegate> {
}

@property (nonatomic, strong) JWPlayerController * player;

@end
  
@implementation ViewController
- (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  //
  // initialize JWPlayerController and pass in `self` as the delgate
  //
  [MUXSDKStatsJWPlayer monitorJWPlayerController:self.player
                                            name:"awesome"
                                        delegate:self
                                      playerData:playerData
                                       videoData:videoData];
}

// example of implementing a delegate method
- (void) onPlay:(JWEvent<JWStateChangeEvent> *)event {
  // this will get called when JWPlayer triggers onPlay
}

Release Notes

Current Release

v0.3.0

  • Add tracking for video source hostname

Previous Releases

v0.2.0

  • Fix bug when collecting player source duration
  • Start collecting player software version

v0.1.0

  • Initial release

Updated 7 months ago

JWPlayer SDK for iOS


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.