I am trying to import a player into my vue.js file. Normally I would use a script file outside of the template, but that does not work.
In an html file what I would do is the following:
<div id="player">
<div id="vplayer"></div>
</div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js"></script>
<script>
var urlsrc = "http://www.streambox.fr/playlists/x36xhzz/x36xhzz.m3u8";
var player = new Clappr.Player({source: urlsrc, parentId: "#vplayer", height: 240, width: 320});
</script>
In vue.js I am trying to do the same thing with the following return code, but it does not work:
<template>
<div id="player">
<div id="vplayer"></div>
</div>
</template>
<script>
export default {
name: 'player',
data () {
return {
script: 'https://cdn.jsdelivr.net/npm/clappr@latest/dist/clappr.min.js',
url: 'http://www.streambox.fr/playlists/x36xhzz/x36xhzz.m3u8',
player: new Clappr.Player({source: this.url, parentId: "#vplayer", height: 240, width: 320})
}
}
}
</script>
I get an error saying that the player is undefined. How can I get normal scripts to run inside of vue.js?