Click on “Create new credentials” and provide a name for your application in the “Application name” field. Your credentials will be listed under the “API/SDK access” page based on this name.
Select iOS in the “Platform” drop-down. Enter the “bundle id” in its respective field.
After you completed all fields, hit “Save” to generate your SDK credentials. Make sure that the “bundle id” is introduced correctly, as you will have no possibility to update them later. If you accidentally saved wrong values, start the process from the beginning and create new credentials with the correct values.
After hitting “Save” in the “Create new credentials” step, you will see your credentials listed.
The created credentials entry will have a “Download iOS Player SDK” button at the bottom, click it to download the SDK package.
The provided zip archive contains the binary frameworks and a sample application.
Open the project that you would like to integrate the SDK in.
Drag IBMVideoPlayerSDK.xcframework and IBMCoreSDK.xcframework into the Embedded Binaries section of your target.
The SDK requires the use of an IBM Player SDK key, which is validated whenever the SDK communicates with IBM’s streaming servers. The sample application contains a sample SDK key which you can use for testing. The sample SDK key can only be used to play content on the test channel(s) that are used in the sample app.
Note: Although there is a provided SDK key for the sample app’s sample content, you still need to register your identifier at IBM.
Before you can start using the Player SDK for playing content from your own channel(s), you will need to:
- Get a valid IBM Player SDK key belonging to the Account that owns the content you would like to play.
- Register the bundle identifier(s) of every app in which you will integrate the IBM Player SDK in.
The application identifier is typically structured as
Before you can create and use an instance of the player you must configure the lib with your IBM Player SDK key:
[USUstreamPlayer configureWithApiKey:<#place your SDK key here#>];
USUstreamPlayer.configure(withApiKey:<#place your SDK key here#>)
USUstreamPlayer can be instantiated in the usual way. The created player object is a subclass of the
USUstreamPlayer optimized for the targeted device (iPhone or iPad).
#import <IBMVideoPlayerSDK/IBMVideoPlayerSDK.h>self.ustreamPlayer = [[USUstreamPlayer alloc] init];self.ustreamPlayer.delegate = self;self.ustreamPlayer.view.frame = self.view.bounds;[self.view addSubview:self.ustreamPlayer.view];
import IBMVideoPlayerSDKself.ustreamPlayer = USUstreamPlayer()self.ustreamPlayer.delegate = selfself.ustreamPlayer.view.frame = self.view.boundsself.view.addSubview(self.ustreamPlayer.view)
By now you have configured your player and it is ready to stream video content through IBM’s services.
USUstreamPlayer can play different kinds of media:
- Live streams
- Recorded videos
For example, to watch the live video playing on your channel:
self.mediaDescriptor = [USMediaDescriptor channelDescriptorWithID:<#place your channel ID here#>];[self.ustreamPlayer playMedia:self.mediaDescriptor];
self.mediaDescriptor = USMediaDescriptor.channelDescriptor(withID:<#place your channel ID here#>)self.ustreamPlayer.playMedia(self.mediaDescriptor)
Content owners can control access to their media using various “locks” that implement password protection, age restriction and other protections. Streaming servers reject clients trying to connect whenever lock conditions are not met. The SDK calls the appropriate callback function to indicate this to the application.
USUstreamPlayer reports its state changes using the
USPlayerDelegate protocol. Some callbacks may also require user interaction in case the servers notify the Player about content restrictions. For example, when “lock” conditions are not met.
In order to receive these callbacks, you need to define a handler conforming to protocol
USPlayerDelegate and set it as a delegate of your player instance.
self.ustreamPlayer.delegate = self;
self.ustreamPlayer.delegate = self
Player state is changed
The player instance reports its state changes so that application states can be updated accordingly. For example, your app can change the layout of the player screen depending on whether playback is in progress.
The most important callback indicating such change is the
playerStateDidChange:, which reports the state of the Player. The states are listed in the
Callbacks listed below are “interactive”, this means they can be used to reconnect for playback after some kind of user input.
When the Player sends the callback:
playerRequiresPassword: it waits for a password belonging to the locked content. You can provide the password using
When you provide the password, the server validates it and starts playing the content if the password is valid. Otherwise it calls back again with
Age lock (deprecated)
When the Player sends either callback
playerRequiresBirthdate: you need to ask the user’s birth date without hints to the required age. If the user-specified age is not less than the required age, you can continue the playback with
Hash lock (deprecated)
A deprecated custom viewer authentication flow. Use [Viewer auth] instead.
Implementing custom viewer authentication flow is possible using the Viewer Authentication API. If the channel or video is set up with custom viewer authentication, the player sends the callback
playerRequiresViewerAuthToken:fromURL: where the application should present the custom authentication flow for the user. For more information on implementing the flow please refer to the Viewer Authentication API documentation.
Once the authentication flow is finished,
continueWithViewerAuthToken: should be called with the resulting
token object of the authentication flow. If the provided
token object is validated the player gains access to the restricted resource and starts playing it back.