obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
657 stars 95 forks source link

Send videofile to source TypeError: obs.send is not a function #345

Open regisroots opened 7 months ago

regisroots commented 7 months ago

How to send an .mp4 file to the source, obs.send no longer works, it gives me an error, below is my code.

const { default: OBSWebSocket } = require('obs-websocket-js');

const obs = new OBSWebSocket();

// Forneça a URL corretamente como uma string obs.connect("ws://localhost:4455", "JWycd0W8eqxyOyYx") .then(() => { console.log("Conectado ao OBS Studio via WebSocket (sem autenticação)");

const sourceName = "NomeDoSeuSource";

const videoFilePath = "caminho/para/video.mp4";

const sourceSettings = {
  file: videoFilePath,
};

obs.send("SetSourceSettings", {
  sourceName: sourceName,
  sourceSettings: sourceSettings,
}).then(() => {
  console.log(`Arquivo de vídeo ${videoFilePath} configurado com sucesso para o source ${sourceName}`);
}).catch((error) => {
  console.error(`Erro ao configurar o arquivo de vídeo para o source ${sourceName}:`, error);
});

}) .catch((error) => { console.error("Erro ao conectar ao OBS Studio:", error); });

error TypeError: obs.send is not a function

thasneem077 commented 3 months ago

did you resolve this?