Skip to content

How to use the getVolume function #92

Description

@simonravel

I tried to use this function:

const GoogleCastClient = require("castv2-client").Client;
const DefaultMediaReceiver = require("castv2-client").DefaultMediaReceiver;
const client = new GoogleCastClient();
var 'some_ip' = '192.168.0.x' //just an example

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

          player.load(media, { autoplay: true }, (err, status) => {
              client.close();
              console.log(`Pushed to device at ${some_ip}`);
            });
      });

   client.getVolume('volume', function(vol){
          console.log(vol)
   })
    
   client.on("error", err => {
        reject(`Google Cast Client error:\n${err}`);
        client.close();
      });

});

Which results in: UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'getVolume' of null

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions