title: JavaFX MediaPlayer loop
body: <p>I am working on a simpel game and I would like to have a video background. I first did this using a gif but this runs kind of slow. Now I created a video background using the mediaplayer and it works perfectly.
  The video show without a problem. </p>
  
  <p>The only problem I have is that the video does not want to loop. I tried every single aproache i found on the internet but nothing seems to work. 
  The video always plays 1 time and then stops.
  I am using the java JDK8. Windows 10, 64 bit.</p>
  
  <p>This is my code:</p>
  
  <pre><code>Media media = new
  Media(getClass().getClassLoader().getResource("img/menu.mp4").toString());
  
  MediaPlayer player = new MediaPlayer(media);
  player.setAutoPlay(true);
  player.setCycleCount(MediaPlayer.INDEFINITE);
  MediaView view = new MediaView(player);
  </code></pre>
  
  <p>All of this is inside a stackpane. </p>
  
  <p>I have tried exporting the mp4 to flv but this does not work. </p>
  
  <p>If anyone knows different ways to create a video background, everything is welcome.</p>
  
  <p><strong>Edit:</strong>
  So far no luck, I was thinking of using:</p>
  
  <pre><code>player.setOnEndOfMedia(new Runnable() {
              @Override
              public void run() {
                  player.seek(Duration.ZERO);
              }
          }); 
  </code></pre>
  
  <p>But not even this works..</p>