GithubHelp home page GithubHelp logo

player's Introduction

player player

A command line player, supports play mp3 both from url and local stream.

Now support Node.js v0.12.0 and io.js v2.0.0

Installation

$ npm install player

Player cli tool

$ [sudo] npm install player -g
$ player play demo.mp3 [anotherdemo.mp3 ... ]

Example

var Player = require('player');

// create player instance
var player = new Player('./xxx.mp3');

// play now and callback when playend
player.play(function(err, player){
  console.log('playend!');
});

// create a player instance from playlist
var player = new Player([
  __dirname + '/demo.mp3',
  __dirname + '/demo2.mp3',
  __dirname + '/demo.mp3',
  // play .mp3 file from a URL
  'http://mr4.douban.com/blablablabla/p1949332.mp3'
]);

// play again
player.play();

// play the next song, if any
player.next();

// add another song to playlist
player.add('http://someurl.com/anothersong.mp3');

// list songs in playlist
console.log(player.list)

// event: on playing
player.on('playing',function(item){
  console.log('im playing... src:' + item);
});

// event: on playend
player.on('playend',function(item){
  // return a playend item
  console.log('src:' + item + ' play done, switching to next one ...');
});

// event: on error
player.on('error', function(err){
  // when error occurs
  console.log(err);
});

// stop playing
player.stop();

Have a try

$ git clone https://github.com/turingou/player.git
$ cd player
$ npm install .
$ node ./examples/local.js
$ node ./examples/online.js
$ node ./examples/next.js

API

new Player(playList)

Init a new Player with provided playList

  • playList: String|Array[String]

player.add(song)

Add a song to current playlist

  • song: String|Object[src: String]

player.play()

Play right now

player.pause()

Pause or resume, if already paused

player.stop()

Stop playing, unpipe the source stream

player.next()

Switch to next song in the current playlist

player.on(eventName, callback)

  • eventName: Would be playing, playend or error
  • callback: The callback function

player.enable(options)

  • options: Can be 'stream' or 'shuffle'

Contributing

  • Fork this repo
  • Clone your repo
  • Install dependencies
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Open a pull request, and enjoy <3

MIT license

Copyright (c) 2014 turing <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


docor built upon love by docor v0.1.2

player's People

Contributors

djulien avatar ewnd9 avatar fraserxu avatar guo-yu avatar jacksontian avatar kevva avatar luoyetx avatar maxmellon avatar newyork-anthonyng avatar obsidianx avatar qivhou avatar therichu avatar willywos avatar y-gagar1n avatar yiting007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

player's Issues

Crackling sound

Hi,
I'm using this API on my RaspberryPi B+. The .mp3 file is playing but crackling really bad.
Any tips ?
Thx

[Enhancement] Add .wav file support

I don't know how easy this is, but if aplay and mplayer, for example, both support .wav files... shouldn't Node-Player support wav files as well as MP3, ogg, etc?

Note that node-musicmetadata does not currently support .wav files, but there is a ticket out for this and (hopefully) progress being made.
leetreveil/musicmetadata#104

Deprecated Carbon Component Manager For Hosting Audio Files

2016-09-02 13:29:58.707 node[23492:971230] 13:29:58.707 WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.

Warning output

I'm getting this output when the player module is included in my script.

2015-12-18 16:42:22.628 node[1539:46341] 16:42:22.627 WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.

The script

import Player from 'player';

var player = new Player(/* url.mp3 */);

npm version : 3.4.1
node version : 5.0.0

Finding a way to send sound to bluetooth headset

Hello,
First of all, I just want to say thank you for all your work on this package.
I'm using a customised version of your package to listen all my songs and sound from youtube videos on my raspberry.
I installed a bluetooth headset on my raspberry. I want to switch all playing song from my speakers to my bluetooth headset when I leave my main room.
My asound.conf
pcm.!default { type plug slave { pcm { type bluetooth device XX:XX:XX:XX:XX:XX profile "auto" } } hint { show on description "BT Headset" } }
It works with aplayer and mplayer.
But when i'm using player with nodejs, I get this error message :
bt_audio_service_open: connect() failed: Connection refused (111) [../deps/mpg123/src/output/alsa.c:165] error: cannot open device default node: pcm_params.c:2286: snd_pcm_hw_refine: Assertion pcm && params' failed.`

I think it's because the speaker module that you use is not made for bluetooth.

Do you know a bluetooth audio package like speaker ?
I want to share the music ReadStream to it.

Thank you
Rémi Bruyère

EventEmitter memory leak

var Player = require('player');
var start_player = new Player(__dirname + '/lib/gunshot.mp3');

setInterval(function(){
start_player.play();

},500)

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Player.addListener (events.js:160:15)
at Player.play (/Users/TaeYeongKIM/Development/coach-block/node_modules/player/libs/player.js:56:29)
at Object. (/Users/TaeYeongKIM/Development/coach-block/player_test.js:6:30)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

Unhandled error event

I cant seem to get the demo to work. Am using node on raspberry pi, I've set up the following code:

`var Player = require('player');
var pkg = require('../package.json');
var debug = require('debug')(pkg.name);

var player = new Player('http://stream.srg-ssr.ch/m/rsp/mp3_128', {
stream: true
});

player.play();

player.on('playing', function(song) {
debug('Playing... ');
debug(song);
});

player.on('error', function(err) {
debug('Opps...!')
debug(err);
});

Am getting the following error when trying to run node index.js

Error: ENOENT, open 'mp3_128'
at Error (native)

Any ideas on whats wrong?

Online demo don't work

/player/index.js:65
        if (err) throw err;
                       ^
Error: resource invalid
    at ClientRequest.<anonymous> (/player/index.js:119:36)
    at ClientRequest.g (events.js:180:16)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at Socket.socketOnData [as ondata] (http.js:1583:20)
    at TCP.onread (net.js:525:27)

depends on Speaker - which is not compatible with node 0.12 (?)

..\src\binding.cc(131): error C2661: 'v8::Object::Set' : no overloaded function takes 3 arguments

gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Anonymous\nodeBundle\node_modules\player\node_modules\speaker
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

CLI Allow specifying of the path rather than assuming current directory

If I pass the full path, it complains since the current directory is automatically tacked on. Only works if i specify a path relative to the current directory.

#doesn't work but should:
$ player play ~/.local/share/sounds/CRASH_6.mp3 

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: ENOENT, open '/home/yuvilio/home/yuvilio/.local/share/sounds/CRASH_6.mp3'
#works but too restricting: 
$ player play .local/share/sounds/CRASH_6.mp3 
$ 

Can we specify the path either way and the script will just use that?

My workaround is to wrap it in a subprocess using $(...) and change directory temporarily to the root so that my directory in my main process isn't changed:

$ echo $BEEPMP3 
/home/yuvilio/.local/share/sounds/CRASH_6.mp3
$ pwd
/home/yuvilio/.local/share
$ $(cd /; player play $BEEPMP3)
$ 

Illegal instruction: 4

Hi, thanks for the cool library.
I tried to pause an audio and got the error in console
Illegal instruction: 4

a part of my source code

        if (url.pathname === '/play') {
            if (currentPlayer) {
                currentPlayer.stop();
            }
            currentPlayer = new Player(data);
            currentPlayer.play();
            currentPlayer.on('error', function(err){
                // when error occurs
                console.log(err);
            });

        }
        else if (url.pathname === '/pause') {
            if (currentPlayer) {
                currentPlayer.pause();
            }
        }
        else if (url.pathname === '/stop') {
            if (currentPlayer) {
                currentPlayer.stop();
            }
        }

Same goes for .stop()

How can I prevent the error?

node: v5.10.1
os: mac os 10.12.4

When node version is 6.0.0 or later, fail to build.

I installed this module when node version is 6.2.0 and node-gyp version 3.3.1.
Then failed to install this module.

As a test, I use node of 5.8.0. then succeed to install this module .

  • Reference
  LIBTOOL-STATIC Release/libmpg123.a
  CC(target) Release/obj.target/lamevectorroutines/deps/lame/libmp3lame/vector/xmm_quantize_sub.o
  LIBTOOL-STATIC Release/liblamevectorroutines.a
  CXX(target) Release/obj.target/bindings/src/bindings.o
In file included from ../src/bindings.cc:19:
../node_modules/nan/nan.h:590:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:596:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback) {
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:601:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:607:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback) {
      ~~~~~~~~~~~~~^
4 errors generated.
make: *** [Release/obj.target/bindings/src/bindings.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/maxmellon/.nvm/versions/node/v6.2.0/lib/node_modules/npm/n
ode_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/Users/maxmellon/.nvm/versions/node/v6.2.0/bin/node" "/Users/maxmellon/.nvm/versions/node/
v6.2.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/maxmellon/work/js/LEMP/node_modules/lame
gyp ERR! node -v v6.2.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 

install fails

here is the result. I'm running Ubuntu 14.04.

~/test  npm install player

> [email protected] install /home/vaju/test/node_modules/speaker
> node-gyp rebuild

make: Entering directory `/home/vaju/test/node_modules/speaker/build'
  CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory
 #include <alsa/asoundlib.h>
                            ^
