Rich Media

  • iOS
  • watchOS
  • tvOS
 

Foreword

AT Internet’s SDK allows you to tag videos and audio media played by the user during app usage.

 

Get off to a good start

Once your tag has been initialised, you can begin tagging your videos and audio media.

In cases of a Swift project,
please import the Tracker module (or TrackerExtension if your target is an extension) in your ViewController. In
cases of an Objective-C project, please import the headers ATInternet.h, ATTracker.h, then depending on the type of
content, ATAudio.h, ATVideo.h, ATLiveAudio.h, ATLiveVideo.h, ATMedium.h, ATLiveMedium.h.

 

Tagging

Rich Media tagging is not
accounted for in the dispatch mechanism!

The tracker makes available a MediaPlayers object. This object exposes the following methods:

  • add: Enables the addition of a new player and returns a MediaPlayer object
  • remove: Delete a player
  • removeAll: Delete all players

When a player is deleted, if media is currently being played or paused, a hit will be automatically sent in order to stop measurement.

import UIKit
import Tracker

class ViewController: UIViewController {

    let tracker = ATInternet.sharedInstance.defaultTracker

    override func viewDidLoad() {
        super.viewDidLoad()

        // New player with ID
        let player1 = tracker.mediaPlayers.add(78)

        // New player with default ID
        let player2 = tracker.mediaPlayers.add()

        // Remove the player 78
        tracker.mediaPlayers.remove(78)

        // Remove all the players
        tracker.mediaPlayers.removeAll()
    }

}
#import "ViewController.h"
#import "SmartTracker/SmartTracker-Swift.h"

@interface ViewController ()

@property (nonatomic, strong) Tracker *tracker;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.tracker = [[ATInternet sharedInstance] defaultTracker];

    // New player with ID
    MediaPlayer *player1 = [self.tracker.mediaPlayers add:78];

    // New player with default ID
    MediaPlayer *player2 = [self.tracker.mediaPlayers add];

    // Remove the player 78
    [self.tracker.mediaPlayers remove:78];

    // Remove all the players
    [self.tracker.mediaPlayers removeAll];
}

@end
Once a player is instantiated, it is possible to tag videos and audio media.

All objects listed below expose the following methods:

  • sendPlay:
    • < v2.9.0 : Sends a media play hit with a refresh hit sent automatically every 5
      seconds
    • >= v.2.9.0 :  Sends a media play hit with a refresh hit sent automatically with
      intervals defined like this:

      • Every 5 seconds during the first minute
      • Every 15 seconds between the second and the fifth minute
      • Every 30 seconds between the sixth and the tenth minute
      • Every minute for play duration > 10 minutes
  • sendPlay with int refresh period: Same as above, except it is possible to specify the refresh period (the
    specified parameter cannot be less than 5, which is the minimum period EXCEPT if the parameter is set to 0,
    in which case refreshing is not enabled!) (Deprecated in v2.9.0)
  • sendPause: Sends a hit when media has been paused
  • sendStop: Sends a hit when media playback has been stopped completely
  • sendMove : Sends a hit when the player’s play cursor has been moved
  • >= v.2.9.0 :
    • sendPlay(SparseIntArray refreshDurations) : custom refresh interval can be defined
    • sendPlayWithoutRefresh() :Sends a media play hit without refresh
    • sendResume() : Resume media tracking preserved updated intervals
 

Dynamic refresh (>= 2.9.0)

sendPlay method has been improve in order to optimise refresh durations all along a media playback. Since
version 2.9.0, sendPlay takes in parameter a Dictionary<Int, Int> like [0: 5, 2: 10, 3:
20] meaning :

From 0 to 2 minutes of media read (not affected by sendMove method), there will be a 5 seconds refresh
duration.
From 2 to 3 minutes, there will be a 10 seconds refresh duration.
After 3 minutes, there will be a 20 second refresh duration.

In the case of the sendPause(), the sendResume() method will be used
to resume and keep the playback and dynamic refresh in progress. If sendPlay(_) is called instead of
sendResume(), the dynamic refresh will restart from the beginning.

 

Video

The MediaPlayer object makes a Videos object available. This object
exposes the following methods:

  • add: Enables the addition of a video to the player and returns a Video
    object
  • remove: Deletes a video
  • removeAll: Deletes all videos
 

