Skip to content

Instantly share code, notes, and snippets.

@whitetigle
Created June 14, 2017 16:04
Show Gist options
  • Save whitetigle/1f3015f5633ea47f9dc4aa7effae2026 to your computer and use it in GitHub Desktop.
Save whitetigle/1f3015f5633ea47f9dc4aa7effae2026 to your computer and use it in GitHub Desktop.
Waud.js bindings for fable
namespace Fable.Import
open Fable.Core
open Fable.Import.JS
open Fable.Import.Browser
open Fable.Core.JsInterop
module Waud =
type Waud =
[<Emit("Waud.autoMute()")>]
static member autoMute() : unit = jsNative
[<Emit("Waud.destroy()")>]
static member destroy() : unit = jsNative
[<Emit("Waud.enableTouchUnlock( $0 )")>]
static member enableTouchUnlock( f : unit -> unit ) : unit = jsNative
[<Emit("Waud.getFormatSupportString()")>]
static member getFormatSupportString() : string = jsNative
[<Emit("Waud.getSampleRate()")>]
static member getSampleRate() : float = jsNative
[<Emit("Waud.getVolume()")>]
static member getVolume() : float = jsNative
[<Emit("Waud.init()")>]
static member init(?doc: HTMLDocument) : unit = jsNative
[<Emit("Waud.isAACSupported()")>]
static member isAACSupported() : bool = jsNative
[<Emit("Waud.isM4ASupported()")>]
static member isM4ASupported() : bool = jsNative
[<Emit("Waud.isMP3Supported()")>]
static member isMP3Supported() : bool = jsNative
[<Emit("Waud.isOGGSupported()")>]
static member isOGGSupported() : bool = jsNative
[<Emit("Waud.isSupported()")>]
static member isSupported() : bool = jsNative
[<Emit("Waud.isWAVSupported()")>]
static member isWAVSupported() : bool = jsNative
[<Emit("Waud.mute()")>]
static member simpleMute() unit = jsNative
[<Emit("Waud.mute($0)")>]
static member mute( mute: bool) : unit = jsNative
[<Emit("Waud.pause()")>]
static member pause() : unit = jsNative
[<Emit("Waud.playbackRate( $0)")>]
static member playbackRate( rate: float) : unit = jsNative
[<Emit("Waud.setVolume( $0)")>]
static member setVolume( vol:float) : unit = jsNative
[<Emit("Waud.stop()")>]
static member stop() : unit = jsNative
type IWaudSound =
abstract isSpriteSound : bool with get, set
abstract rate : float with get, set
abstract spriteName : string with get, set
abstract url : string with get, set
abstract autoStop : bool -> unit
abstract destroy : unit -> unit
abstract getDuration : unit -> float
abstract getTime : unit -> float
abstract getVolume : unit -> float
abstract isPlaying : unit -> bool
abstract isReady : unit -> bool
abstract load : unit -> float
abstract loadAndBack : ?callback : unit -> IWaudSound
abstract loop : bool -> unit
abstract simpleMute : unit -> unit
abstract mute : bool -> unit
abstract onEnd : ?callback : unit -> IWaudSound
abstract onError : ?callback : unit -> IWaudSound
abstract onLoad : ?callback : unit -> IWaudSound
abstract pause : ?string : unit -> unit
abstract play : ?string :unit -> unit
abstract stop : ?string :unit-> unit
abstract togglePlay : ?string :unit -> bool
abstract playbackRate : float -> unit
abstract setTime : float -> unit
abstract setVolume : float -> unit
abstract toggleMute : unit -> bool
and WaudCallback = System.Func<IWaudSound,unit>
and WaudSoundOptions =
| Autoplay of bool
| Autostop of bool
| Loop of bool
| OnEnd of WaudCallback
| OnError of WaudCallback
| OnLoad of WaudCallback
| PlaybackRate of float
| Preload of bool
| Volume of float
| Webaudio of bool
[<Emit("new WaudSound($0,$1)")>] let WaudSound (url,options) : IWaudSound = jsNative
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment