kuro-kuroite / mini-google-home-notifier

google-home-notifier で必要な部分のみを Promise でデコレートしたミニライブラリ
0 stars 0 forks source link

Volume Control #2

Open Jack-Drake opened 5 years ago

Jack-Drake commented 5 years ago

How do I raise and lower the volume in the options?

kuro-kuroite commented 5 years ago

according to this issue, devise like Google Home volume control function has node-castv2-client library.

if you want to set volume, you put setVolume method in client.connect() callback please see https://gist.github.com/guerrerocarlos/552cdb38cbd8d153260e#file-castv2-client-test1-js-L56

This is an additional information, I annex the setVolume definition place

sample code (maybe well)

import {
  Client as GoogleCastClient,
  DefaultMediaReceiver,
} from 'castv2-client';

const ip = '192.168.10.55';  // change this

const client = new GoogleCastClient();
client.connect(
  ip,
  () => {
    client.launch(DefaultMediaReceiver, (err, player) => {
      const media = {
        contentId: url,
        contentType: 'audio/mp3',
        streamType: 'BUFFERED',
      };

      setTimeout(() => {
        client.setvolume(0.5, (err, newVolume) => {
          if(err) {
            console.log("there was an error.");
            client.close();
            return;
          }
          console.log(`volume changed to ${newVolume}`);
        })
        client.close();
      }
      , 10000);
    });
  },
);

Thank you to understand my poor English m( )m

kuro-kuroite commented 5 years ago

In my opinion, you fork this or you use patch-package library and modify this part

kuro-kuroite commented 5 years ago

google tts has no volume option please see https://github.com/zlargon/google-tts/issues/18