function process_main($window, $id)
{
    // Try to load the multimedia dll
    $winmmlib = wb_load_library("winmm");
    $mciSendString = wb_get_function_address("mciSendString", $winmmlib);
    static $file_filter = array(array("MP3 file", "*.mp3"));
    switch ($id) {
        case ID_OPEN:
            $filename = wb_sys_dlg_open($window, "Get It", $file_filter);
            if ($filename) {
                wb_call_function($mciSendString, array("open \"" . $filename . "\" type mpegvideo alias " . $filename, NULL, 0, 0));
            }
            wb_call_function($mciSendString, array("play \"" . $filename . "\" from 0 notify", NULL, 0, 0));
            break;
        case IDCLOSE:
            // IDCLOSE is predefined
            wb_destroy_window($window);
            break;
    }
}
function import_csv($window)
{
    global $statusbar;
    $filename = wb_sys_dlg_open($window, "Import CSV", "CSV files (*.csv, *.txt)*.csv;*.txtAll files (*.*)*.*" . "");
    if ($filename) {
        $csv = file($filename);
    } else {
        return false;
    }
    $n = 0;
    foreach ($csv as $line) {
        $line = trim($line);
        if ($line) {
            $entry = csv_explode(stripcslashes($line));
            if (edit_record("item", 0, "name\ndescription\ncat\npriority\nseverity", $entry)) {
                $n++;
            }
        }
    }
    wb_set_text($statusbar, basename($filename) . " imported successfully ({$n} items added).");
    return true;
}
function process_main($window, $id, $ctrl)
{
    global $statusbar, $fmod, $mainwin;
    switch ($id) {
        case ID_INFOTIMER:
            $status = "´ÅÅÌ: " . $fmod->fmod_GetOutputName() . " ";
            $status .= "¸èÇú³¤¶È: " . $fmod->fmod_GetLenght(true) . " ·ÖÖÓ ";
            $status .= "ÒѲ¥·Å: " . $fmod->fmod_Msec2Time($fmod->fmod_GetTime(true)) . " sec ";
            if ($song_name = $fmod->fmodStreamUrl) {
                $status .= "Ãû³Æ: {$song_name} ";
            }
            wb_set_text($statusbar, $status);
            //		play position
            if ($fmod->fmod_GetLenght(false)) {
                wb_set_value(wb_get_control($mainwin, ID_PLAY_POS), round($fmod->fmod_GetTime(false) / $fmod->fmod_GetLenght(false), 2) * 100);
            }
            if ($fmod->fmod_GetTime(false) == $fmod->fmod_GetLenght(false)) {
                $fmod->fmod_StreamOpen($fmod->fmodStreamUrl);
                $fmod->fmod_StreamPlay();
            }
            break;
        case ID_OPEN:
            $filename = wb_sys_dlg_open();
            if ($filename) {
                if ($fmod->fmod_StreamOpen($filename)) {
                    $fmod->fmod_StreamPlay();
                    // returns true, then play
                } else {
                    wb_message_box($window, "Error opening Audiostream!\n" . $fmod->lasterror, APPNAME, WBC_INFO);
                }
            }
            break;
        case ID_CLOSE:
            $fmod->fmod_StreamStop();
            break;
        case ID_PLAY:
            $fmod->fmod_StreamPlay();
            break;
        case ID_STOP:
            $fmod->fmod_StreamStop();
            break;
        case ID_PAUSE:
            if ($fmod->fmodStreamState == 1) {
                switch ($fmod->fmodIsPaused) {
                    case 0:
                        $fmod->fmod_SoundPause(true);
                        wb_set_text($ctrl, "¼ÌÐø..");
                        break;
                    case 1:
                        $fmod->fmod_SoundPause(false);
                        wb_set_text($ctrl, "ÔÝÍ£");
                        break;
                }
            }
            break;
        case ID_MUTE:
            if ($fmod->fmodStreamState == 1) {
                switch ($fmod->fmodIsMuted) {
                    case 0:
                        $fmod->fmod_SoundMute(true);
                        wb_set_text($ctrl, "·ÅÒô");
                        break;
                    case 1:
                        $fmod->fmod_SoundMute(false);
                        wb_set_text($ctrl, "¾²Òô");
                        break;
                }
            }
            break;
        case ID_SURROUND:
            switch ($fmod->fmodSurroundEnabled) {
                case 0:
                    $fmod->fmod_SetSurround(true);
                    wb_set_text($ctrl, "Ñ­»·");
                    break;
                case 1:
                    $fmod->fmod_SetSurround(false);
                    wb_set_text($ctrl, "²»Ñ­»·");
                    break;
            }
            break;
        case ID_VOLUMEN:
            $fmod->fmod_SetVolumen(wb_get_value($ctrl));
            wb_set_text($statusbar, "ÒôÁ¿: " . $fmod->fmod_GetVolumen());
            break;
        case ID_BALANCE:
            $fmod->fmod_SetPanning(wb_get_value($ctrl));
            break;
        case ID_BALCENTER:
            $fmod->fmod_SetPanning(127);
            wb_set_value(wb_get_control($window, ID_BALANCE), 127);
            break;
        case IDCLOSE:
            $fmod->fmod_SoundClose();
            wb_release_library($fmod->fmodlib);
            wb_destroy_window($window);
            break;
    }
}