需求
录屏状态时,屏幕底部有个计时器,点击计时器停止录屏,跳转录屏结束的视频播放。
效果如下
electron-录屏演示
实现
计时器
创建一个浮窗,根据x、y坐标移动窗口的位置;
// 获取屏幕的主显示器信息
const { width, height } = screen.getPrimaryDisplay().workAreaSize;
// 设置窗口的宽度和高度
const windowWidth = 120;
const windowHeight = 120;
// app.commandLine.appendSwitch('disable-features', 'IOSurfaceCapturer,DesktopCaptureMacV2')
recordWin = new BrowserWindow({
width: windowWidth,
height: windowHeight,
x: width / 2 - windowWidth / 2,
y: height - windowHeight,
frame: true, // 无边框
transparent: true, // 透明窗口
alwaysOnTop: true, // 窗口