Search code examples
swiftapple-tvtvml

How to disable Scrubbing in TVMLKit JS Player Class


I am trying to stop users from scrubbing forward (skipping ads) in the TVMLKit Player class.

I have tried setting

player.interactiveOverlayDocument = null;

but the player still shows the Transport bar, and I am able to scrub forward.


Solution

  • Turns out to be quite easy.

    On the MediaItem Class which the Player Class uses to load the video, there is an attribute interstitials that accepts an array of [starttiem, duration] values.

    var singleVideo = new MediaItem(mediaType, videourl);
    var videoInterstitials = [];
    
    videoInterstitials.push({
                                starttime: 50,
                                duration: 30
                            });
    singleVideo.interstitials = videoInterstitials;
    var videoList = new Playlist();
    videoList.push(singleVideo);
    var player = new Player();
    player.playlist = videoList;
    player.play();