Electron:摄像头录制和屏幕录制

Electron:摄像头录制和屏幕录制

摄像头录制

main.js

const {
   
    app, BrowserWindow} = require('electron')


let mainWin = null
const createWindow = () => {
   
   
  mainWin = new BrowserWindow({
   
   
    width: 800,
    height: 600,
    title: '自定义菜单',
    webPreferences: {
   
   
      // 允许渲染进程使用nodejs
      nodeIntegration: true,
      // 允许渲染进程使用nodejs
      contextIsolation: false,
    }
  })
  mainWin.loadFile('index.html')
  mainWin.webContents.openDevTools()
}

app.whenReady().then(() => {
   
   
  createWindow()
  app.on('activate', () => {
   
   
    if (BrowserWindow.getAllWindows().length === 0) {
   
   
      createWindow()
    }
  })
})

app.on('window-all-closed', () => {
   
   
  if (process.platform !== 'darwin') {
   
   
    app.quit()
  }
})


index.html

<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title></title>
</head>

<body>
  <button id="openCamera">打开摄像头</button>
  <button id="start">开始录制</button>
  <button id="stop">停止录制</button>
  <button id="play">播放</button>

  <video src="" id="originVideo"></video>
  <video src="" id="playVideo" width="400" height="500"></video>

  <script>

    const openCamera = document.querySelector("#openCamera")
    const start 
转载请说明出处内容投诉
CSS教程网 » Electron:摄像头录制和屏幕录制

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买