plugin Radio
Page 1 sur 1
plugin Radio
nouveau plugin radio; le plugin est optimiser et presque niveau supérieur, (on m'a un peu aider a le développer)
- si une radio est en écoute en cours actuelle et si vous voulez lancer une nouvelle radio, AVATAR stop la radio en cours ensuite lance la nouvelle radio ; le plugin seras bientot dispo sur mon github, d'autre nouveaux plugins serons bientot fini : allociné, calcul, conjugaison, traduction, pushover(notifications ) et d'autre encore(philips hue, domoticz, withings;
j'ai ajouter une petite fonction d'une radio "france info" , pour un scenario le matin avec le plaugin scenariz de stephane bascher dans la ou les piéces de votre choix(cuisine, chambre, salle de bains), aprés a modier a vos besoins.
exports.action = function(data, callback){
let tblCommand = {
radio : function() {
stationRadios (data, client);
},
franceInfo : function() {
franceInfo (data, client);
},
stopRadio : function() {
stopRadio (data, client);
}
};
let client = setClient(data);
info("Radio:", data.action.command, "From:", data.client, "To:", client);
tblCommand[data.action.command]();
callback();
}
function stationRadios(data, client) {
let radioName = data.action.rawSentence.toLowerCase().replace(/mets|je|veux|écouter|la|radio|sur/gi, "").trim();
if (radioName) {
const Stations = Config.modules['Radio'].radios;
if (Stations.hasOwnProperty(radioName.toLowerCase())) {
Avatar.speak(`Je mets radio ${radioName.toLowerCase()}`, data.client, () => {
Avatar.stop(null, data.client);
setTimeout(() => {
Avatar.Speech.end(data.client, true, () => {
Avatar.play(`%URL%${Stations[radioName]}`, data.client);
});
}, 2000);
});
} else {
Avatar.speak(`La radio "${radioName}" n'est pas disponible.`, data.client, () => {
Avatar.Speech.end(data.client);
});
}
} else {
Avatar.speak(`Je ne peux pas mettre la radio sans le nom de la radio.`, data.client, () => {
Avatar.Speech.end(data.client);
});
}
}
function franceInfo (data, client) {
Avatar.play(`%URL%${'http://icecast.radiofrance.fr/franceinfo-hifi.aac'}`, data.client);
}
function stopRadio(data, client) {
Avatar.stop(null, data.client);
Avatar.speak("A bientôt sur radio france", data.client, () => {
Avatar.Speech.end(data.client);
});
}
function setClient(data){
let client = data.client;
if (data.action.room)
client = (data.action.room != 'current') ? data.action.room : (Avatar.currentRoom) ? Avatar.currentRoom : Config.default.client;
if (data.action.setRoom)
client = data.action.setRoom;
return client;
}
- si une radio est en écoute en cours actuelle et si vous voulez lancer une nouvelle radio, AVATAR stop la radio en cours ensuite lance la nouvelle radio ; le plugin seras bientot dispo sur mon github, d'autre nouveaux plugins serons bientot fini : allociné, calcul, conjugaison, traduction, pushover(notifications ) et d'autre encore(philips hue, domoticz, withings;
j'ai ajouter une petite fonction d'une radio "france info" , pour un scenario le matin avec le plaugin scenariz de stephane bascher dans la ou les piéces de votre choix(cuisine, chambre, salle de bains), aprés a modier a vos besoins.
exports.action = function(data, callback){
let tblCommand = {
radio : function() {
stationRadios (data, client);
},
franceInfo : function() {
franceInfo (data, client);
},
stopRadio : function() {
stopRadio (data, client);
}
};
let client = setClient(data);
info("Radio:", data.action.command, "From:", data.client, "To:", client);
tblCommand[data.action.command]();
callback();
}
function stationRadios(data, client) {
let radioName = data.action.rawSentence.toLowerCase().replace(/mets|je|veux|écouter|la|radio|sur/gi, "").trim();
if (radioName) {
const Stations = Config.modules['Radio'].radios;
if (Stations.hasOwnProperty(radioName.toLowerCase())) {
Avatar.speak(`Je mets radio ${radioName.toLowerCase()}`, data.client, () => {
Avatar.stop(null, data.client);
setTimeout(() => {
Avatar.Speech.end(data.client, true, () => {
Avatar.play(`%URL%${Stations[radioName]}`, data.client);
});
}, 2000);
});
} else {
Avatar.speak(`La radio "${radioName}" n'est pas disponible.`, data.client, () => {
Avatar.Speech.end(data.client);
});
}
} else {
Avatar.speak(`Je ne peux pas mettre la radio sans le nom de la radio.`, data.client, () => {
Avatar.Speech.end(data.client);
});
}
}
function franceInfo (data, client) {
Avatar.play(`%URL%${'http://icecast.radiofrance.fr/franceinfo-hifi.aac'}`, data.client);
}
function stopRadio(data, client) {
Avatar.stop(null, data.client);
Avatar.speak("A bientôt sur radio france", data.client, () => {
Avatar.Speech.end(data.client);
});
}
function setClient(data){
let client = data.client;
if (data.action.room)
client = (data.action.room != 'current') ? data.action.room : (Avatar.currentRoom) ? Avatar.currentRoom : Config.default.client;
if (data.action.setRoom)
client = data.action.setRoom;
return client;
}
halim- Messages : 89
Date d'inscription : 19/11/2022
Sujets similaires
» Radio en cuisine
» Plugin JoyeuxAnniverssaire
» Plugin tvSchedule
» Installation Plugin
» plugin pushover
» Plugin JoyeuxAnniverssaire
» Plugin tvSchedule
» Installation Plugin
» plugin pushover
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|