Skip to content

Commit

Permalink
Rolmback volume for Google cast after notification finished
Browse files Browse the repository at this point in the history
  • Loading branch information
bertrandda committed Dec 12, 2024
1 parent af3be46 commit 943b72e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/services/google-cast/lib/google_cast.setValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ async function setValue(device, deviceFeature, value, options) {

client.connect(ipAddress, async () => {
logger.debug('Google Cast Connected, launching app ...');
const getVolume = promisify(client.getVolume.bind(client));
const setVolume = promisify(client.setVolume.bind(client));

Check warning on line 28 in server/services/google-cast/lib/google_cast.setValue.js

View check run for this annotation

Codecov / codecov/patch

server/services/google-cast/lib/google_cast.setValue.js#L28

Added line #L28 was not covered by tests

const { level } = await getVolume();

Check warning on line 30 in server/services/google-cast/lib/google_cast.setValue.js

View check run for this annotation

Codecov / codecov/patch

server/services/google-cast/lib/google_cast.setValue.js#L30

Added line #L30 was not covered by tests

if (options.volume) {
await setVolume({ level: options.volume / 100 });

Check warning on line 33 in server/services/google-cast/lib/google_cast.setValue.js

View check run for this annotation

Codecov / codecov/patch

server/services/google-cast/lib/google_cast.setValue.js#L32-L33

Added lines #L32 - L33 were not covered by tests
}
Expand All @@ -46,8 +49,12 @@ async function setValue(device, deviceFeature, value, options) {
},
};

player.on('status', (status) => {
player.on('status', async (status) => {

Check warning on line 52 in server/services/google-cast/lib/google_cast.setValue.js

View check run for this annotation

Codecov / codecov/patch

server/services/google-cast/lib/google_cast.setValue.js#L52

Added line #L52 was not covered by tests
logger.debug('status broadcast playerState=%s', status.playerState);

if (status.idleReason === 'FINISHED') {
await setVolume({ level });

Check warning on line 56 in server/services/google-cast/lib/google_cast.setValue.js

View check run for this annotation

Codecov / codecov/patch

server/services/google-cast/lib/google_cast.setValue.js#L55-L56

Added lines #L55 - L56 were not covered by tests
}
});

logger.debug('app "%s" launched, loading media %s ...', player.session.displayName, media.contentId);
Expand Down

0 comments on commit 943b72e

Please sign in to comment.