audio

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<audio")
	TagClose = []byte("</audio>")

	AttrAutoplay              = []byte(" autoplay")
	AttrControls              = []byte(" controls")
	AttrLoop                  = []byte(" loop")
	AttrMuted                 = []byte(" muted")
	AttrSrc                   = []byte(" src=\"")
	AttrControlsList          = []byte(" controlslist=\"")
	AttrCrossOrigin           = []byte(" crossorigin=\"")
	AttrDisableRemotePlayback = []byte(" disableremoteplayback")
	AttrLoading               = []byte(" loading=\"")
	AttrPreload               = []byte(" preload=\"")
)

Byte constants for HTML rendering.

Functions

func Fallback

func Fallback(fallback string) *element

Fallback Creates a new audio element with fallback text content for unsupported browsers. Example: audio.Fallback("Your browser does not support audio.") Renders: <audio>Your browser does not support audio.</audio>

func New

func New(nodes ...node.Node) *element

New Creates a new audio element without any initial attributes. Example: audio.New() Renders: <audio></audio>

func PreloadAuto

func PreloadAuto(nodes ...node.Node) *element

PreloadAuto Creates an audio element with preload="auto" (loads entire audio). Example: audio.PreloadAuto() Renders: <audio preload="auto"></audio>

func PreloadMetadata

func PreloadMetadata(nodes ...node.Node) *element

PreloadMetadata Creates an audio element with preload="metadata" (loads only metadata). Example: audio.PreloadMetadata() Renders: <audio preload="metadata"></audio>

func PreloadNone

func PreloadNone(nodes ...node.Node) *element

PreloadNone Creates an audio element with preload="none" (no preloading). Example: audio.PreloadNone() Renders: <audio preload="none"></audio>

func Sources

func Sources(sources ...node.Node) *element

Sources Creates a new audio element with multiple <source> child elements. Example: audio.Sources(source.AudioMP3("/music/song.mp3"), source.AudioOgg("/music/song.ogg")) Renders: <audio><source src="/music/song.mp3" type="audio/mpeg" /><source src="/music/song.ogg" type="audio/ogg" /></audio>

func Src added in v0.3.0

func Src(src string) *element

Src Creates an audio element that loads a single audio source. Example: audio.Src("/music/song.mp3") Renders: <audio src="/music/song.mp3"></audio>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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