ionic添加cordova插件-NativeAudio

gzgchzc博客最新更新地址:http://blog.gzvtc.cc/

NativeAudio
Cordova / PhoneGap 3.5 +本地音频播放,针对HTML5游戏和音频应用所需的最小延迟,复调和并发。

cordova plugin add cordova-plugin-nativeaudio

Examples

module.controller('MyCtrl', function($scope, $cordovaNativeAudio, $timeout) {

  $cordovaNativeAudio
    .preloadSimple('click', 'audio/click.mp3')
    .then(function (msg) {
      console.log(msg);
    }, function (error) {
      alert(error);
    });

  $cordovaNativeAudio
    .preloadComplex('music', 'audio/music.mp3', 1, 1)
    .then(function (msg) {
      console.log(msg);
    }, function (error) {
      console.error(error);
    });

  $scope.play = function () {
    $cordovaNativeAudio.play('click');
    $cordovaNativeAudio.loop('music');

    // stop 'music' loop and unload
    $timeout(function () {
      $cordovaNativeAudio.stop('music');

      $cordovaNativeAudio.unload('click');
      $cordovaNativeAudio.unload('music');
    }, 1000 * 60);
  };

});
阅读更多
版权声明:本文为博主gzgchzc原创文章,转载必须注明出处。http://blog.gzvtc.cc/ https://blog.csdn.net/qq_33561700/article/details/53836844
上一篇ionic添加cordova插件-PinDialog
下一篇ionic使用cordovaMedia、cordovaFile和cordovaFileTransfer播放在线音乐
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