Template

Template:iOS Sequence of Calls

From Engineering Client Portal

Sequence of Calls

play

Call play at the start of each new stream. If changing videos or watching a new video, call play() each time.

Objective C

   [nielsenAppApi play:()];

Swift

nielsenAppApi?.play();

loadMetadata

Objective C

[nielsenApi loadMetadata:(contentMetadata)];

Swift

self.nielsenAppApi?.loadMetadata(contentMetadata)

playheadPosition

Objective C

-(void) setPlayHeadPosition {
    
    //Setting play head position
    CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);
    [player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){
        NSTimeInterval seconds = CMTimeGetSeconds(time);
        NSInteger intSec = seconds;
        
        //Sending data dictionary to SDK with updated playHead position.
        [nielsenApi playheadPosition:(intSec)];
    }];
}

Swift

        //Monitor the Playhead position of the AVPlayer
        let timeInterval: CMTime = CMTimeMakeWithSeconds(1.0,10)
        self.avPlayerViewController.player?.addPeriodicTimeObserver(forInterval: timeInterval, queue: DispatchQueue.main) {(elapsedTime: CMTime) -> Void in
            if self.avPlayerViewController.player!.currentItem?.status == .readyToPlay {
                let time : Float64 = self.avPlayerViewController.player!.currentTime().seconds;
                let pos = Int64(time);
                NSLog("New Elapse Time = \(time)");
                self.nielsenAppApi?.playheadPosition(pos);
            }
        }
    }

stop

Objective C

[nielsenApi stop];

Swift

nielsenApi.stop()

end

When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).

Objective C

[nielsenApi end];

Swift

nielsenApi.end()