Function: image-toggle-animation

image-toggle-animation is an interactive and byte-compiled function defined in image-mode.el.gz.

Signature

(image-toggle-animation)

Documentation

Start or stop animating the current image.

If image-animate-loop is non-nil, animation loops forever. Otherwise it plays once, then stops.

Probably introduced at or before Emacs version 24.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/image-mode.el.gz
(defun image-toggle-animation ()
  "Start or stop animating the current image.
If `image-animate-loop' is non-nil, animation loops forever.
Otherwise it plays once, then stops."
  (interactive)
  (let ((image (image-get-display-property))
	animation)
    (cond
     ((null image)
      (error "No image is present"))
     ((null (setq animation (image-multi-frame-p image)))
      (message "No image animation."))
     (t
      (let ((timer (image-animate-timer image)))
	(if timer
	    (cancel-timer timer)
	  (let ((index (plist-get (cdr image) :index)))
	    ;; If we're at the end, restart.
	    (and index
		 (>= index (1- (car animation)))
		 (setq index nil))
	    (image-animate image index
			   (if image-animate-loop t)))))))))