This how-to guide describes how to integrate THEOplayer with VueJS framework.
npm install vue
vue create theoplayer-vuejs-sample
cd theoplayer-vuejs-sample
npm run serve
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>theoplayer-vuejs-sample</title>
<link
rel="stylesheet"
type="text/css"
href="//cdn.theoplayer.com/dash/theoplayer/ui.css"
/>
</head>
<body>
<noscript>
<strong
>We're sorry but theoplayer-vuejs-sample doesn't work properly without
JavaScript enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
<script
type="text/javascript"
src="//cdn.theoplayer.com/dash/theoplayer/THEOplayer.js"
></script>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div
class="theoplayer-container video-js theoplayer-skin vjs-16-9 THEOplayer"
ref="theoplayer"
></div>
</template>
<script>
export default {
props: ["source"],
mounted: function() {
this.playerInit();
},
methods: {
playerInit() {
const player = new window.THEOplayer.Player(this.$refs.theoplayer, {
fluid: true,
libraryLocation: "//cdn.theoplayer.com/dash/theoplayer/"
});
player.source = {
sources: this.source
};
}
}
};
</script>
<style>
.THEOplayer {
width: 50%;
margin: 0 auto;
}
.video-js.vjs-16-9 {
padding-top: 28.12%;
width: 50%;
}
</style>
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png" />
<Player :source="source" v-if="source" />
</div>
</template>
<script>
import Player from "./components/Player.vue";
export default {
name: "app",
components: {
Player
},
data: function() {
return {
source: [
{
type: "application/x-mpegurl",
src: "//cdn.theoplayer.com/video/elephants-dream/playlist.m3u8"
}
]
};
}
};
</script>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>theoplayer-vuejs-sample</title>
<link rel="stylesheet" type="text/css" href="libs/THEOplayer/ui.css" />
</head>
<body>
<noscript>
<strong
>We're sorry but theoplayer-vuejs-sample doesn't work properly without
JavaScript enabled. Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
<script type="text/javascript" src="libs/THEOplayer/THEOplayer.js"></script>
<!-- built files will be auto injected -->
</body>
</html>
const player = new window.THEOplayer.Player(this.$refs.theoplayer, {
fluid: true,
libraryLocation: "./libs/THEOplayer"
});