Tagging examples

  1. Tagging a video play with refresh duration by default ( [0:5, 1:15, 5:30, 10:60] )
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let video = player.videos.add("movie", duration: 122)
            video.sendPlay()
    
            /// with buffering (>= 2.11.0)
            video.sendPlay(true)
        }
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOLL)animated {
        self.video = [self.player.videos add:@"movie" duration:122];
        [self.video sendPlay];
    
        /// with buffering (>= 2.11.0)
        [self.video sendPlayWithIsBuffering:YES];
    }
    
    @end
    
  2. Tagging a video play with a dynamic refresh duration
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let video = player.videos.add("movie", duration: 122)
            video.sendPlay(dynamicRefreshConfiguration: [0: 5, 1:10, 3: 30])
    
            /// with buffering (>= 2.11.0)
            video.sendPlay(dynamicRefreshConfiguration:[0: 5, 1:10, 3: 30], isBuffering:true)
        }
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *video;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.video = [self.player.videos add:@"movie" duration:122];
        [self.video sendPlayWithDynamicRefreshConfiguration: @{@0:@5, @1:@15, @5:@30, @10:@60}];
    
        /// with buffering (>= 2.11.0)
        [self.video sendPlayWithDynamicRefreshConfiguration:@{@0:@5, @1:@15, @5:@30, @10:@60} isBuffering:YES];
    }
    
    @end
  3. Tagging a video play with themes (chapters for older sdk versions)
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let video= player.videos.add("movie", mediaTheme1:"theme1", mediaTheme2:"theme2", duration:122)
        }
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        Video *video = [self.player.videos add:@"movie" mediaTheme1:@"theme1" mediaTheme2:@"theme2" duration:122];
    }
    @end
    
  4. Tagging a video “pause”
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var video: Video!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillDisappear(animated: Bool) {
            video.sendPause()
        }
    
        override func viewWillAppear(animated: Bool) {
            video = player.videos.add("movie", duration: 122)
            video.sendPlay()
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *video;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [self.video sendPause];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.video = [self.player.videos add:@"movie" duration:122];
        [self.video sendPlay];
    }
    
    @end
    
  5. Tagging a video “stop”
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var video: Video!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillDisappear(animated: Bool) {
            video.sendStop()
        }
    
        override func viewWillAppear(animated: Bool) {
            video = player.videos.add("movie", duration: 122)
            video.sendPlay()
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *video;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [self.video sendStop];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.video = [self.player.videos add:@"movie" duration:122];
        [self.video sendPlay];
    }
    
    @end
    
  6. Tagging video information
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var myVideo: Video!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            myVideo = player.videos.add("movie", duration: 122)
            myVideo.sendPlay()
    
            /// >= 2.11.0
            myVideo.sendInfo()
            myVideo.sendInfo(true)
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *myVideo;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.myVideo = [self.player.videos add:@"movie" duration:122];
        [self.myVideo sendPlay];
    
        /// (>= 2.11.0)
        [myVideo sendInfo]
        [myVideo sendInfoWithIsBuffering:YES]
    }
    
    @end
    
  7. Tagging others actions on the video
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var video: Video!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        // Custom method
        func othersActions() {
            video.sendMove()
            video.sendShare()
            video.sendEmail()
            video.sendDownload()
            video.sendFavor()
        }
    
        override func viewWillAppear(animated: Bool) {
            video = player.videos.add("movie", duration: 122)
            video.sendPlay()
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *video;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    // Custom method
    - (void)othersActions {
        [self.video sendMove];
        [self.video sendEmail];
        [self.video sendDownload];
        [self.video sendShare];
        [self.video sendFavor];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.video = [self.player.videos add:@"movie" duration:122];
        [self.video sendPlay];
    }
    
    @end
    
 

LiveVideo

The MediaPlayer object makes a LiveVideos object available. This
object exposes the following methods:

  • add: Enables the addition of a live video to the player and returns a
    LiveVideo object
  • remove: Deletes a live video
  • removeAll: Deletes all live videos
 

Tagging examples

  1. Tagging a live video play without refresh
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let liveVideo = player.liveVideos.add("movie")
            liveVideo.sendPlayWithoutRefresh()
    
            /// with buffering (>= 2.11.0)
            liveVideo.sendPlayWithoutRefresh(true)
        }
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        LiveVideo *liveVideo = [self.player.liveVideos add:@"movie"];
    
        [liveVideo sendPlayWithoutRefresh];
        /// with buffering (>= 2.11.0)
        [liveVideo sendPlayWithoutRefreshWithIsBuffering:YES];
    }
    
    @end
  2. Tagging a live video play with refresh (refresh period cannot be less than 5 seconds)
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let liveVideo = player.liveVideos.add("movie")
            // Refresh duration 10sec
            liveVideo.sendPlay(10)
    
            /// with buffering (>= 2.11.0)
            liveVideo.sendPlay(true)
        }
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        LiveVideo *liveVideo = [self.player.liveVideos add:@"movie"];
        // Refresh duration 10sec
        [liveVideo sendPlay:10];
    
        /// with buffering (>= 2.11.0)
        [liveVideo sendPlayWithIsBuffering:YES];
    }
    
    @end
  3. Tagging a live video ‘pause’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var liveVideo: LiveVideo!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillDisappear(animated: Bool) {
            liveVideo.sendPause()
        }
    
        override func viewWillAppear(animated: Bool) {
            liveVideo = player.videos.add("movie", mediaTheme1:"theme1")
            liveVideo.sendPlay()
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *liveVideo;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [self.liveVideo sendPause];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.liveVideo = [self.player.liveVideos add:@"movie" mediaTheme1:@"theme1"];
        [self.liveVideo sendPlay];
    }
    
    @end
    
  4. Tagging a live video ‘stop’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var liveVideo: LiveVideo!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillDisappear(animated: Bool) {
            liveVideo.sendStop()
        }
    
        override func viewWillAppear(animated: Bool) {
            liveVideo = player.liveVideos.add("movie")
            liveVideo.sendPlay()
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Video *liveVideo;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [self.liveVideo sendStop];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.liveVideo = [self.player.liveVideos add:@"movie"];
        [self.liveVideo sendPlay];
    }
    
    @end
    
  5. Tagging live video information
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var liveVideo: LiveVideo!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            liveVideo = player.liveVideos.add("movie")
            liveVideo.sendPlay()
    
            ///>= 2.11.0
            liveVideo.sendInfo()
            /// with buffering
            liveVideo.sendInfo(true)
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveVideo *liveVideo;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.liveVideo = [self.player.liveVideos add:@"movie"];
        [self.liveVideo sendPlay];
    
        ///>= 2.11.0
        [self.liveVideo sendInfo];
        /// with buffering
        [self.liveVideo sendInfoWithIsBuffering:YES];
    }
    
    @end
    
  6. Tagging others actions on the live video
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var liveVideo: LiveVideo!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        // Custom method
        func othersActions() {
            liveVideo.sendMove()
            ///>= 2.11.0
            liveVideo.sendShare()
            liveVideo.sendEmail()
            liveVideo.sendFavor()
            liveVideo.sendDownload()
        }
    
        override func viewWillAppear(animated: Bool) {
            liveVideo = player.liveVideos.add("movie")
            liveVideo.sendPlay()
        }
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveVideo *liveVideo;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    // Custom method
    - (void)othersActions {
        [self.liveVideo sendMove];
        ///>= 2.11.0
        [self.liveVideo sendDownload];
        [self.liveVideo sendShare];
        [self.liveVideo sendFavor];
        [self.liveVideo sendEmail];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.liveVideo = [self.player.liveVideos add:@"movie"];
        [self.liveVideo sendPlay];
    }
    
    @end
    
 

