Skip to content

Netzyn Player API for iOS

The Netzyn Player API for iOS allows an iOS application to embed the NZ Player functionality. This is accomplished by

  • Adding NetzynPlayer.xcframework to your app
  • Creating and adding NetzynPlayerviewController to your UIViewController, and add its corresponding view to your view hierarchy

The Netzyn Player SDK for iOS requires XCode 15 or later and iOS 16.2 or later.

Class NetzynPlayerViewController

This is the main UIKit class for the SDK. (For the SwiftUI View, see below). Add this view controller to your view controller hierarchy, and add its corresponding view to the view hierarchy.

When the last strong reference to NetzynPlayerViewController and its corresponding view is removed, the class is deallocated and the SDK will disconnect automatically.

Initializers

init(configuration:)

Creates a new instance with the specified configuration. This initializer constructs the view controller with the supplied configuration, and it will connect automatically.

NetzynPlayerViewController(configuration: Configuration)

Parameters:
configuration Configuration to connect the NetzynPlayerViewController

Example:

import UIKit
import NetzynPlayer

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        var configuration = Configuration(url: URL(string: "example.com")!)
        //adjust configuration as needed 

        let playerViewController = NetzynPlayerViewController(configuration: configuration)
        addChild(playerViewController)
        view.addSubview(playerViewController.view)
        playerViewController.view.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            playerViewController.view.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            playerViewController.view.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
            playerViewController.view.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
            playerViewController.view.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
        ])
    }
}

Currently only one simultaneous instance of NetzynPlayerViewController is supported.

init(coder:)

Called when unarchiving the view controller from a storyboard or nib file. Do not call this initializer yourself, instead rely on it to be called automatically during the unarchive process. When the view controller is unarchived from a storyboard or nib file, it is not possible to provide a configuration at that time. Instead, you can provide a configuration later in the lifecycle with the setConfiguration(configuration:) method.

NetzynPlayerViewController(coder: NSCoder)

Currently only one simultaneous instance of NetzynPlayerViewController is supported.

Methods

setConfiguration(configuration:)

Provides a configuration 'late'. In the case that the NetzynPlayerViewController is constructed via init(coder:), for example, because it is unarchived from a storyboard file or a xib, no configuration is provided at initialization time. If so, this method can provide a configuration after the view controller is created. Once supplied with a configuration, connection can proceed automatically.

func setConfiguration(configuration: Configuration) async

Parameters:
configuration The configuration to set
Precondition:
No configuration has been provided to the NetzynPlayerViewController. That is, neither init(configuration:) nor setConfiguration(configuration:) have been previously called on this instance.

Properties

errors

Returns an ErrorSequence of errors. You can iterate over this sequence with for await error in errors.

var errors: ErrorSequence

presentErrors

Whether errors ought to be presented automatically to the user. If true, errors will be presented as alerts. true is the default value.

var presentErrors: Bool = true

Class NetzynPlayerView

This is the main SwiftUI class for the SDK. (For the UIKit ViewController, see above). Add this view type to your SwiftUI hierarchy.

!!! Note "When the NetzynPlayerView is removed from the view hierarchy, the SDK is deallocated and it will disconnect automatically.

init(configuration:)

Creates a new instance with the specified configuration. This initializer constructs the SwiftUI view with the supplied configuration, and it will connect automatically.

NetzynPlayerView(configuration: Configuration)

Parameters:
configuration Configuration to connect the NetzynPlayerView

Currently only one simultaneous instance of NetzynPlayerView is supported.

pause

Call this function to pause the NZPlayer. Typically this should be called when transitioning to the background.

void pause()

resume

Call this function to resume the NZPlayer. Typically this should be called when transitioning to the foreground.

void resume()

sendKeyDown

This function is called to send a keyboard key down event

sendKeyDown(int keycode, int metaState)

Parameters
keycode Key event code from Key Codes
metaState Meta key state flags from Meta State

sendKeyUp

This function is called to send a keyboard key up event

sendKeyUp(int keycode, int metaState)

Parameters
keycode Key event code from Key Codes
metaState Meta key state flags from Meta State

SwiftUI View Effects

presentingErrors

Whether errors ought to be presented automatically to the user. If true, errors will be presented as alerts. true is the default value.

func presentingErrors(_ value: Bool) -> NetzynPlayerView

withErrors

Returns an ErrorSequence of errors. You can iterate over this sequence with for await error in errors.

func withErrors(_ callback: @escaping (ErrorSequence) -> Void) -> NetzynPlayerView

Struct Configuration

A Configuration models the information needed to connect to the Netzyn Cloud.

Initializers

init(url:commandLineArgs:)

Creates the configuration with the specified parameters.

Configuration(url: URL, commandLineArgs: String = "")

Parameters:
url The URL to connect to. Please contact support@netzyn.com to get a provisioned cloud URL. To run a specific app, append the app name to the URL path. For example, example.com/specificappname.
commandLineArgs Additional low-level options to be passed to the SDK core. Supports many debugging and configuration options not directly exposed to the Swift API.

Properties

prefersMetalRenderer

When true, attempts to use the metal renderer. When false, uses the OpenGL renderer. The default value is true.

var prefersMetalRenderer: Bool = true

The Metal renderer is the modern high-performance default renderer for Apple platforms. To use the legacy OpenGL renderer instead, set this property to false.

!!! In the future, the legacy OpenGL renderer – and this API – will be removed. If you encounter bugs that require use of this property, please report them.

ErrorSequence

An opaque AsyncSequence of Swift.Error. To observe the errors produced by the SDK, use the for try await pattern.

Example:

//maintaining a weak reference ensures the viewcontroller does not remain allocated merely because of error handling
Task { [weak netzynPlayerViewController] in
    for try await error in netzynPlayerViewController?.errors {
        print("error")
    }
}
See also: NetzynPlayerViewController.presentsErrors.

Constants

Meta State

QZ_KEY_FLAGS_NONE
QZ_KEY_FLAGS_NUMLOCK QZ_KEY_FLAGS_CAPSLOCK QZ_KEY_FLAGS_LOCKS
QZ_KEY_FLAGS_ALT_RIGHT QZ_KEY_FLAGS_ALT_LEFT QZ_KEY_FLAGS_ALT
QZ_KEY_FLAGS_CTRL_RIGHT QZ_KEY_FLAGS_CTRL_LEFT QZ_KEY_FLAGS_CTRL
QZ_KEY_FLAGS_SHIFT_RIGHT QZ_KEY_FLAGS_SHIFT_LEFT QZ_KEY_FLAGS_SHIFT
QZ_KEY_FLAGS_META_LEFT QZ_KEY_FLAGS_META_RIGHT QZ_KEY_FLAGS_META
QZ_KEY_FLAGS_TRANSLATED QZ_KEY_FLAGS_RELAY_KEY QZ_KEY_FLAGS_AUTO_REPEAT

Key Codes

QZ_KEY_AACUTE QZ_KEY_ACIRCUMFLEX QZ_KEY_ACUTE QZ_KEY_ADDFAVORITE
QZ_KEY_ADIAERESIS QZ_KEY_AE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