Templates by BIGtheme NET

Event Notification to user by playing beep sound in Java Script

Description
This is a common requirement from web application users.

For some events, required beep sound.
That helps the user to identify some event occurrence.

Examples:

1) When new message push to the device.

2) When user transaction is completed.

3) When User attention is required for some critical action.

This code works even for lower end devices also.

Sample Java script Code

function playBeep() {

    var beepSourceFile = window.beepFilePath;
    var isHTML5 = true;
    /**
     * For lower versions of IE9, isHTML5 value will be false. The beep sound will be played with help of bgsound tag.
     * For IE9 & higher ver of IE, google chrome & firefox, isHTML5 is true. The beep will be played with help of audio tag.
     */
    try {
        if (isHTML5) {
            $("").appendTo('body');
            $('#beepAudio')[0].play();
        }
    } catch (ex) {
        isHTML5 = false;
    }
    //alert('isHTML5:' + isHTML5);

    if (!isHTML5) {
        $("body").append("");
    }
}

*** Venkat – Happy leaning ****