compilation terminated.
make: *** [Release/obj.target/output/deps/mpg123/src/output/alsa.o] Error 1
make: Leaving directory `/home/vaju/test/node_modules/speaker/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:100:13)
gyp ERR! stack     at ChildProcess.emit (events.js:185:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:204:12)
gyp ERR! System Linux 4.2.0-35-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/vaju/test/node_modules/speaker
gyp ERR! node -v v5.10.1
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/home/vaju/test/package.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README data
npm WARN test No license field.
npm ERR! Linux 4.2.0-35-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "player"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the speaker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs speaker
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls speaker
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vaju/test/npm-debug.log
➜  ~/test  

0.11.x support

Hi

Lame doesn't support node-v0.11.x, so player can't work for 0.11.x. Is there any good idea to solve this?Any other packages to replace lame? I'm developing a app using your player but maybe I have to use node-v0.11 ...

卡在require('player')这一行

`var Player = require('player');

// create player instance
var player = new Player('./someMusic.mp3');

// play now and callback when playend
player.play(function(err, player){
console.log('playend!');
});`
代码非常简单,第一行一直在执行。安装没报错,运行也没有任何信息。
node版本8.5.0
windows10

两次 next() 后无法再继续下一首

OS X 环境,player.list 中有足够的歌曲,play() 后调用 next() 方法,第一次没问题,第二次后 player.status 变成了 stopped,所以无法继续 next()

BTW, 我用你的 player 在写一个跟 douban.fm 项目类似的项目,十分感谢你,辛苦了!

node 4 support not released to npm

thank you so much for the node 4 support fix. could you please release it to npm. the latest version is still 0.5.0 which has no node 4 support :(

How can we implement crossfade?

Do we have an option to control loudness of music to create crossfade effect or is there any integrated crossfade option?

protocol http not supported

I get the following error when trying to run the online example from a cloned repo (with command node examples/online.js ):

https.js:101
throw new Error('Protocol:' + options.protocol + ' not supported.');
^
Error: Protocol:http: not supported.
at Object.exports.request (https.js:101:11)
at Object.exports.get (https.js:127:21)
at Player.download (/Users/Scott/Code/player/libs/player.js:118:43)
at Player.read (/Users/Scott/Code/player/libs/player.js:167:8)
at play (/Users/Scott/Code/player/libs/player.js:66:10)
at iterate (/Users/Scott/Code/player/node_modules/async/lib/async.js:142:13)
at Object.async.eachSeries (/Users/Scott/Code/player/node_modules/async/lib/async.js:158:9)
at Player.play (/Users/Scott/Code/player/libs/player.js:60:9)
at Object. (/Users/Scott/Code/player/examples/online.js:8:8)
at Module._compile (module.js:456:26)

Any idea why?

Pause function

Is it supported? If no, is it actual? (I didn't found any related issues).

npm安装依赖失败报错怎么解决?

`C:\Users\Cooper\Desktop\pp
λ npm i player

