Apple TV TVML Video Loop

216 views Asked by At

In html5 there is a simple way to loop a video. See here. I want to know if something like this exists for Apple TV's TVJS and TVML.

I can get it to loop in the javascript like this:

if(videoURL && event.type === "select") {
  var player = new Player();
  var playlist = new Playlist();
  var mediaItem = new MediaItem("video", videoURL);

  player.playlist = playlist;
  for (var i = 0; i < 10; i++) {
    player.playlist.push(mediaItem);
  }

  player.present();
}

However, this shows the video progress bar every time a new instance of the video starts, and this is not the functionality that I want. I want to loop continuously until exited.

Thanks in advance for any help here.

1

There are 1 answers

0
absolom Mugwagwa On

Your code was not too far off, you had 1 issue :

player.present();

was suppose to be :

player.play();

here is the refactored code that works with tvml:

function playAndLoopVideo(src) {
player = new Player();
var mediaItem = new MediaItem("video", src);
player.playlist = new Playlist();

for (var i = 0; i < 10; i++) {
player.playlist.push(mediaItem);
}

player.play();
}