Skip to main content
Module

x/denops_std/function/vim/mod.ts>sound_playevent

📚 Standard module for denops.vim
Go to Latest
function sound_playevent
import { sound_playevent } from "https://deno.land/x/denops_std@v6.4.0/function/vim/mod.ts";

Play a sound identified by {name}. Which event names are supported depends on the system. Often the XDG sound names are used. On Ubuntu they may be found in /usr/share/sounds/freedesktop/stereo. Example:

call sound_playevent('bell')

On MS-Windows, {name} can be SystemAsterisk, SystemDefault, SystemExclamation, SystemExit, SystemHand, SystemQuestion, SystemStart, SystemWelcome, etc. On macOS, {name} refers to files located in /System/Library/Sounds (e.g. "Tink"). It will also work for custom installed sounds in folders like ~/Library/Sounds.

When {callback} is specified it is invoked when the sound is finished. The first argument is the sound ID, the second argument is the status: 0 sound was played to the end 1 sound was interrupted 2 error occurred after sound started Example:

func Callback(id, status)
  echomsg "sound " .. a:id .. " finished with " .. a:status
endfunc
call sound_playevent('bell', 'Callback')

MS-Windows: {callback} doesn't work for this function.

Returns the sound ID, which can be passed to sound_stop(). Returns zero if the sound could not be played.

Can also be used as a method:

GetSoundName()->sound_playevent()

only available when compiled with the +sound feature

Parameters

denops: Denops
name: unknown
optional
callback: unknown

Returns

Promise<number>