Add a player to your view (iOS v3)

Use the following steps and code examples to add a player to the ViewController.h or ViewController.swift file of your app:

  1. In ViewController.h or ViewController.swift, create a JWPlayerController object named player.
  2. Create a JWConfig object named config. At the minimum, you must define the file property.
  3. Initialize the player with the config.
@interface ObjCViewController ()

@property (nonatomic) JWPlayerController *player;


@implementation ObjCViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    JWConfig *config = [[JWConfig alloc] init];
    config.file = @"";
    self.player = [[JWPlayerController alloc] initWithConfig:config];

- (void)viewDidAppear {
    [super viewDidAppear];
    [self.view addSubview:self.player.view];

class ViewController: UIViewController {
    var player: JWPlayerController?

    override func viewDidLoad() {
        let config = JWConfig()
        config.file = ""
        player = JWPlayerController(config: config)

    override func viewDidAppear(_ animated: Bool) {