From 5ef95fc1911133cdad4ad7cbb795d146b18aa01b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e=20Kooi?= Date: Sun, 27 Mar 2016 13:31:16 +0200 Subject: [PATCH] deps: use native Audio constructor instead of play-audio --- .../new-chain/.gitignore | 2 - .../new-chain/.npmignore | 4 - .../new-chain/README.md | 59 ----------- .../new-chain/index.js | 55 ----------- .../new-chain/package.json | 12 --- .../play-audio/.gitignore | 2 - .../play-audio/.npmignore | 5 - .../play-audio/README.md | 99 ------------------- .../play-audio/index.js | 1 - .../play-audio/lib/mime.js | 17 ---- .../play-audio/lib/player.js | 75 -------------- .../play-audio/lib/render.js | 8 -- .../play-audio/lib/src.js | 31 ------ .../play-audio/lib/templates.js | 1 - .../play-audio/package.json | 16 --- package.json | 1 - src/actions/ChatActionCreators.js | 3 +- 17 files changed, 1 insertion(+), 390 deletions(-) delete mode 100644 .temp-unpublished-node_modules/new-chain/.gitignore delete mode 100644 .temp-unpublished-node_modules/new-chain/.npmignore delete mode 100644 .temp-unpublished-node_modules/new-chain/README.md delete mode 100644 .temp-unpublished-node_modules/new-chain/index.js delete mode 100644 .temp-unpublished-node_modules/new-chain/package.json delete mode 100644 .temp-unpublished-node_modules/play-audio/.gitignore delete mode 100644 .temp-unpublished-node_modules/play-audio/.npmignore delete mode 100644 .temp-unpublished-node_modules/play-audio/README.md delete mode 100644 .temp-unpublished-node_modules/play-audio/index.js delete mode 100644 .temp-unpublished-node_modules/play-audio/lib/mime.js delete mode 100644 .temp-unpublished-node_modules/play-audio/lib/player.js delete mode 100644 .temp-unpublished-node_modules/play-audio/lib/render.js delete mode 100644 .temp-unpublished-node_modules/play-audio/lib/src.js delete mode 100644 .temp-unpublished-node_modules/play-audio/lib/templates.js delete mode 100644 .temp-unpublished-node_modules/play-audio/package.json diff --git a/.temp-unpublished-node_modules/new-chain/.gitignore b/.temp-unpublished-node_modules/new-chain/.gitignore deleted file mode 100644 index 93f136199..000000000 --- a/.temp-unpublished-node_modules/new-chain/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -npm-debug.log diff --git a/.temp-unpublished-node_modules/new-chain/.npmignore b/.temp-unpublished-node_modules/new-chain/.npmignore deleted file mode 100644 index f4b4121e0..000000000 --- a/.temp-unpublished-node_modules/new-chain/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -test -test.js -example -examples diff --git a/.temp-unpublished-node_modules/new-chain/README.md b/.temp-unpublished-node_modules/new-chain/README.md deleted file mode 100644 index 292660847..000000000 --- a/.temp-unpublished-node_modules/new-chain/README.md +++ /dev/null @@ -1,59 +0,0 @@ -## new-chain [![Build Status](https://travis-ci.org/azer/new-chain.png?branch=master)](https://travis-ci.org/azer/new-chain) - -Create chaining APIs from functions - -## Install - -```bash -$ npm install new-chain -``` - -## Usage - -```js -Num(3).sum(10).sub(5).mul(2).val() -// => 16 - -function Num(x){ - - var x = 0 - var chain = newChain(sum, sub, mul) // or: { alias: mul, mul:mul } or: newChain({ alias: mul }, mul) - - chain.val = val - - return chain - - function mul(n){ - x *= n - } - - function sum(n){ - x += n - } - - function sub(n){ - x -= n - } - - function val(n){ - return x - } - -} -``` - -### `from` - -```js -x = [1, 2, 3] - -val = newChain.from(x)(foo, bar) - -val -// => [1, 2, 3] - -val.foo().bar() -// => [1, 2, 3] -``` - -![](https://dl.dropboxusercontent.com/s/swyw3663x22pnwy/npmel_15.jpg) diff --git a/.temp-unpublished-node_modules/new-chain/index.js b/.temp-unpublished-node_modules/new-chain/index.js deleted file mode 100644 index dc1b08b8d..000000000 --- a/.temp-unpublished-node_modules/new-chain/index.js +++ /dev/null @@ -1,55 +0,0 @@ -module.exports = newChain; -module.exports.from = from; - -function from(chain){ - - return function(){ - var m, i; - - m = methods.apply(undefined, arguments); - i = m.length; - - while ( i -- ) { - chain[ m[i].name ] = m[i].fn; - } - - m.forEach(function(method){ - chain[ method.name ] = function(){ - method.fn.apply(this, arguments); - return chain; - }; - }); - - return chain; - }; - -} - -function methods(){ - var all, el, i, len, result, key; - - all = Array.prototype.slice.call(arguments); - result = []; - i = all.length; - - while ( i -- ) { - el = all[i]; - - if ( typeof el == 'function' ) { - result.push({ name: el.name, fn: el }); - continue; - } - - if ( typeof el != 'object' ) continue; - - for ( key in el ) { - result.push({ name: key, fn: el[key] }); - } - } - - return result; -} - -function newChain(){ - return from({}).apply(undefined, arguments); -} diff --git a/.temp-unpublished-node_modules/new-chain/package.json b/.temp-unpublished-node_modules/new-chain/package.json deleted file mode 100644 index 936f69540..000000000 --- a/.temp-unpublished-node_modules/new-chain/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "new-chain", - "version": "0.0.1", - "description": "Create chaining APIs from functions", - "main": "index.js", - "repository": { - "url": "git@github.com:azer/new-chain.git", - "type": "git" - }, - "author": "Azer Koçulu ", - "license": "BSD" -} diff --git a/.temp-unpublished-node_modules/play-audio/.gitignore b/.temp-unpublished-node_modules/play-audio/.gitignore deleted file mode 100644 index 93f136199..000000000 --- a/.temp-unpublished-node_modules/play-audio/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -npm-debug.log diff --git a/.temp-unpublished-node_modules/play-audio/.npmignore b/.temp-unpublished-node_modules/play-audio/.npmignore deleted file mode 100644 index b8a988ec2..000000000 --- a/.temp-unpublished-node_modules/play-audio/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -test -test.js -example -examples -dist diff --git a/.temp-unpublished-node_modules/play-audio/README.md b/.temp-unpublished-node_modules/play-audio/README.md deleted file mode 100644 index 4c51de640..000000000 --- a/.temp-unpublished-node_modules/play-audio/README.md +++ /dev/null @@ -1,99 +0,0 @@ -## play-audio - -Lightweight Wrapper For HTML5 Audio API - -```js -play = require('play-audio') - -play('song.mp3').autoplay() -``` - -* Example 1: [Playing An Alert Sound](http://requirebin.com/?gist=6050020) -* Example 2: [Music player](http://requirebin.com/?gist=6049983) -* Example 3: [alert library](http://github.com/azer/alert) - -## Install - -```bash -$ npm install play-audio -``` - -## Browser Compatibility - -```js -play(['song.mp3', 'song.ogg']).play() -``` - -## Displaying Controls - -```js -parent = document.querySelector('.my-player') -play(['song.mp3', 'song.ogg'], parent).autoplay.controls() -``` - -## How to use without NPM? - -If your application isn't structured as a CommonJS package, you can download the distribution file; - -```bash -$ wget https://raw.github.com/azer/play-audio/master/dist/play-audio.js -``` - -And include it on your page: - -```html - - -``` - -## Changing Source After Initialization - -```js -p = play(['song.mp3', 'song.ogg']).autoplay() -p.src() -// => ['song.mp3', 'song.ogg'] - -p.src(['new.mp3', 'new.ogg']).play() -p.src() -// => ['new.mp3', 'new.ogg'] -``` - -## API - -Example: - -```js -play('foo.mp3').volume(0.3).controls().loop().on('ended', function(){ - console.log('End of the song reached') -}) -``` - -Reference: - -* play(uri, parentElement) -* .controls -* .currentTime -* .element -* .loop -* .muted -* .on(event, function) -* .pause -* .play -* .preload -* .src(url) -* .volume(number) - -## Events - -* abort -* durationchange -* ended -* error -* pause -* play -* progress -* timeupdate - -[See complete reference](http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#mediaevents) diff --git a/.temp-unpublished-node_modules/play-audio/index.js b/.temp-unpublished-node_modules/play-audio/index.js deleted file mode 100644 index 9f178d2fb..000000000 --- a/.temp-unpublished-node_modules/play-audio/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./lib/player'); diff --git a/.temp-unpublished-node_modules/play-audio/lib/mime.js b/.temp-unpublished-node_modules/play-audio/lib/mime.js deleted file mode 100644 index feb9d1c64..000000000 --- a/.temp-unpublished-node_modules/play-audio/lib/mime.js +++ /dev/null @@ -1,17 +0,0 @@ -var table = { - aif : "audio/x-aiff", - aiff : "audio/x-aiff", - wav : "audio/x-wav", - mp3 : 'audio/mpeg', - m3u : "audio/x-mpegurl", - mid : "audio/midi", - midi : "audio/midi", - m4a : 'audio/m4a', - ogg : 'audio/ogg' -}; - -module.exports = mimeOf; - -function mimeOf(url){ - return table[ url.split('.').slice(-1)[0] ]; -} diff --git a/.temp-unpublished-node_modules/play-audio/lib/player.js b/.temp-unpublished-node_modules/play-audio/lib/player.js deleted file mode 100644 index 86ac4e43c..000000000 --- a/.temp-unpublished-node_modules/play-audio/lib/player.js +++ /dev/null @@ -1,75 +0,0 @@ -var newChain = require('new-chain'), - src = require('./src'), - render = require('./render'); - -module.exports = play; - -function play(urls, dom){ - var el, chain, url; - - dom || ( dom = document.documentElement ); - el = render(); - dom.appendChild(el); - - chain = newChain({ - autoplay: bool('autoplay'), - controls: bool('controls'), - load: method('load'), - loop: bool('loop'), - muted: bool('muted'), - on: on, - pause: method('pause'), - play: method('play'), - preload: bool('preload') - }); - - chain.currentTime = attr('currentTime'); - chain.element = element; - chain.src = src.attr(el); - chain.volume = attr('volume'); - chain.remove = remove; - - chain.src(urls); - - return chain; - - function attr(name){ - return function(value){ - if ( arguments.length ) { - el[name] = value; - return chain; - } - - return el[name]; - }; - } - - function bool(name){ - return function(value){ - if (value === false) { - return el[name] = false; - } - - return el[name] = true; - }; - } - - function element(){ - return el; - } - - function on(event, callback){ - el.addEventListener(event, callback, false); - } - - function method(name){ - return function(){ - return el[name].apply(el, arguments); - }; - } - - function remove(){ - return el.parentNode.removeChild(el); - } - -} diff --git a/.temp-unpublished-node_modules/play-audio/lib/render.js b/.temp-unpublished-node_modules/play-audio/lib/render.js deleted file mode 100644 index 31c87499d..000000000 --- a/.temp-unpublished-node_modules/play-audio/lib/render.js +++ /dev/null @@ -1,8 +0,0 @@ -var domify = require('domify'), - templates = require("./templates"); - -module.exports = render; - -function render(src){ - return domify(templates['audio.html']); -} diff --git a/.temp-unpublished-node_modules/play-audio/lib/src.js b/.temp-unpublished-node_modules/play-audio/lib/src.js deleted file mode 100644 index 600af3367..000000000 --- a/.temp-unpublished-node_modules/play-audio/lib/src.js +++ /dev/null @@ -1,31 +0,0 @@ -var mimeOf = require("./mime"); - -module.exports = { - attr: attr, - pick: pick -}; - -function attr(el){ - var value; - - return function(urls){ - if (arguments.length) { - value = urls; - el.setAttribute('src', pick(el, value)); - } - - return value; - }; -} - -function pick(el, urls){ - if(!urls) return; - - if(typeof urls == 'string'){ - return urls; - } - - return urls.filter(function(url){ - return !!el.canPlayType(mimeOf(url)); - })[0]; -} diff --git a/.temp-unpublished-node_modules/play-audio/lib/templates.js b/.temp-unpublished-node_modules/play-audio/lib/templates.js deleted file mode 100644 index d0403dd13..000000000 --- a/.temp-unpublished-node_modules/play-audio/lib/templates.js +++ /dev/null @@ -1 +0,0 @@ -exports["audio.html"] = "" \ No newline at end of file diff --git a/.temp-unpublished-node_modules/play-audio/package.json b/.temp-unpublished-node_modules/play-audio/package.json deleted file mode 100644 index 6acba6045..000000000 --- a/.temp-unpublished-node_modules/play-audio/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "play-audio", - "version": "0.0.3", - "description": "HTML5 Audio Player", - "main": "index.js", - "dependencies": { - "new-chain": "./.temp-unpublished-node_modules/new-chain", - "domify": "~1.0.0" - }, - "repository": { - "url": "git@github.com:azer/play-audio.git", - "type": "git" - }, - "author": "Azer Koçulu ", - "license": "BSD" -} diff --git a/package.json b/package.json index 4f3876ab4..8be6afaf8 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "object-assign": "^4.0.1", "object-values": "^1.0.0", "object.map": "^0.2.0", - "play-audio": "./.temp-unpublished-node_modules/play-audio", "react": "^0.14.3", "react-addons-css-transition-group": "^0.14.3", "react-dnd": "^2.0.2", diff --git a/src/actions/ChatActionCreators.js b/src/actions/ChatActionCreators.js index b0bbe5868..252093b52 100644 --- a/src/actions/ChatActionCreators.js +++ b/src/actions/ChatActionCreators.js @@ -1,6 +1,5 @@ import escapeRegExp from 'escape-string-regexp'; import values from 'object-values'; -import audio from 'play-audio'; import { SEND_MESSAGE, RECEIVE_MESSAGE, LOG } from '../constants/actionTypes/chat'; import parseChatMarkup from '../utils/parseChatMarkup'; @@ -49,7 +48,7 @@ export function inputMessage(text) { let mentionSound; function playMentionSound() { if (!mentionSound) { - mentionSound = audio([ 'assets/audio/mention.opus', 'assets/audio/mention.mp3' ]); + mentionSound = new Audio('assets/audio/mention.mp3'); } mentionSound.play(); }