Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to successfully destroy a MediaElementPlayer and create a new one
    primarykey
    data
    text
    <p>Here's the scenario:</p> <p>I have a page that contains a <code>video</code> element which is set up with a video. The source of this video may be HTML5 video with multiple sources (and Flash fallback) or a YouTube video. Beneath this is a number of images which serve as video thumbnails, clicking on one should load the appropriate video, by destroying the existing MediaElementPlayer and creating a new one on the same <code>video</code> element.</p> <p>This creates the initial player on page load:</p> <pre><code>$('video').mediaelementplayer({ alwaysShowControls: true }); </code></pre> <p>And this is intended to change the player when one of the images is clicked:</p> <pre><code>$('video').mediaelementplayer({ alwaysShowControls: true, success: function(media, dom, player) { console.log('success!'); }, error: function() { console.log('error!'); } }); </code></pre> <p>But it doesn't work. The <code>success</code> function is never entered (neither is <code>error</code>) and nothing appears to happen.</p> <p>I guess the library still thinks that the original player exists or something, and have tried a number of things to try and tell it that this isn't the case, for example:</p> <pre><code>mejs.meIndex = 0 mejs.players = [] </code></pre> <p>To no effect, and setting: </p> <pre><code>window.mejs = null; window.MediaElementPlayer = null; window.MediaElement = null; </code></pre> <p>Just breaks things :)</p> <p>Can anyone out there help? I'm sure I'm missing something simple here so I'd be very grateful if someone could point out what! Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload