forked from cloudflare/orange
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recorder.mjs
44 lines (36 loc) · 1.14 KB
/
recorder.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import fs from 'fs'
import puppeteer from 'puppeteer'
import { getStream, launch, wss } from 'puppeteer-stream'
const file = fs.createWriteStream('./test.webm')
;(async () => {
// Launch the browser and open a new blank page
const browser = await launch({
executablePath: puppeteer.executablePath(),
// args: ['--use-fake-ui-for-media-stream'],
defaultViewport: {
width: 1920,
height: 1080,
},
})
const page = await browser.newPage()
// Navigate the page to a URL
await page.goto('http://localhost:8787/bigoteam/room?skip_permission_check')
// Set screen size
await page.setViewport({ width: 1080, height: 1024 })
// Type into search box
await page.type('#username', 'bigoteam recorder')
await page.waitForSelector('button[type="submit"]')
await page.click('button[type="submit"]')
const stream = await getStream(page, { audio: true, video: false })
console.log('recording')
stream.pipe(file)
// await page.waitForSelector('#join-button')
// await page.click("#join-button")
setTimeout(async () => {
await stream.destroy()
file.close()
console.log('finished')
;(await wss).close()
await browser.close()
}, 30000)
})()