haste-compiler-0.5.5.0: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.Audio

Description

High-ish level bindings to the HTML5 audio tag and JS API.

Synopsis

Documentation

data Audio

Represents an audio player.

Instances

data AudioSettings

Constructors

AudioSettings 

Fields

audioControls :: !Bool

Show controls? Default: False

audioAutoplay :: !Bool

Immediately start playing? Default: False

audioLooping :: !Bool

Initially looping? Default: False

audioPreload :: !AudioPreload

How much audio to preload. Default: Auto

audioMuted :: !Bool

Initially muted? Default: False

audioVolume :: !Double

Initial volume Default: 0

data AudioType

Constructors

MP3 
OGG 
WAV 

data AudioState

Constructors

Playing 
Paused 
Ended 

data Seek

Constructors

Start 
End 
Seconds Double 

Instances

mkSource :: JSString -> Maybe AudioSource

Create an audio source with automatically detected media type, based on the given URL's file extension. Returns Nothing if the given URL has an unrecognized media type.

newAudio :: MonadIO m => AudioSettings -> [AudioSource] -> m Audio

Create a new audio element.

setSource :: MonadIO m => Audio -> AudioSource -> m ()

Set the source of the given audio element.

getState :: MonadIO m => Audio -> m AudioState

Get the current state of the given audio object.

setMute :: MonadIO m => Audio -> Bool -> m ()

(Un)mute the given audio object.

isMute :: MonadIO m => Audio -> m Bool

Is the given audio object muted?

toggleMute :: MonadIO m => Audio -> m ()

Mute/unmute.

setLooping :: MonadIO m => Audio -> Bool -> m ()

Set whether the given sound should loop upon completion or not.

isLooping :: MonadIO m => Audio -> m Bool

Is the given audio object looping?

toggleLooping :: MonadIO m => Audio -> m ()

Toggle looping on/off.

getVolume :: MonadIO m => Audio -> m Double

Get the volume for the given audio element as a value between 0 and 1.

setVolume :: MonadIO m => Audio -> Double -> m ()

Set the volume for the given audio element. The value will be clamped to [0, 1].

modVolume :: MonadIO m => Audio -> Double -> m ()

Modify the volume for the given audio element. The resulting volume will be clamped to [0, 1].

play :: MonadIO m => Audio -> m ()

Starts playing audio from the given element.

pause :: MonadIO m => Audio -> m ()

Pause the given audio element.

stop :: MonadIO m => Audio -> m ()

Stop playing a track, and seek back to its beginning.

togglePlaying :: MonadIO m => Audio -> m ()

If playing, stop. Otherwise, start playing.

seek :: MonadIO m => Audio -> Seek -> m ()

Seek to the specified time.

getDuration :: MonadIO m => Audio -> m Double

Get the duration of the loaded sound, in seconds.

getCurrentTime :: MonadIO m => Audio -> m Double

Get the current play time of the loaded sound, in seconds.