sounds

package
v0.0.0-...-3432426 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: MPL-2.0 Imports: 13 Imported by: 0

README

Licenses:

message.opus is taken from `sound-theme-freedesktop` at
https://directory.fsf.org/wiki/Sound-theme-freedesktop. It is re-encoded from
the original .oga file to a low bitrate .opus file. It is licensed under
Creative Commons.

Documentation

Index

Examples

Constants

View Source
const (
	Bell    = "bell"
	Message = "message"
)

Sound IDs.

Variables

This section is empty.

Functions

func Play

func Play(app *app.Application, id string)

Play plays the given sound ID. It first uses Canberra, falling back to ~/.cache/gotktrix/{id}.opus, then the embedded audio (if any), then display.Beep() otherwise.

Play is asynchronous; it returning does not mean the audio has successfully been played to the user.

Example
app := app.New(context.Background(), "com.example.app", "app")
app.ConnectActivate(func() {
	// Plays are automatically debounced.
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)
	sounds.Play(app, sounds.Message)

	app.Hold()
	glib.TimeoutSecondsAdd(1, app.Release)
})

app.Run(nil)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL