AVATAR Forum
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

plugin VlcPlayer

Aller en bas

plugin VlcPlayer Empty plugin VlcPlayer

Message par halim Jeu 4 Avr - 10:42

plugin vlcplayer pour regarder les chaines télé(fichiers m3u) sur le pc, je l'ai développer de plusieurs facon ,mais ne seras pas sur mon github, je vais remplacer le lecteur vlc par regarder la télé dans une fenetre pop up, je pense c'est mieux que de télécharger des lecteurs comme vlc, kodi, plex ou autre(donc aucune configuration), comme ca l'appli AVATAR ca seras sur un écran intélligent comme amazon alexa, aprés peut etre rajouter du htlm et css au plugin comme plugin blague que ca affiche sur l'écran le text de la blague ou plugin météo ca affiche l'icone méteo température nom de la ville, ect...voila
exports.action = function(data, callback){

let tblCommand = {
playVlc : function() {playVlc (data.client);},
stopVlc : function() {stopVlc (data, client);},
pauseVlc : function() {controls ("pauseVlc", data, client);},
lectureVlc : function() {controls ("lectureVlc", data, client);},
pleinEcranVlc : function() {controls ("pleinEcranVlc", data, client);},
inverseEcranvlc : function() {controls ("inverseEcranVlc", data, client);},
avanceVlc : function() {controls ("avanceVlc", data, client);},
reculeVlc : function() {controls ("reculeVlc", data, client);},
volumeUpVlc : function() {controls ("vlcVolumeDown", data, client);},
volumeDownVlc : function() {controls ("vlcVolumeDown", data, client);},
};

let client = setClient(data);
info("VlcPlayer:", data.action.command, "From:", data.client, "To:", client);
tblCommand[data.action.command]();
callback();

}

function playVlc(data, client) {

const fs = require('fs');
const path = require('path');

   const nameChannelTv = data.action.sentence.toLowerCase().replace("mets", "").replace("la chaîne sur", "").trim();

   if (!nameChannelTv) {
       Avatar.speak(`Mot-clé non trouvé. Veuillez recommencer.`, data.client, () => {
           Avatar.Speech.end(data.client);
       });
       return;
   }
     
       const channelFilePath = path.join(__dirname, 'TvFrance', `${nameChannelTv}.m3u`);
       
       if (fs.existsSync(channelFilePath)) {
           Avatar.speak(`Je mets ${nameChannelTv}`, data.client, () => {
               Avatar.runApp(`${__dirname}/nircmd/nircmdc64.exe killprocess vlc.exe`, null, data.client);
               setTimeout(() => {
                   Avatar.runApp(`C:/Progra~1/VideoLAN/VLC/vlc.exe ${channelFilePath}`, null, data.client, () => {
                       Avatar.Speech.end(data.client);
                   });
               }, 2000);
           });
           return;
       } else {
           Avatar.speak(`La chaîne ${nameChannelTv} n'a pas été trouvée.`, data.client, () => {
               Avatar.Speech.end(data.client);
           });
           return;
       }

}


function stopVlc (data, client) {

Avatar.runApp(`${__dirname}/nircmd/nircmdc64.exe killprocess vlc.exe`, null, data.client, function(){
Avatar.speak("J'ai éteins la télé|J'ai arrété la télé", data.client, () => {
Avatar.Speech.end(data.client, true, () => {
});
 });
});

}

function controls(commandVlc, data, client) {
   const dirname = `${__dirname}/nircmd/nircmdc64.exe sendkeypress`;
   let keyCombination;

   switch (commandVlc) {
       case "pauseVlc":
       case "lectureVlc":
           keyCombination = "Éspace";
           break;
       case "pleinEcranVlc":
           keyCombination = "f";
           break;
       case "inverseEcranVlc":
           keyCombination = "Échape";
           break;
       case "avanceVlc":
           keyCombination = "Ctrl+Right";
           break;
       case "reculeVlc":
           keyCombination = "Ctrl+Left";
           break;
       case "volumeUp":
           keyCombination = "Ctrl+Up";
           break;
       case "volumeDown":
           keyCombination = "Ctrl+Down";
           break;
       default:
           Avatar.speak("Commande non reconnue.", data.client, () => {
               Avatar.Speech.end(data.client);
           });
           return;
   }

   Avatar.runApp(`${dirname} ${keyCombination}`, null, 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
halim

Messages : 89
Date d'inscription : 19/11/2022

Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum