@cycjimmy/vue-h5-audio-controls

Simple h5 music controller for vue
660 12
Install
npm install @cycjimmy/vue-h5-audio-controls
Latest Version:2.1.0
Older releases:2
License:MIT
Last Updated:Aug 10, 2026
Links: GitHub  ·  npm
Maintainer: cycdpo

vue-h5-audio-controls

libraries dependency status libraries sourcerank Release date semantic-release npm license

  • Simple h5 music controller for vue. Demo.
  • This plugin extends @cycjimmy/h5-audio-controls to support vue@3. Its rendering mode is still DOM. h5 audio controls image
  • It is no longer supported vue@2. If you use vue@2, you can use v1.

Language: En | 中文


How to use

Install

NPM version NPM bundle size npm download

$ npm install @cycjimmy/vue-h5-audio-controls --save
# or
$ yarn add @cycjimmy/vue-h5-audio-controls

Usage

vue

Put <h5-audio-controls /> into vue node which is preferably the root node

<template>
  <h5-audio-controls :src />
</template>

<script setup>
  import { ref } from 'vue';
  import H5AudioControls from '@cycjimmy/vue-h5-audio-controls';

  const src = ref('https://www.xxx.com/foo.mp3');
</script>
  • Props

    • src: [Require][string] a url to an audio file
    • position: [Option][string] the position of audio controller.
      • Choose one of the four options:
        • 'left-top'
        • 'top-right'(Default)
        • 'right-bottom'
        • 'left-bottom'
    • positionType: [Option][string] Set position type of audio controller.
      • Choose one of the five options:
        • 'fixed'(Default)
        • 'absolute'
        • 'relative'
        • 'sticky'
        • 'static'
    • buttonSize: [Option][string|number] Set button wrapper size.
    • iconSize: [Option][string|number] Set button icon size.
    • playIcon: [Option][string] Set play icon.
    • pauseIcon: [Option][string] Set pause icon.
    • autoPlay: [Option][boolean] Whether to play immediately after loading. Default true.
  • Methods

    • play(): Play the audio.
    • pause(): Pause the audio.
    • stop(): Stop the audio.
    • isPlaying(): Return whether the audio is playing.

An advanced example

<template>
  <div>
    <h5-audio-controls 
      ref="h5AudioControlsRef"
      :src="audioControlsConfig.src"
      :position="audioControlsConfig.position"
      :positionType="audioControlsConfig.positionType"
      :buttonSize="audioControlsConfig.buttonSize"
      :iconSize="audioControlsConfig.iconSize"
      :playIcon="audioControlsConfig.playIcon"
      :pauseIcon="audioControlsConfig.pauseIcon"
      :autoPlay="audioControlsConfig.autoPlay"
    />

    <!-- This is an external control button to simulate methods -->
    <botton @click="trigger">Trigger</botton>
  </div>
</template>
  
<script setup>
  import { ref } from 'vue';
  import H5AudioControls from '@cycjimmy/vue-h5-audio-controls';
  
  import playIcon from './images/icon-play.png';
  import pauseIcon from './images/icon-pause.png';

  const h5AudioControlsRef = ref();
  const audioControlsConfig = ref({
    src: 'https://www.xxx.com/foo.mp3',
    position: 'left-top',
    positionType: 'fixed',
    buttonSize: '15vw',
    iconSize: '12vw',
    playIcon,
    pauseIcon,
    autoPlay: true,
  });

  const trigger = () => {
    if (h5AudioControlsRef.value.isPlaying()) {
      h5AudioControlsRef.value.pause();
    } else {
      h5AudioControlsRef.value.play();
    }
  };
</script>

CDN

jsdelivr

To use via a CDN include this in your html:

<script src="https://cdn.jsdelivr.net/npm/@cycjimmy/vue-h5-audio-controls@2/dist/h5-audio-controls.umd.js"></script>

<!-- or -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@cycjimmy/vue-h5-audio-controls@2/dist/h5-audio-controls.es.js"></script>

Related Packages

@gaidalou/control

Vue3 control component

5,398
@reasy-team/reasy-ui

Tenda基于Vue2.x的PC组件库。在线示例

3,044
@reasy-team/reasy-vui

移动端 UI 组件库。 在线示例

727
alanyitools

前端常用工具集:1、带波纹的音频录制功能;2、获取手机验证码功能;3、动态滑块选项...

693
vue-acl

Plugin of Access Control List from Vue JS 2

89,002 371

Version History

Version Released Vue License
2.1.0 MIT
2.0.1 MIT
2.0.0 MIT
1.2.0 MIT
1.1.0 ^2.6.12 MIT