linsyking/messenger-core/17.1.1

NOTE: the latest version is 20.0.0

Renamed to elm-messenger/messenger-core. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as linsyking/messenger-core still install under that name. 34 versions of 52 come from the new location (see their notes). 7 versions could not be recovered and cannot be installed.

Messenger.Audio.Audio

Audio Module

You can play audio by emitting SOMPlayAudio message with the audio ID, a channel, and an option.

The channel is an integer that is used to identify the audio channel.

You can play different audio on the same channel at the same time. The previous audio will not be stopped.

However, when you stop the channel, all audio on the channel will be stopped.

If an audio is finished playing, it will be removed from the playing channel.

newAudioChannel : InternalData -> Int

Generate a new unique audio channel number.

You should add the internal data in globaldata as the parameter, and the returning value is a integer which is the generated channel number.
    - Note: It is really similar to GenUID.
audioDuration : InternalData -> String -> Maybe Duration

Get the duration of an audio by its ID.

Usage : audioDuration internalData audioId

  • internalData is just env.globaldata.internalData. Just pass it as your first argument.
  • audioID is the NAME (not ID!) of the desired audio, which should be registered in the resources.elm.

The output of the function is a Maybe Duration, with which you can extract the Float value of the length in seconds via Duration.inSeconds.

Example: audioDuration id "Boom" |> Duration.inSeconds == 1.274 -- the duration in seconds.