Static GitHub Issues

[1992] Need help using Media Element with Nuxt

prev: Use history.pushstate in NuxtJS
next: How to dynamic switch theme

Hi guys,

Is anyone try this with Nuxt? I'm trying to create a components with Media Element but I got this error MediaElement is not a constructor. Here is my file:

<template>
  <video width="320" height="240">
    <source type="video/mp4" src="video.mp4" />
  </video>
</template>

<script>
let MediaElementPlayer
if (process.browser) {
  MediaElementPlayer= require('mediaelement')
}

export default {
  mounted () {
    let player = new MediaElementPlayer('video', {
      pluginPath: 'https://cdnjs.com/libraries/mediaelement/',
      success: function (mediaElement, originalNode, instance) {

      }
    })
    player.on('play', () => {
      this.$emit('play')
    })
  }
}
</script>

Thanks!

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1768">#c1768</a>)</em></sub></div>