Renamed function to toggleAutoplay for clarity.