haste-compiler-0.5.1.1: 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 Source

Represents an audio player.

Instances

data AudioSettings Source

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 Source

Constructors

MP3 
OGG 
WAV 

data Seek Source

Constructors

Start 
End 
Seconds Double 

Instances

mkSource :: JSString -> Maybe AudioSource Source

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 Source

Create a new audio element.

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

Set the source of the given audio element.

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

Get the current state of the given audio object.

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

(Un)mute the given audio object.

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

Is the given audio object muted?

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

Mute/unmute.

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

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

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

Is the given audio object looping?

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

Toggle looping on/off.

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

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

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

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

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

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

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

Starts playing audio from the given element.

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

Pause the given audio element.

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

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

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

If playing, stop. Otherwise, start playing.

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

Seek to the specified time.

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

Get the duration of the loaded sound, in seconds.

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

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