IOS SDK Advanced Features
Floating Player Preset
Based on your placement configuration, when the user scrolls the player off the screen, the player will switch to floating mode.
If you need an advanced control (e.g., the place of the floatingParentView in the view tree hierarchy etc.) you will need to follow this section and provide a floating container view, which will be used to contain the player in its floating mode.
player?.configure( [ .placementId: ...,
.flowParentView: YOUR_FLOATING_PARENT_VIEW ] )
[player configure:@{
@(PrimisConfigKeyPlacementId): ...,
@(PrimisConfigKeyFlowParentView): YOUR_FLOATING_PARENT_VIEW
}];
Additional instructions
- The floatingParentView must be of type UIView, covering the entire screen and visible during the controller’s life cycle. We suggest that you use the view controller's view, otherwise you should provide a subview that fulfills these requirements.
- We recommend that your custom floatingParentView and the container view will belong to a single view controller.
Defining friendly views for Overlapping Detection
Primis Sdk is able to detect when a view overlaps the player. For example, when the user opens a menu, or a modal screen is presented the player stops playing and waits to be visible again before continuing to play.
In order to ignore overlapping views (a button for example) add their tags (Integer) while configuring the player.
player?.configure( [ ...
.friendlyViewTags: [TAG1, TAG2,...] ]
)
[player configure:@{
...
@(PrimisConfigKeyFriendlyViewTags): @[@(TAG1),...]
}];
Single Player - multiple indexes in Table and Collection View
Primis Player may be assigned to more than one index in a TableView or CollectionView. To implement this, the app maintains a list of indexes and assigns the appropriate Cell when the player scrolls out of the screen.
Notes:
- Only one index can be visible at a time. Trying to display the player in multiple indexes will fail silently.
- Do not set a floating player in the placement configuration (in Primis dashboard) if using this mode. Enabling it in this mode may result in unexpected behavior.
- Use a dedicated table cell for the player. Using the player’s cell to display other content may result in unexpected behavior
Edit your cellForRowAtIndexPath to display the player on every index in your playerPositions Set.
let playerPositions: Set<Int>
...
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if playerPositions.contains(indexPath.row) {
// Dequeue a player cell
let playerCell = tableView.dequeueReusableCell(
withIdentifier: "playerCell",
for: indexPath) as! PlayerTableViewCell
// Notify the Primis player that it is about to be presented in a cell,
// and provide the container view to which the player will be added as a subview
player?.displayInCell(playerCell, container: playerCell.playerContainer)
return playerCell
}
// Display other cells
let otherCell = tableView.dequeueReusableCell
...
return otherCell
}
NSSet *playerPositions
...
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if ([playerPositions containsObject:@(indexPath.row)]) {
// Dequeue a player cell
PlayerTableViewCell *playerCell =
[tableView dequeueReusableCellWithIdentifier:@"playerCell" forIndexPath:indexPath];
// Notify the Primis player that it is about to be presented in a cell,
// and provide the container view to which the player will be added as a subview
[player displayInCell:playerCell container:playerCell.playerContainer];
return playerCell;
}
// Display other cells
TextTableViewCell *otherCell = [tableView dequeue
...
return otherCell;
}
Consent management
Primis Player supports consent strings in IAB TCF format, version 2. If your app uses certified IAB CMP, the SDK will read the consent string from userDefaults according to the standard.
Otherwise, to start the Player with some predefined consent string, pass it in the configuration object by defining PrimisConsent tuple (swift) or dictionary (obj-c) as described below:
player.configure( [ .placementId: YOUR_PLACEMENT_ID_STRING,
.containerView: YOUR_PLAYER_CONTAINER_VIEW,
.consent: PrimisConsent("consent-string","2") ] )
[player configure:@{
@(PrimisConfigKeyPlacementId): YOUR_PLACEMENT_ID_STRING,
@(PrimisConfigKeyContainerView): YOUR_PLAYER_CONTAINER_VIEW,
@(PrimisConfigKeyConsent): @{@"consent":@"consent-string", @"version":@"2"}
}];
Player API - player events intefrace
Primis SDK allows the host application to register and start listening to events that are triggered inside the video
player (e.g., when video content starts playing or when the user clicks on an ad).
A full list of available player API events can be found here.
In order to get the player events from PrimisPlayer implement the PrimisPlayerDelegate protocol
extend YOUR_VIEW_CONTROLLER : PrimisPlayerDelegate {
func onPrimisPlayerEvent(event: PlayerApiEvent){
print(event.data)
}
}
class YOUR_VIEW_CONTROLLER : UIViewController, PrimisPlayerDelegate {
- (void)onPrimisPlayerEventWithEvent:(PlayerAPIEvent *)event {
NSLog(@"%@", [NSString stringWithFormat:@"Primis player event - %@", event.data]);
}
}
APP Tracking Transparency
Primis SDK is fully compliant with Apple's new tracking policy for iOS14, and will use the device IDFA accordingly.
For further information see Apple documentation: here.
Debugging
Optional - The PrimisPlayer SDK generates debug logs to indicate successful operations or potential problems. These logs may be handy during integration and you can easily disable them when releasing the app.
Our logs are disabled by default.
You can turn on/off the player's debug logs by adding '.debugLogActive: true/false' to the player's configure call.
Player Dynamic Parameters
Primis tag is a javascript tag that contains initial configuration parameters for the player. You may extend the basic tag by adding dynamic parameters in URL format with the .additionalParams field like so:
player.configure( [ .placementId: YOUR_PLACEMENT_ID_STRING,
.containerView: YOUR_PLAYER_CONTAINER_VIEW,
.additionalParams: “vp_template=...&vp_content=...”]
[player configure:@{
@(PrimisConfigKeyPlacementId): YOUR_PLACEMENT_ID_STRING,
@(PrimisConfigKeyContainerView): YOUR_PLAYER_CONTAINER_VIEW,
@(PrimisConfigKeyAdditionalParams): @“vp_template=...&vp_content=...”}
}];
You may view the full list of available dynamic parameters here
Updated about 1 year ago