[Bug]: The recorded video has no sound
Environments
- playwright-go Version: v0.4702.0
- Browser: chrome
- OS and version: macOS
Bug description
To Reproduce
package main
import (
"fmt"
"github.com/playwright-community/playwright-go"
"log"
)
func main() {
err := playwright.Install(&playwright.RunOptions{
SkipInstallBrowsers: true,
})
if err != nil {
log.Fatalf("could not install playwright: %v", err)
}
pw, err := playwright.Run()
if err != nil {
log.Fatalf("could not launch playwright: %v", err)
}
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
Channel: playwright.String("chrome"),
Headless: playwright.Bool(false),
})
if err != nil {
log.Fatalf("could not launch Chromium: %v", err)
}
page, err := browser.NewPage(playwright.BrowserNewPageOptions{
Screen: &playwright.Size{
Width: 1920,
Height: 1080,
},
RecordVideo: &playwright.RecordVideo{
Dir: "videos/",
Size: &playwright.Size{
Width: 1920,
Height: 1080,
},
},
})
if err != nil {
log.Fatalf("could not create page: %v", err)
}
if _, err = page.Goto("https://xxx.video"); err != nil {
log.Fatalf("could not goto: %v", err)
}
err = page.Locator("#PlayButtonBig").Click()
if err != nil {
log.Fatalf("could not click entries: %v", err)
}
page.WaitForTimeout(10000)
if err := page.Close(); err != nil {
log.Fatalf("failed to close page: %v", err)
}
path, err := page.Video().Path()
if err != nil {
log.Fatalf("failed to get video path: %v", err)
}
fmt.Printf("Saved to %s\n", path)
if err = browser.Close(); err != nil {
log.Fatalf("could not close browser: %v", err)
}
if err = pw.Stop(); err != nil {
log.Fatalf("could not stop Playwright: %v", err)
}
}
There is no sound when playing the output file xxx.webm. Hope there is sound.
no voice, no audio
You can use BrowserTypeLaunchOptions{ ignoreDefaultArgs: } to filter out --mute-audio from default arguments (for chromium).
You can use
BrowserTypeLaunchOptions{ ignoreDefaultArgs: }to filter out--mute-audiofrom default arguments (for chromium).
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
IgnoreDefaultArgs: []string{"--mute-audio"},
Channel: playwright.String("chrome"),
Headless: playwright.Bool(false),
})
thx, but not working. During the recording process, sound can be heard, but there is no sound when playing the output file
According to upstream https://github.com/microsoft/playwright/issues/4870, recording audio is not supported.