JavaScript Vue

Add an Audio Player to a Vue App with the xns-audio-player-simple Package

Spread the love

We can add a good look audio player to our Vue app with the xns-audio-player-simple package.

To install it, we run:

npm i xns-audio-player-simple

Then in main.js, we add:

import Vue from "vue";
import App from "./App.vue";
import XnsAudioPlayerSimple from "xns-audio-player-simple";

Vue.config.productionTip = false;

new Vue({
  render: h => h(App)

We called Vue.use(XnsAudioPlayerSimple); to register the plugin.

Next, in App.vue, we write:

  <div id="app">
    <xns-audio-player-simple :playlist="playlist"></xns-audio-player-simple>
export default {
  name: "App",
  data() {
    return {
      playlist: [
          artist: "singer",
          title: "music",
          album: "album",
          cover: ""

We have a playlist array with the entries being objects with the audio property with the URL or path to the audio file.

artist has the artist name.

title has the audio title.

album has the album name.

cover has the cover image URL.

Then we should see an audio player with the cover image referenced by the URL.

We can play and pause the audio as we please.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *