volume/mute handled in chromecast transport

This commit is contained in:
nklhrstv 2020-05-18 14:17:52 +03:00
parent d770b5572a
commit 817dcbd3cc

View file

@ -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;
};
}