Audio

The MediaPlayer object makes an Audios object available. This
object exposes the following methods:

  • add: Enables the addition of audio media to the player and returns an
    Audio object.
  • remove: Deletes an audio media
  • removeAll: Deletes all audio media
 

Tagging examples

  1. Tagging audio media play without refresh
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let audio = player.audios.add("song", duration:122)
    
            audio.sendPlay(0)
        }
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Audio *audio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.audio = [self.player.audios add:@"song" duration:122];
        [self.audio sendPlay];
    }
    @end
    
  2. Tagging audio media play with refresh (refresh period cannot be less than 5 seconds)
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            let audio = player.audios.add("song", duration:122)
    	    // Refresh duration 10sec
            audio.sendPlay(10)
    
            /// with buffering (>= 2.11.0)
            audio.sendPlay(true)
        }
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        Audio *a = [self.player.audios add:@"song" duration:122];
        // Refresh duration 10 seconds
        [a sendPlay:10];
    
        /// with buffering (>= 2.11.0)
        [a sendPlayWithIsBuffering:YES];
    }
    @end
    
  3. Tagging an audio media ‘pause’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var audio: Audio!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillDisappear(animated: Bool) {
            audio.sendPause()
        }
    
        override func viewWillAppear(animated: Bool) {
            audio = player.audios.add("song", mediaTheme1:"theme1", mediaTheme2:"theme2", mediaTheme3:"theme3", duration: 122)
            audio.sendPlay()
        }
    
    }
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Audio *audio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [self.audio sendPause];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.audio = [self.player.audios add:@"song" mediaTheme1:@"theme1" mediaTheme2:@"theme2" mediaTheme3: @"theme3" duration:122];
        [self.audio sendPlay];
    }
    
    @end
    
  4. Tagging an audio media ‘stop’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var audio: Audio!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillDisappear(animated: Bool) {
            audio.sendStop()
        }
    
        override func viewWillAppear(animated: Bool) {
            audio = player.audios.add("song", duration: 122)
            audio.sendPlay()
        }
    
    }
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Audio *audio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
        [self.audio sendStop];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.audio = [self.player.audios addWithName:@"song" duration:122];
        [self.audio sendPlay];
    }
    
    @end
    
  5. Tagging audio information
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var audio: Audio!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        override func viewWillAppear(animated: Bool) {
            audio = player.audios.add("song", duration: 122)
            audio.sendPlay()
    
            /// >= 2.11.0
            audio.sendInfo()
            /// with buffering
            audio.sendInfo(true)
        }
    
    }
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Audio *audio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
        self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.audio = [self.player.audios addWithName:@"song" duration:122];
        [self.audio sendPlay];
    
        /// >= 2.11.0
        [self.audio sendInfo];
        /// with buffering
        [self.audio sendInfoWithIsBuffering:YES];
    }
    
    @end
    
  6. Tagging others actions on the audio
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
        let tracker = ATInternet.sharedInstance.defaultTracker
        var player: MediaPlayer!
        var audio: Audio!
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            player = tracker.mediaPlayers.add()
        }
    
        // Custom method
        func othersActions() {
            audio.sendMove()
            /// >= 2.11.0
            audio.sendEmail()
            audio.sendShare()
            audio.sendFavor()
            audio.sendDownload()
        }
    
        override func viewWillAppear(animated: Bool) {
            audio = player.audios.add("song", duration: 122)
            audio.sendPlay()
        }
    
    }
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Audio *audio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
        self.player = [self.tracker.mediaPlayers add];
    }
    
    // Custom method
    - (void)othersActions {
        [self.audio sendMove];
        /// >= 2.11.0
        [self.audio sendEmail];
        [self.audio sendFavor];
        [self.audio sendDownload];
        [self.audio sendShare];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        self.audio = [self.player.audios addWithName:@"song" duration:122];
        [self.audio sendPlay];
    }
    
    @end
    
 

