Skip to main content
100%

A simple method to stop YouTube, Vimeo, and HTML5 videos from playing.

✓ Published0🌍 Public
MMistyBlunch
Last edited Jun 6, 2014
Created on Jul 4, 2018

This example demonstrates a JavaScript utility for pausing embedded videos within a webpage. It shows how to stop playback for both HTML5 `<video>` elements and iframe-based players from services like YouTube or Vimeo. The code defines a `stopVideo` function that takes a container element and uses the standard DOM API to pause the video. For iframes, it resets the `src` attribute by reassigning the iframe’s current `src` property, forcing a reload. For native `<video>` elements, it directly calls the `pause()` method. The example relies solely on native JavaScript DOM manipulation, with no external libraries or frameworks.

AI-generated description

Similar vizzes