Packages‎ > ‎gnocl::gnome‎ > ‎

gnocl::sound

Play a sound sample from disk.

Synopsis

gnocl::sound fileName <option val>

Description

The gnocl::sound command will play a sound file from disk. The filetypes supported are those recognised by libCanberra for which this command is a binding.

Options

-onFinished string (default: "")
Tcl command which is executed when the playing of the sound file is complete. 
%f    name of the sample played.
%e   errorcode  ie. how the play was terminated, 0 = play completed, -1 play cancelled.

Subcommands

cancel 
Terminates the playback of the current audio file.

Example


# basic Tcl/Gnocl Script
#!/bin/sh \
exec tclsh "$0" "$@"
package require Gnocl

set but1 [gnocl::button -text play ]
set but2 [gnocl::button -text stop -sensitive 0 ]

$but1 configure -onClicked \
    {
        $but2 configure -sensitive 1
        %w configure -sensitive 0
        gnocl::sound bell.wav \
    
            -onFinished {
    
               $but1 configure -sensitive 1 
    
               $but2 configure -sensitive 0  
    
            }

    }

$but2 configure -onClicked \
    {
        $but1 configure -sensitive 1
        %w configure -sensitive 0
        gnocl::sound cancel
    }

set box [gnocl::box]

$box add [list $but1 $but2] -fill {1 1 } -expand 1

gnocl::window -child $box -width 200

gnocl::mainLoop

Comments