亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未捕獲(承諾)TypeError:無法讀取 HTMLButtonElement

未捕獲(承諾)TypeError:無法讀取 HTMLButtonElement

夢里花落0921 2023-03-24 13:37:56
我按照 firespace 的教程進行操作,這是一個電子教程,我得到了這個按摩,說這是一個錯誤,即使教程沒有未捕獲(承諾)TypeError:無法讀取 HTMLButtonElement.getVideoSources 處未定義的屬性“buildFromTemplate”const { writeFile } = require("fs");const dialog = remote;const Menu = remote;// Global statelet mediaRecorder; // MediaRecorder instance to capture footageconst recordedChunks = [];// Buttonsconst videoElement = document.querySelector("video");const startBtn = document.getElementById("startBtn");startBtn.onclick = (e) => {  mediaRecorder.start();  startBtn.classList.add("is-danger");  startBtn.innerText = "Recording";};const stopBtn = document.getElementById("stopBtn");stopBtn.onclick = (e) => {  mediaRecorder.stop();  startBtn.classList.remove("is-danger");  startBtn.innerText = "Start";};const videoSelectBtn = document.getElementById("videoSelectBtn");videoSelectBtn.onclick = getVideoSources;// Get the available video sourcesasync function getVideoSources() {  const inputSources = await desktopCapturer.getSources({    types: ["window", "screen"],  });  const videoOptionsMenu = Menu.buildFromTemplate(    inputSources.map((source) => {      return {        label: source.name,        click: () => selectSource(source),      };    })  );  videoOptionsMenu.popup();}// Change the videoSource window to recordasync function selectSource(source) {  videoSelectBtn.innerText = source.name;  const constraints = {    audio: false,    video: {      mandatory: {        chromeMediaSource: "desktop",        chromeMediaSourceId: source.id,      },    },  };  // Create a Stream  const stream = await navigator.mediaDevices.getUserMedia(constraints);  // Preview the source in a video element  videoElement.srcObject = stream;  videoElement.play();  // Create the Media Recorder  const options = { mimeType: "video/webm; codecs=vp9" };  mediaRecorder = new MediaRecorder(stream, options);  // Register Event Handlers  mediaRecorder.ondataavailable = handleDataAvailable;  mediaRecorder.onstop = handleStop;  // Updates the UI}此代碼來自教程 github 的源文件。你能幫忙解決一下嗎,謝謝
查看完整描述

1 回答

?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

const {remote} = require("electron");

const {dialog, Menu} = remote;

不是


const dialog = remote;

const Menu = remote;

而且我相信您使用的是較新版本的 Electron,您需要像這樣創建 BrowserWindow


const mainWindow = new BrowserWindow({

    width: 800,

    height: 600,

    webPreferences: {

      nodeIntegration: true,

      enableRemoteModule: true

    }

  })

因為你不允許remote在渲染器上使用,默認情況下enableRemoteModuel從falsev9開始


查看完整回答
反對 回復 2023-03-24
  • 1 回答
  • 0 關注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號