Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions v2/internal/frontend/desktop/darwin/WailsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct Preferences {
bool *textInteractionEnabled;
bool *fullscreenEnabled;
const char *applicationNameForUserAgent;
bool *enableAutoplayWithoutUserAction;
};

- (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable :(bool)zoomable :(bool)fullscreen :(bool)fullSizeContent :(bool)hideTitleBar :(bool)titlebarAppearsTransparent :(bool)hideTitle :(bool)useToolbar :(bool)hideToolbarSeparator :(bool)webviewIsTransparent :(bool)hideWindowOnClose :(NSString *)appearance :(bool)windowIsTranslucent :(int)minWidth :(int)minHeight :(int)maxWidth :(int)maxHeight :(bool)fraudulentWebsiteWarningEnabled :(struct Preferences)preferences :(bool)enableDragAndDrop :(bool)disableWebViewDragAndDrop :(bool)disableEscapeExitsFullscreen;
Expand Down
4 changes: 4 additions & 0 deletions v2/internal/frontend/desktop/darwin/WailsContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ - (void) CreateWindow:(int)width :(int)height :(bool)frameless :(bool)resizable
}
#endif

if (preferences.enableAutoplayWithoutUserAction != NULL && *preferences.enableAutoplayWithoutUserAction) {
config.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
}

WKUserContentController* userContentController = [WKUserContentController new];
[userContentController addScriptMessageHandler:self name:@"external"];
config.userContentController = userContentController;
Expand Down
4 changes: 4 additions & 0 deletions v2/internal/frontend/desktop/darwin/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ func NewWindow(frontendOptions *options.App, debug bool, devtools bool) *Window
if mac.Preferences.ApplicationNameForUserAgent != "" {
preferences.applicationNameForUserAgent = c.String(mac.Preferences.ApplicationNameForUserAgent)
}

if mac.Preferences.EnableAutoplayWithoutUserAction.IsSet() {
preferences.enableAutoplayWithoutUserAction = bool2CboolPtr(mac.Preferences.EnableAutoplayWithoutUserAction.Get())
}
}

zoomable = bool2Cint(!frontendOptions.Mac.DisableZoom)
Expand Down
5 changes: 5 additions & 0 deletions v2/pkg/options/mac/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ type Preferences struct {
// (e.g. YouTube embed) reject the default identifier. Leave empty to keep
// Wails' default behaviour.
ApplicationNameForUserAgent string
// EnableAutoplayWithoutUserAction allows media to start playing automatically
// without requiring a user gesture. When unset or false, WebKit's default
// behaviour is preserved (gesture required).
// Maps to WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback.
EnableAutoplayWithoutUserAction u.Bool
}