Geluid luider/stiller zetten

Alles over het toepassen van API en DLL's in Liberty BASIC

Moderator: anthonio

Geluid luider/stiller zetten

Berichtdoor anthonio » wo maart 25, 2009 12:01 am

Volgende code toont hoe je het geluid luider of zachter kan zetten van een mp3-file.
Handig voor bv een muziekspeler

Code: Selecteer alles
WindowWidth = 100
WindowHeight = 100

button #main, "plus", [plus], UL, 10, 10, 30, 20
button #main, "min", [min], UL, 50, 10, 30, 20
open "Eye Saver" for window as #main
#main, "trapclose [Quit]"

filedialog "MP3-bestand", "*.mp3", m$
m$=GetShortPathName$(m$)
r$=mciSendString$("open "+m$+" alias music")
r$=mciSendString$("play music")
counter=0
wait

'Geluid luider zetten
[plus]
if counter < 1000 then
    counter = counter + 100
    volume = counter
    r$=mciSendString$("setaudio music volume to ";volume)
    print counter
end if
wait

'Geluid zachter zetten
[min]
if counter > 0 then
    counter = counter - 100
    volume = counter
    r$=mciSendString$("setaudio music volume to ";volume)
    print counter
end if
wait

[Quit]
    r$=mciSendString$("close music")
    close #main
    end

Function mciSendString$(s$)
    buffer$=space$(1024)+chr$(0)
    calldll #winmm,"mciSendStringA",s$ as ptr,buffer$ as ptr,_
        1028 as long, 0 as long, r as long
    buffer$=left$(buffer$, instr(buffer$, chr$(0)) - 1)
        if r>0 then
            mciSendString$="error"
        else
            mciSendString$=buffer$
        end if
    End Function

Function GetShortPathName$(lPath$)
    lPath$=lPath$+chr$(0)
    sPath$=space$(256)
    lenPath=len(sPath$)
    calldll #kernel32, "GetShortPathNameA",lPath$ as ptr,_
    sPath$ as ptr,lenPath as long,r as long
    GetShortPathName$=left$(sPath$,r)
    end function
Dual boot: Ubuntu 8.04 - WIndows XP SP2 (via VMware) - Windows Vista 32bit - Toshiba L40 - Dual Core @ 1,76GHz - 1GB RAM - 120GB HDD - VDSL Connection
Avatar gebruiker
anthonio
 
Berichten: 281
Geregistreerd: zo mei 20, 2007 9:58 pm

Keer terug naar API/DLL

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron