helper functions for autoplay