def anim_to_html(anim):
    """
    Convert an animation into an embedable HTML element.

    This converts the animation objects returned by ``play_sta()`` and
    ``play_rates()`` into an HTML tag that can be embedded, for example
    in a Jupyter notebook.

    Paramters
    ---------
    anim : matplotlib.animation.Animation
        The animation object to embed.

    Returns
    -------
    html : IPython.display.HTML
        An HTML object with the encoded video. This can be directly embedded
        into an IPython notebook.

    Raises
    ------
    An ImportError is raised if the IPython modules required to convert the
    animation are not installed.
    """
    from IPython.display import HTML
    return HTML(anim.to_html5_video())
