private void startAnimation() {

    if (_slides == null || _slides.size() == 0 || _stoppedTransitions) {
      return;
    }

    _started = true;
    _lastTimeSlideLoaded = 0;

    if (_slides.size() == 1) {
      try {
        ImageCache.instance()
            .getImage(
                new URL(_slides.get(0).imageSrc),
                new OnLoadedListener() {
                  public void onLoaded(
                      URL url, BufferedImage image, boolean fromCache, boolean fail) {
                    _currentImage = image;
                    repaint();
                  }
                });
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }
    } else {
      _timer = new Timer();
      _timer.schedule(
          new TimerTask() {
            @Override
            public void run() {
              tryMoveNext(false);
            }
          },
          0,
          200); // Check every 200 milliseconds if we should trigger a transition
    }
  }
  private void tryMoveNext(boolean forceCurrentIndex) {

    if (_loadingNextImage) {
      return;
    }

    Slide slide = null;

    if (_currentSlideIndex == -1) {
      if (_randomStart) {
        _currentSlideIndex = new Random(System.currentTimeMillis()).nextInt(_slides.size());
      } else {
        _currentSlideIndex = 0;
      }
      _loadingNextImage = true;
      try {
        ImageCache.instance()
            .getImage(
                new URL(_slides.get(_currentSlideIndex).imageSrc),
                new OnLoadedListener() {
                  public void onLoaded(
                      URL url, BufferedImage image, boolean fromCache, boolean fail) {
                    _currentImage = image;
                    _loadingNextImage = false;
                    if (_currentImage != null) {
                      _lastImage = _currentImage;
                      _lastTimeSlideLoaded = System.currentTimeMillis();
                      repaint();
                    }
                  }
                });
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }
    } else {
      slide = _slides.get(_currentSlideIndex);
      if (forceCurrentIndex) {
        // Switch Image without
        try {
          ImageCache.instance()
              .getImage(
                  new URL(slide.imageSrc),
                  new OnLoadedListener() {
                    public void onLoaded(
                        URL url, BufferedImage image, boolean fromCache, boolean fail) {
                      _currentImage = prepareImage(image);

                      if (_transition != null) {
                        _transition.stop();
                      }

                      _transition = null;
                      repaint();
                    }
                  });
        } catch (MalformedURLException e) {
          e.printStackTrace();
        }
        return;
      } else if (slide.duration + _lastTimeSlideLoaded + _transitionTime
          < System.currentTimeMillis()) {
        _currentSlideIndex = (_currentSlideIndex + 1) % _slides.size();
        slide = _slides.get(_currentSlideIndex);
      } else {
        slide = null;
      }
    }

    if (slide != null) {
      _loadingNextImage = true;
      try {
        ImageCache.instance()
            .getImage(
                new URL(slide.imageSrc),
                new OnLoadedListener() {
                  public void onLoaded(
                      URL url, BufferedImage image, boolean fromCache, boolean fail) {
                    _currentImage = prepareImage(image);
                    if (_lastImage != null && _currentImage != null) {
                      _transition =
                          new FadeSlideTransition(SlideshowPanel.this, _lastImage, _currentImage);
                      _transitionTime = _transition.getEstimatedDuration();
                      _transition.start();
                    }
                    _loadingNextImage = false;
                    if (_currentImage != null) {
                      _lastImage = _currentImage;
                      _lastTimeSlideLoaded = System.currentTimeMillis();
                      repaint();
                    }
                  }
                });
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }
    }
  }