voiceLive

1.1.11 • Public • Published

VoiceLive.js

Voice Live function library with Howler.js.

Installation

In a browser:

  <script src="voiceLive.js"></script> 

Using npm:

  $ npm i -S howler
  $ npm i -S voiceLive

Examples

img

  var datas = [{
    id: 4,
    src: 'xxxxx',
    time: 16,
    currentTime: 0
  }, {
    id: 4,
    src: 'xxxxx',
    time: 25,
    currentTime: 0
  }];
 
  var vl = new LiveAudio({
    datas: this.datas, 
    step: function (itemId, currentTime, progress) { // for live process, and like a timer 
      progress = (progress * 100).toFixed(2) // for to 100
      if (progress > 99) {
        progress = 100.00
      }
      $('#currentTime-' + itemId).text(Math.floor(currentTime) + 's');
      $('#progress-' + itemId).text(progress + '%')
    },
    events: { // events for current voice
      onload: function () {
        console.log('onload');
      },
      onloaderror: function () {
        console.log('onloaderror');
      },
      onplay: function () {
        console.log('onplay');
      },
      onpause: function () {
        console.log('onpause');
      },
      onstop: function () {
        console.log('onstop');
      },
      onend: function () {
        this.playNext(); // for auto play next item
        console.log('onend');
      }
    }
  });

Methods

  1. vl.play(id)

  2. vl.pause(id)

  3. vl.stop(id)

  4. vl.seek(id, time)

  5. vl.playNext()

  6. vl.playPre()

  7. vl.addVoice(data)

  8. vl.destory([id][,fn])

  9. vl.replaceVoice(id, src)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0
    • modifyPackageName
  • 1.1.11
    3
    • latest
  • 0
    • english
  • 0
    • modifyDoc
  • 0
    • newVersion
  • 0
    • fix bug
  • 0
    • modify git address
  • 0
    • add replace and destroy functions
  • 0
    • modify version
  • 0
    • 优化
  • 0
    • 增加销毁音频方法
  • 0
    • 增加seek方法
  • 0
    • changge version
  • 0
    • fix destory api, add duration param in seek
  • 0
    • 修复音频seek报错
  • 0
    • 调整代码
  • 1.1.11
    3
    • add option format

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.11
    3

Package Sidebar

Install

npm i voiceLive

Weekly Downloads

1

Version

1.1.11

License

MIT

Last publish

Collaborators

  • lzwai