GithubHelp home page GithubHelp logo

rakesh-mohanta / ngwebaudio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nehz/ngwebaudio

0.0 2.0 0.0 81 KB

AngularJS module for playing audio using the WebAudio API

License: MIT License

HTML 7.83% JavaScript 92.17%

ngwebaudio's Introduction

#ngWebAudio ngWebAudio is an AngularJS module for playing audio using the WebAudio API.

HTML5 Audio is used if WebAudio is unavailable.

One motivation for using WebAudio is that you can buffer audio on page load for mobile browsers. Currently most mobile browsers will not pre-buffer HTML5 audio elements unless it is interacted with, and will also ignore XHR caches. The work-around is to fetch and cache audio via XHR, and play it back using the WebAudio.

#Usage

angular.module('my-app', ['ngWebAudio'])
  .controller('controller', function($scope, WebAudio) {
    // ...
  });

Module: ngWebAudio

Service: WebAudio

API

var audio = WebAudio(path_to_audio, [options]);

// Automatically called on creation if options.buffer = true (default)
// otherwise will be called when audio is first played
audio.buffer();

// Current position in audio track
audio.offset();

audio.play();
audio.stop();
audio.pause();

// Options for audio object
audio.options

See demo/demo.html for an example.

Options

options = {
  buffer = true,
  loop = false,
  gain = 1,
  retryInterval = 1000  // Retry interval if buffering fails
}

Events

audio.onPlay = function() { ... }   // When media first starts playing
audio.onEnd = function() { ... }    // When media stops playing

Callbacks are attached to the audio object that is returned.

##Installation

bower install ng-webaudio

##Testing

npm install -g karma-cli
npm install
bower install
karma test

##License MIT licensed. See LICENSE for details.

ngwebaudio's People

Contributors

nehz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.