tessel / tessel-av

USB Camera, Microphone, MP3 Player and Text Speaker support for Tessel 2.
38 stars 9 forks source link

av.Player constructor lock the program #28

Open eledwinn opened 4 years ago

eledwinn commented 4 years ago

Hi, i have problems when try play mp3 from my tessel 2.

When i run next code, this is blocked when av.Player() is called.

'use strict';
const path = require('path');
const av = require('tessel-av');
const mp3 = path.join(__dirname, '20-second-nonsense.mp3');
console.log('one'); // this is showed in console
const sound = new av.Player(mp3);
console.log('two'); // this never show in console
sound.play();

sound.on('timeupdate', function(seconds) {
  seconds = Math.round(seconds);

  if (seconds === 2) {
    this.pause();
  }

  if (seconds > 12) {
    this.stop().play();
  }
});

sound.on('pause', function() {
  setTimeout(() => this.play(10), 1000);
});

My environment info:

(base) MacBook-Pro:audio edwingomez$ t2 version
INFO Looking for your Tessel...
INFO Connected to Tessel-02A37EC93AD1.
INFO Tessel Environment Versions:
INFO t2-cli: 0.1.23
INFO t2-firmware: 0.2.0
INFO Node.js: 8.11.3

(base) MacBook-Pro:audio edwingomez$ node -v
v10.16.0

My package.json

{
  "name": "audio",
  "version": "0.0.0",
  "description": "Tessel project",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": "www.github.com/tessel/t2-cli",
  "keywords": [
    "Tessel"
  ],
  "license": "MIT",
  "readme": "A bare bones Tessel 2 blinky script.",
  "dependencies": {
    "tessel-av": "^0.19.0"
  }
}
HipsterBrown commented 4 years ago

Hi @eledwinn, do you have a .tesselinclude file in your project directory to include your mp3 file in the files pushed to your Tessel? https://tessel.gitbooks.io/t2-docs/content/API/CLI.html#project-files

eledwinn commented 4 years ago

Hi @HipsterBrown, yes, i'm using .tesselinclude such as show CLI documentation. I'm pushed my code to github for illustrate. https://github.com/eledwinn/tessel-tests/tree/master/audio

I tried creating the new Player() instance without parameters, but it also lock there.