[email protected] install C:\Users\Cooper\node_modules\lame
node-gyp rebuild

C:\Users\Cooper\node_modules\lame>if not defined npm_config_node_gyp (node "C:\Users\Cooper\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "C:\Users\Cooper\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (C:\Users\Cooper\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack at PythonFinder. (C:\Users\Cooper\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at C:\Users\Cooper\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:170:21)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\Cooper\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Cooper\node_modules\lame
gyp ERR! node -v v9.7.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Cooper\package.json'
npm WARN Cooper No description
npm WARN Cooper No repository field.
npm WARN Cooper No README data
npm WARN Cooper No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Cooper\AppData\Roaming\npm-cache_logs\2018-04-07T17_21_13_669Z-debug.log`

Can't install

I think is something related with speaker dependency
I'm trying to install with:

npm install player

But I get:

> [email protected] install /home/canda/node_modules/player/node_modules/speaker
> node-gyp rebuild

make: Entering directory `/home/canda/node_modules/player/node_modules/speaker/build'
  CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory
 #include <alsa/asoundlib.h>
                            ^
compilation terminated.
make: *** [Release/obj.target/output/deps/mpg123/src/output/alsa.o] Error 1
make: Leaving directory `/home/canda/node_modules/player/node_modules/speaker/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.13.0-46-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/canda/node_modules/player/node_modules/speaker
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok 

Play Next Song

When I try to play the next song(player.next();),only the first seconds are played

Playback stops when window loses focus (electron / atom-shell)

When using the default implementation:

var player = new Player(MUSIC_DIR + currentSong);

player.play(function(err, player){
  if (err) throw (err);
  console.log('playend!');
});

the file plays fine when window is in focus, but when focus is lost, playback stops after a few seconds.

Playback resumes immediately when the window is back in focus, or when I switch between apps.

No errors are being thrown

next() keeps playing the second track

Hi,

On my system, no matter the current play list, next() keeps playing the second track. The issue is also present in the next.js example.

I'm on OS X 10.9.2, node v0.10.33.

Thanks.

默认不下载音乐

Hi, @turingou .

我最近封装了网易云音乐的api, 然后做了个简单的播放器. 播放音乐部分用到了这个player模块. 但是我发现使用它播放时, 会默认将歌曲下载到本地(用户根目录或者指定参数)

this.downloads = params && params.downloads ? params.downloads : utils.getUserHome();

但是我并不希望每次播放时都默认去下载, 毕竟不是所有歌曲都是免费而且没有版权的.

能否加入一个参数, 默认不下载, 只有在参数里传了download之后才下载?

另外, 这个模块真的很好用, 赞一个!! 👍

Playing stream without extension

Playing streams ending in .mp3 seems to be no problem, but is there any chance it can play streams like http://live.nsbradio.co.uk:8904/ too? As far as I can figure out that's the correct stream (even though it shows a page when browsing to it). The content type is audio/mpeg, but without the extension I get an error like

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: EISDIR: illegal operation on a directory, read
    at Error (native)

Cutting off the ending slash (/) produces

{ [Error: Parse Error] bytesParsed: 0, code: 'HPE_INVALID_CONSTANT' }

播放.m4a后缀url出错

我在本地尝试使用player播放格式为" http://cc.cdn.jing.fm/201308031031/63f81a99de31ab3766705482b370b403/2012/0713/06/hv/2012071306hvw.m4a " 的url时出现如下错误:

[../deps/mpg123/src/libmpg123/parse.c:1078] error: Giving up searching valid MPEG header after 65536 bytes of junk.
[../deps/mpg123/src/libmpg123/parse.c:1078] error: Giving up searching valid MPEG header after 65536 bytes of junk.
[../deps/mpg123/src/libmpg123/parse.c:1078] error: Giving up searching valid MPEG header after 65536 bytes of junk.

测试mp3格式没有问题。请问有办法支持.m4a格式么?

Error with basic example, the file sounds but then fail

I have got his code:

var Player = require('player');

var player = new Player(__dirname + '/public/aran_voice_1.mp3');

player.play(function(err, player){
  console.log('playend!');
});

player.play();

Error messages:

events.js:87
      throw Error('Uncaught, unspecified "error" event.');
            ^
Error: Uncaught, unspecified "error" event.
    at Error (native)
    at Player.emit (events.js:87:13)
    at Player.next ([MY_FOLDER]/node_modules/player/dist/player.js:281:14)
    at Decoder.<anonymous> ([MY_FOLDER]/node_modules/player/dist/player.js:172:25)
    at Decoder.g (events.js:199:16)
    at Decoder.emit (events.js:129:20)
    at finishMaybe ([MY_FOLDER]/node_modules/player/node_modules/lame/node_modules/readable-stream/lib/_stream_writable.js:371:12)
    at afterWrite ([MY_FOLDER]/node_modules/player/node_modules/lame/node_modules/readable-stream/lib/_stream_writable.js:291:5)
    at onwrite ([MY_FOLDER]/node_modules/player/node_modules/lame/node_modules/readable-stream/lib/_stream_writable.js:281:7)
    at WritableState.onwrite ([MY_FOLDER]/node_modules/player/node_modules/lame/node_modules/readable-stream/lib/_stream_writable.js:106:5)

I am working in a rapsberry B+. I have to install "speaker" using npm and libasound2-dev.

node v0.12 无法安装 player

单独安装 speaker是可以的。
报错如下:

../src/bindings.cc:29:15: error: calling a protected constructor of class
      'v8::HandleScope'
  HandleScope scope;
              ^
/usr/local/lib/node_modules/player/node_modules/lame/.node-gyp/0.12.0/deps/v8/include/v8.h:816:13: note: 
      declared protected here
  V8_INLINE HandleScope() {}
            ^
1 error generated.
make: *** [Release/obj.target/bindings/src/bindings.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Darwin 14.1.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/player/node_modules/lame
gyp ERR! node -v v0.12.0
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 
npm info [email protected] Failed to exec install script
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "player" "-g" "-d"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the speaker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls speaker
npm ERR! There is likely additional logging output above.
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info postuninstall [email protected]

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/Hbomb/npm-debug.log

Support for http/https redirects

I'm trying to access an audio stream past a redirect, but I've come to notice 302's aren't supported by this library. I hacked a quick fix by editing the dist/player directly replacing require(https) with require('follow-redirects').https. follow-redirects is a drop-in replacement for http/https with support for redirects.

I'm not too familiar with the ES6 syntax for imports, so I didn't fork/PR, but I'd suggest using follow-redirects. In theory, it's a 3 liner! (one line to add the dependency in package-json, two lines for http/https).

Cannot Install using "npm install player"

I am trying to install this package on my system but I am getting issues

npm ERR! Linux 4.4.0-41-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "player"
npm ERR! node v4.5.0
npm ERR! npm  v2.15.9
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the speaker package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs speaker
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls speaker
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/nomo/workspace/node-js-getting-started/npm-debug.log

my node version is -

v4.5.0

Playback stops before end

Playback stops before end of the mp3 file (less than one second), on Archlinux 3.12.21-1-ARCH, either with local or remote file

Cannot play a stream

Here is my sample code. Playing the demo.mp3 works fine, but what I'm trying to accomplish is playing a music stream, which unfortunately it fails to do. Any hints?

var Player = require('player');

var player = new Player('http://stream.srg-ssr.ch/m/rsp/mp3_128');
//var player = new Player('http://node-player.qiniudn.com/demo.mp3');

player.play(function(err, player){
        console.log("playend");
});

Error on examples.

I'm on Mac OS 10.9.2 I am getting the following error with you module.

> npm install 
> node examples/online.js
util.js:538
  ctor.prototype = Object.create(superCtor.prototype, {
                                          ^
TypeError: Cannot read property 'prototype' of undefined
    at Object.exports.inherits (util.js:538:43)
    at Object.<anonymous> (player/node_modules/pool_stream/lib/pool.js:33:6)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (player/node_modules/pool_stream/index.js:1:80)
    at Module._compile (module.js:449:26)

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.