From 817dcbd3ccb787aa6e4c8672bbefe33a7a4d7eb8 Mon Sep 17 00:00:00 2001 From: nklhrstv Date: Mon, 18 May 2020 14:17:52 +0300 Subject: [PATCH] volume/mute handled in chromecast transport --- .../Chromecast/ChromecastTransport.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/services/Chromecast/ChromecastTransport.js b/src/services/Chromecast/ChromecastTransport.js index 4b19196fb..b990699e1 100644 --- a/src/services/Chromecast/ChromecastTransport.js +++ b/src/services/Chromecast/ChromecastTransport.js @@ -209,6 +209,28 @@ function ChromecastTransport() { cast.framework.CastContext.getInstance().endCurrentSession(action.stopCasting); return; } + case 'setVolume': { + const castSession = cast.framework.CastContext.getInstance().getCurrentSession(); + if (castSession) { + castSession.setVolume(MESSAGE_NAMESPACE, action.volume) + .catch((code) => { + onCastError(code); + }); + } + + return; + } + case 'setMute': { + const castSession = cast.framework.CastContext.getInstance().getCurrentSession(); + if (castSession) { + castSession.setMute(MESSAGE_NAMESPACE, action.muted) + .catch((code) => { + onCastError(code); + }); + } + + return; + } case 'message': { const castSession = cast.framework.CastContext.getInstance().getCurrentSession(); if (castSession) { @@ -234,6 +256,22 @@ function ChromecastTransport() { return session.getCastDevice(); } + return null; + }; + this.getVolume = function() { + const session = cast.framework.CastContext.getInstance().getCurrentSession(); + if (session !== null) { + return session.getVolume(); + } + + return null; + }; + this.isMute = function() { + const session = cast.framework.CastContext.getInstance().getCurrentSession(); + if (session !== null) { + return session.isMute(); + } + return null; }; }