LiveAudio

The MediaPlayer object makes a LiveAudios object available. This
object exposes the following methods:

  • add: Enables the addition of live audio media to the player and
    returns a LiveAudio object.
  • remove: Deletes a live audio media
  • removeAll: Deletes all live audio media
 

Tagging examples

  1. Tagging a live audio media play without refresh
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let liveAudio = player.liveAudios.add("song")
    
    		liveAudio.sendPlayWithoutRefresh()
    
    		/// with buffering (>= 2.11.0)
    		liveAudio.sendPlayWithoutRefresh(true)
    	}
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	LiveAudio *liveAudio = [self.player.liveAudios add:@"song"];
    
    	[liveAudio sendPlayWithoutRefresh];
    
    	/// with buffering (>= 2.11.0)
    	[liveAudio sendPlayWithoutRefreshWithIsBuffering:YES];
    }
    
    @end
  2. Tagging a live audio media play with refresh (refresh period cannot be less than 5 seconds)
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let liveAudio = player.liveAudios.add("song", mediaTheme1: "theme1")
    
    		// Refresh duration 10sec
    		liveAudio.sendPlay(10)
    
    		/// with buffering (>= 2.11.0)
    		liveAudio.sendPlay(true)
    	}
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	LiveAudio *liveAudio = [self.player.liveAudios add:@"song" mediaTheme1:@"theme1"];
    
    	// Refresh duration 10sec
    	[liveAudio sendPlay:10];
    
    	/// with buffering (>= 2.11.0)
    	[liveAudio sendPlayWithIsBuffering:YES];
    }
    
    @end
    
  3. Tagging a live audio media ‘pause’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveAudio: LiveAudio!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillDisappear(animated: Bool) {
    		liveAudio.sendPause()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		liveAudio = player.videos.add("song")
    		liveAudio.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveAudio *liveAudio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
    	[self.liveAudio sendPause];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveAudio = [self.player.liveAudios add:@"song"];
    	[self.liveAudio sendPlay];
    }
    
    @end
    
  4. Tagging a live audio media ‘stop’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveAudio: LiveAudio!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillDisappear(animated: Bool) {
    		liveAudio.sendStop()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		liveAudio = player.videos.add("song")
    		liveAudio.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveAudio *liveAudio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
    	[self.liveAudio sendStop];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveAudio = [self.player.liveAudios add:@"song"];
    	[self.liveAudio sendPlay];
    }
    
    @end
    
  5. Tagging live audio information
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveAudio: LiveAudio!
    
    	override func viewDidLoad() {
    	    super.viewDidLoad()
    
    	    player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    	    liveAudio = player.liveAudios.add("song")
    	    liveAudio.sendPlay()
    
    	    /// >= 2.11.0
    	    liveAudio.sendInfo()
    	    /// with buffering
    	    liveAudio.sendInfo(true)
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveAudio *liveAudio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveAudio = [self.player.liveAudios add:@"movie"];
    	[self.liveAudio sendPlay];
    
    	/// >= 2.11.0
    	[self.liveAudio sendInfo];
    	/// with buffering
    	[self.liveAudio sendInfoWithIsBuffering:YES];
    }
    
    @end
    
  6. Tagging others actions on the live audio
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveAudio: LiveAudio!
    
    	override func viewDidLoad() {
    	    super.viewDidLoad()
    
    	    player = tracker.mediaPlayers.add()
    	}
    
    	// Custom method
    	func othersActions() {
    	    liveAudio.sendMove()
    	    /// >= 2.11.0
    	    liveAudio.sendShare()
    	    liveAudio.sendEmail()
    	    liveAudio.sendFavor()
    	    liveAudio.sendDownload()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    	    liveAudio = player.liveAudios.add("song")
    	    liveAudio.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveAudio *liveAudio;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    // Custom method
    - (void)othersActions {
    	[self.liveAudio sendMove];
    	/// >= 2.11.0
    	[self.liveAudio sendShare];
    	[self.liveAudio sendDownload];
    	[self.liveAudio sendFavor];
    	[self.liveAudio sendEmail];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveAudio = [self.player.liveAudios add:@"movie"];
    	[self.liveAudio sendPlay];
    }
    
    @end
    
 

Medium

The MediaPlayer object makes a Media object available.
This object exposes the following methods:

  • add : Enables the addition of a medium and returns a Medium
    object.
  • remove : Deletes a medium
  • removeAll : Deletes all media
 

Tagging examples

  1. Tagging medium play without refresh
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let medium = player.media.add("medium", mediaType: "customType", duration: 56)
    
    		medium.sendPlayWithoutRefresh()
    		medium.sendPlayWithoutRefresh(true)
    	}
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	Medium *medium = [self.player.media add:@"medium" mediaType:@"customType" duration:56];
    
    	[medium sendPlayWithoutRefresh];
    	[medium sendPlayWithoutRefreshWithIsBuffering:YES];
    }
    
    @end
  2. Tagging medium play with refresh (refresh period cannot be less than 5 seconds)
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let medium = player.media.add("medium", mediaType: "customType", duration: 56)
    
    		medium.sendPlay()
    
    		/// with buffering
    		medium.sendPlay(true)
    	}
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	Medium *medium = [self.player.media add:@"medium" mediaType:@"customType" duration:56];
    
    	[medium sendPlay];
    
    	/// with buffering
    	[medium sendPlayWithIsBuffering:YES];
    }
    
    @end
    
  3. Tagging a medium ‘pause’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var medium: Medium!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillDisappear(animated: Bool) {
    		medium.sendPause()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let medium = player.media.add("medium", mediaType: "customType", duration: 56)
    		medium.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Medium *medium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
    	[self.medium sendPause];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.medium = [self.player.media add:@"medium" mediaType:@"customType" duration:56];
    	[self.medium sendPlay];
    }
    
    @end
    
  4. Tagging medium ‘stop’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var medium: Medium!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillDisappear(animated: Bool) {
    		medium.sendStop()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		medium = player.media.add("medium", mediaType:"customType", duration:56)
    		medium.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Medium *medium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
    	[self.medium sendStop];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.medium = [self.player.media add:@"medium" mediaType:@"customType" duration:56];
    	[self.medium sendPlay];
    }
    
    @end
    
  5. Tagging medium information
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var medium: Medium!
    
    	override func viewDidLoad() {
    	    super.viewDidLoad()
    
    	    player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    	    medium = player.media.add("medium", mediaType: "customType", duration: 56)
    	    medium.sendPlay()
    
    	    medium.sendInfo()
    	    medium.sendInfo(true)
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Medium *medium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.medium = [self.player.media add:@"movie" mediaType:@"customType" duration:56];
    	[self.medium sendPlay];
    
    	[self.medium sendInfo];
    	[self.medium sendInfoWithIsBuffering:YES];
    }
    
    @end
    
  6. Tagging others actions on the medium
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var medium: Medium!
    
    	override func viewDidLoad() {
    	    super.viewDidLoad()
    
    	    player = tracker.mediaPlayers.add()
    	}
    
    	// Custom method
    	func othersActions() {
    	    medium.sendMove()
    	    medium.sendShare()
    	    medium.sendEmail()
    	    medium.sendFavor()
    	    medium.sendDownload()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    	    medium = player.media.add("song", mediaType:"customType", duration:56)
    	    medium.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) Medium *medium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    // Custom method
    - (void)othersActions {
    	[self.medium sendMove];
    	/// >= 2.11.0
    	[self.medium sendShare];
    	[self.medium sendDownload];
    	[self.medium sendFavor];
    	[self.medium sendEmail];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.medium = [self.player.media add:@"movie" mediaType:@"customType" duration:56];
    	[self.medium sendPlay];
    }
    
    @end
    
 

LiveMedium

The MediaPlayer object makes a LiveMedia object available.
This object exposes the following methods:

  • add : Enables the addition of live medium to the player and returns a
    LiveMedium object.
  • remove : Deletes a live medium
  • removeAll : Deletes all live medium
 

Tagging examples

  1. Tagging live medium play without refresh
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let liveMedium = player.liveMedia.add("medium", mediaType: "customType")
    
    		liveMedium.sendPlayWithoutRefresh()
    		liveMedium.sendPlayWithoutRefresh(true)
    	}
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	LiveMedium *liveMedium = [self.player.liveMedia add:@"medium" mediaType:@"customType"];
    
    	[liveMedium sendPlayWithoutRefresh];
    	[liveMedium sendPlayWithoutRefreshWithIsBuffering:YES];
    }
    
    @end
  2. Tagging live medium play with refresh (refresh period cannot be less than 5 seconds)
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let liveMedium = player.liveMedia.add("medium", mediaType: "customType")
    
    		liveMedium.sendPlay()
    
    		/// with buffering
    		liveMedium.sendPlay(true)
    	}
    
    }
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	LiveMedium *liveMedium = [self.player.liveMedia add:@"medium" mediaType:@"customType"];
    
    	[liveMedium sendPlay];
    
    	/// with buffering
    	[liveMedium sendPlayWithIsBuffering:YES];
    }
    
    @end
    
  3. Tagging a live medium ‘pause’
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveMedium: LiveMedium!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillDisappear(animated: Bool) {
    		medium.sendPause()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		let liveMedium = player.liveMedia.add("medium", mediaType: "customType")
    		liveMedium.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveMedium *liveMedium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
    	[self.liveMedium sendPause];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveMedium = [self.player.liveMedia add:@"medium" mediaType:@"customType"];
    	[self.liveMedium sendPlay];
    }
    
    @end
    
  4. Tagging a live medium stop
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveMedium: LiveMedium!
    
    	override func viewDidLoad() {
    		super.viewDidLoad()
    
    		player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillDisappear(animated: Bool) {
    		liveMedium.sendStop()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    		liveMedium = player.liveMedia.add("song", mediaType:"customType")
    		liveMedium.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveMedium *liveMedium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
    	[self.liveMedium sendStop];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveMedium = [self.player.liveMedia add:@"medium" mediaType:@"customType"];
    	[self.liveMedium sendPlay];
    }
    
    @end
    
  5. Tagging live medium information
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveMedium: LiveMedium!
    
    	override func viewDidLoad() {
    	    super.viewDidLoad()
    
    	    player = tracker.mediaPlayers.add()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    	    liveMedium = player.liveMedia.add("medium", mediaType: "customType")
    	    liveMedium.sendPlay()
    
    	    liveMedium.sendInfo()
    	    liveMedium.sendInfo(true)
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveMedium *liveMedium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveMedium = [self.player.liveMedia add:@"movie" mediaType:@"customType"];
    	[self.liveMedium sendPlay];
    
    	[self.liveMedium sendInfo];
    	[self.liveMedium sendInfoWithIsBuffering:YES];
    }
    
    @end
    
  6. Tagging others actions on the live medium
    import UIKit
    import Tracker
    
    class ViewController: UIViewController {
    
    	let tracker = ATInternet.sharedInstance.defaultTracker
    	var player: MediaPlayer!
    	var liveMedium: LiveMedium!
    
    	override func viewDidLoad() {
    	    super.viewDidLoad()
    
    	    player = tracker.mediaPlayers.add()
    	}
    
    	// Custom method
    	func othersActions() {
    	    liveMedium.sendMove()
    	    liveMedium.sendShare()
    	    liveMedium.sendEmail()
    	    liveMedium.sendFavor()
    	    liveMedium.sendDownload()
    	}
    
    	override func viewWillAppear(animated: Bool) {
    	    liveMedium = player.liveMedia.add("medium", mediaType:"customType")
    	    liveMedium.sendPlay()
    	}
    
    }
    
    #import "ViewController.h"
    #import "SmartTracker/SmartTracker-Swift.h"
    
    @interface ViewController ()
    
    @property (nonatomic, strong) Tracker *tracker;
    @property (nonatomic, strong) MediaPlayer *player;
    @property (nonatomic, strong) LiveMedium *liveMedium;
    
    @end
    
    @implementation ViewController
    
    - (void)viewDidLoad {
    	[super viewDidLoad];
    
    	self.tracker = [[ATInternet sharedInstance] defaultTracker];
    
    	self.player = [self.tracker.mediaPlayers add];
    }
    
    // Custom method
    - (void)othersActions {
    	[self.liveMedium sendMove];
    	/// >= 2.11.0
    	[self.liveMedium sendShare];
    	[self.liveMedium sendDownload];
    	[self.liveMedium sendFavor];
    	[self.liveMedium sendEmail];
    }
    
    - (void)viewWillAppear:(BOOL)animated {
    	self.liveMedium = [self.player.liveMedia add:@"movie" mediaType:@"customType"];
    	[self.liveMedium sendPlay];
    }
    
    @end
    
 

Buffering management (>= 2.11.0)

Since 2.11.0 release, it’s possible to measure buffering delay for every media type.

 

Tagging examples

import UIKit
import Tracker

class ViewController: UIViewController {

	let tracker = ATInternet.sharedInstance.defaultTracker
	var player: MediaPlayer!
	var liveMedium: LiveMedium!

	override func viewDidLoad() {
		super.viewDidLoad()

		player = tracker.mediaPlayers.add()
		liveMedium = player.liveMedia.add("medium", mediaType: "customType")
	}
}
#import "ViewController.h"
#import "SmartTracker/SmartTracker-Swift.h"

@interface ViewController ()

@property (nonatomic, strong) Tracker *tracker;
@property (nonatomic, strong) MediaPlayer *player;
@property (nonatomic, strong) LiveMedium *liveMedium;

@end

@implementation ViewController

- (void)viewDidLoad {
	[super viewDidLoad];

	self.tracker = [[ATInternet sharedInstance] defaultTracker];

	self.player = [self.tracker.mediaPlayers add];

	self.liveMedium = [self.player.liveMedia add:@"medium" mediaType:@"customType"];
}

@end

  1. Starting a playback without buffering
    liveMedium.sendPlay()
    [self.liveMedium sendPlay];
  2. Starting a playback with buffering
    liveMedium.sendPlay(true)
    [self.liveMedium sendPlayWithIsBuffering:YES];
  3. Resume the playback after buffering
    liveMedium.sendInfo(false)
    [self.liveMedium sendInfoWithIsBuffering:NO]
  4. Buffering for an ongoing playback
    liveMedium.sendInfo(true)
    [self.liveMedium sendInfoWithIsBuffering:YES]
 

Shared properties

Name Type Default value Description
mediaLabel String Empty string Gets or sets the name of the viewed media
mediaTheme1 String? nil Gets or sets the first chapter
mediaTheme2 String? nil Gets or sets the second chapter
mediaTheme3 String? nil Gets or sets the third chapter
mediaLevel2 Int? nil Gets or sets the level 2 ID
isEmbedded Bool? false Indicates if the media is external to the application
webdomain String? nil Gets or sets the media referrer in case of external placements (isEmbedded at true)
linkedContent String? nil Gets or sets the label/name of the content related to an ad (pre-roll, mid-roll or post-roll)
 

MediaPlayer class

 

Properties

Name Type Default value Description
playerId Int 1 Gets or sets the player ID
videos Videos nil Gets the instance allowing video management
audios Audios nil Gets the instance allowing audio media management
media (>= 2.11.0) Media nil Gets the instance allowing media management
liveVideos LiveVideos nil Gets the instance allowing live video management
liveAudios LiveAudios nil Gets the instance allowing live audio media management
liveMedia (>= 2.11.0) LiveMedia nil Gets the instance allowing live media management

Management
of player ID is
automatic but you can nonetheless specify one.

 

Video class

 

Properties

Name Type Default value Description
duration Int 0 Gets or sets total video length, in seconds
 

Audio class

 

Properties

Name Type Default value Description
duration Int 0 Gets or sets total audio media length, in seconds
 

Medium class

 

Properties

Name Type Default value Description
duration Int 0 Gets or sets total audio media length, in seconds
 

Methods

Name Return type Description
sendPlay() (< 2.9.0) void Sends a play hit with an automatic refresh of 5 seconds
sendPlay() (>= 2.9.0) void Sends a play hit with an automatic refresh defined by steps (see above)
sendPlay(isBuffering: Bool) (>= 2.11.0) void Sends a play hit with an automatic refresh defined by steps (see above) with buffering specification
sendPlay(refreshDuration: Int) (deprecated since 2.9.0) void Sends the play hit with an automatic refresh, given in parameters (0 = refresh
disabled)
sendPlay(refreshDuration: Dictionary<Int, Int>) (>= 2.9.0) void Sends a play hit with an automatic refresh defined by parameter
sendPlay(refreshDuration: Dictionary<Int, Int>, isBuffering: Bool) (>= 2.11.0) void Sends a play hit with an automatic refresh defined by parameter with buffering specification
sendPlayWithoutRefresh() (>= 2.9.0) void Sends a play hit without refresh
sendPlayWithoutRefresh(isBuffering: Bool) (>= 2.11.0) void Sends a play hit without refresh with buffering specification
sendResume() (>= 2.9.0) void Resuming playback in the current state
sendResume(isBuffering: Bool) (>= 2.11.0) void Resuming playback in the current state with buffering specification
sendPause void Sends “pause” hit
sendStop void Sends “stop” hit
sendInfo (>= 2.11.0) void Sends information hit
sendInfo(isBuffering: Bool) (>= 2.11.0) void Sends information hit with buffering specification
sendMove void Sends play cursor “movement” hit
sendShare (>= 2.11.0) void Sends sharing hit
sendDownload (>= 2.11.0) void Sends download hit
sendEmail (>= 2.11.0) void Sends emailing hit
sendFavor (>= 2.11.0) void Sends favor hit
 

Was this post helpful?

Last update: 21/03/2019