Results 1 to 3 of 3

Thread: Mouse Unit - Pausing program until input

  1. #1

    Mouse Unit - Pausing program until input

    IDE: Free Pascal, NO Lazarus
    WinXP
    Using BASS Audio engine... http://www.un4seen.com/

    Well, heres the thing. The mouse unit, when used within a repeat until loop, seems to be unhappy with just ending when its supposed to. SO, my problem, is that I am making a media player, and it automatically switches to the next song. However, due to the mouse unit, this does not work, because it waits for me to mouse-over the screen, then it switches songs. Annoying beyond belief... I tried to put an event in the queue, but that didnt work either. I'm using the GetMouseEvent(event); command, and a with event do begin to use it. How can I fix this?

    [pascal]
    Procedure Play_Playlist;
    begin
    clrscr_display;
    bass_setvolume(100);
    mp3 := bass_sampleload(false,pchar(playlist[z]),0,0,BASS_SAMPLE_LOOP,0);
    songhand := bass_samplegetchannel(mp3,false);
    songlength := bass_channelgetlength(songhand); //Get total length of file

    gotoxy(1,23);
    writeln('<<<<');
    gotoxy(28,23);
    writeln('pause');
    gotoxy(35,23);
    writeln('resume');
    gotoxy(43,23);
    writeln('goto');
    gotoxy(49,23);
    writeln('quit');
    gotoxy(77,23);
    writeln('>>>>');

    i:= TID3v11.create(nil);
    i.LoadFromFile(playlist[z]);
    writebox(2,2,'message','Title: '+i.title,'Artist: '+i.artist,'Album: '+i.album);
    gotoxy(2,5);
    writeln('Year: '+i.year);
    gotoxy(2,6);
    if (i.Genre<Length(ID3v11Genres)) then
    WriteLn('Genre: '+ID3v11Genres[i.Genre])
    else
    WriteLn('Unknown Genre');
    i.free;
    bass_channelplay(songhand,true);
    InitMouse;
    nextsong := false;
    repeat
    songcurrent := bass_channelgetposition(songhand);
    getmouseevent(event);
    playing_mouse;
    command_playing;
    if mode = 'quit' then exit;
    if bass_channelisactive(songhand) = BASS_ACTIVE_STOPPED then nextsong := true;
    until nextsong = true;
    donemouse;
    itemclicked := false;
    Play_Next;
    end;

    Procedure Command_Playing;
    begin
    //cmd := entry;
    if cmd <then> 1 then begin
    if (buttons=mouseleftbutton) and (action=MouseActionDown) and ((x = 0) or (x = 1) or (x = 2) or (x = 3)) and (y = 22) then begin
    cmd := 'prev';
    itemclicked := true;
    end;
    end;

    if (buttons=mouseleftbutton) and (action=MouseActionDown) and ((x = 75) or (x = 76) or (x = 77) or (x = 7) and (y = 22) then begin
    cmd := 'next';
    itemclicked := true;
    end;

    if (buttons=mouseleftbutton) and (action=MouseActionDown) and ((x = 27) or (x = 2 or (x = 29) or (x = 30) or (x = 31)) and (y = 22) then begin
    cmd := 'pause';
    itemclicked := true;
    end;

    if (buttons=mouseleftbutton) and (action=MouseActionDown) and ((x = 34) or (x = 35) or (x = 36) or (x = 37) or (x = 3 or (x = 39)) and (y = 22) then begin
    cmd := 'resume';
    itemclicked := true;
    end;

    if (buttons=mouseleftbutton) and (action=MouseActionDown) and ((x = 42) or (x = 43) or (x = 44) or (x = 45)) and (y = 22) then begin
    cmd := 'goto';
    itemclicked := true;
    end;

    if (buttons=mouseleftbutton) and (action=MouseActionDown) and ((x = 4 or (x = 49) or (x = 50) or (x = 51)) and (y = 22) then begin
    cmd := 'quit';
    itemclicked := true;
    end;
    end;
    end;

    begin
    LM_Initialize;
    repeat
    if (mode <> 'create') and (mode <> 'load') and (listload = false) then begin
    repeat
    clrscr_display;
    Menu_Main_Mouse;
    command_main;
    until (mode = 'create') or (mode = 'load') or (mode = 'quit');
    end;
    if listload = true then begin
    repeat
    clrscr_display;
    gotoxy(2,2);
    menu_load_mouse;
    command_load;
    until (mode = 'quit') or (mode = 'load') or (mode = 'play') or (mode = 'list');
    end;
    if (mode = 'create') and (listload = false) then Create_Playlist;
    if mode = 'load' then Load_Playlist;
    if (mode = 'play') and (listload = true) then Play_Playlist;
    if mode = 'quit' then cmd := 'quit';
    if (mode = 'list') and (listload = true) then ListItems;
    until cmd = 'quit';
    LM_Quit;
    end.

    Procedure Pause;
    begin
    bass_channelpause(songhand);
    end;

    Procedure Resume;
    begin
    bass_channelplay(songhand,false);
    end;

    Procedure Stop;
    begin
    bass_channelstop(songhand); //Is this right?
    end;

    Procedure Restart;
    begin
    bass_channelstop(songhand); //is this right?
    bass_channelplay(songhand,false);
    end;
    //End Song Controls..

    Procedure Play_Next;
    begin
    z := z+1;
    bass_channelstop(songhand);
    bass_samplefree(songhand);
    songlength := 0;
    songcurrent := 0;
    Play_Playlist;
    end;


    Procedure Play_Prev;
    begin
    z := z-1;
    bass_channelstop(songhand);
    bass_samplefree(songhand);
    songlength := 0;
    songcurrent := 0;
    Play_Playlist;
    end;

    begin
    LM_Initialize;
    repeat
    if (mode <> 'create') and (mode <> 'load') and (listload = false) then begin
    repeat
    clrscr_display;
    Menu_Main_Mouse;
    command_main;
    until (mode = 'create') or (mode = 'load') or (mode = 'quit');
    end;
    if listload = true then begin
    repeat
    clrscr_display;
    gotoxy(2,2);
    menu_load_mouse;
    command_load;
    until (mode = 'quit') or (mode = 'load') or (mode = 'play') or (mode = 'list');
    end;
    if (mode = 'create') and (listload = false) then Create_Playlist;
    if mode = 'load' then Load_Playlist;
    if (mode = 'play') and (listload = true) then Play_Playlist; {this here being a loop in itself, which doesn't end... So, no problems possible here.}
    if mode = 'quit' then cmd := 'quit';
    if (mode = 'list') and (listload = true) then ListItems;
    until cmd = 'quit';
    LM_Quit;
    end.
    [/pascal]
    --MagicRPG--

  2. #2

    Mouse Unit - Pausing program until input

    Updated post...
    --MagicRPG--

  3. #3

    Mouse Unit - Pausing program until input

    Well, as it turns out, it was an easy fix. Simply had to prefix GetMouseEvent with if PollMouseEvent(event) then GetMouseEvent(event); as Pollmouseevent does not wait for input, while GetMouseEvent does.
    --MagicRPG--

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •