vendredi 24 avril 2015

comment utiliser _sndplay,_sndplayfile en basic QB64 HOW TO PLAY WAV MP3 OGG MIDI

Le lien pour programmer en basic ---->http://www.qb64.net/


Un grand merci a la clinique GAMOPAT pour les réponse à mes questions car sans eux je n'aurai pas fais cet article.

10 emplacement$ = "rock/"                ' faites un dossier dans QB64 et nomez le " rock" dans lequel vous y metrais vos chansons
20 titre$(i) = "highway to hell.ogg"
30 titre$(i + 1) = "hell bells.wav"

40 titre$(i + 2) = "back to black.mp3"
50 i = 2                                              'votre choix de chanson

60 PRINT titre$(i)
70_SNDPLAYFILE emplacement$ + titre$(i)


 
Jouera le titre " back to black " car la variable est égale a 2 ! si elle était égale a 0 le titre aurai été " highway to hell" et si i était égale a 1 le titre serait "hell bells"

ATTENTION si vous ouvrez plusieurs chansons a la fois ça entraine un plantage ! il faut pour cela fermer la chanson precedente avec les fonctions _SNDSTOP handle&:_SNDCLOSE handle&, il se peut qu'il y es des lenteurs aussi !

Maintenant un petit programme pour faire une playliste !

ATTENTION le demarage de chaque titre prend du temp et MAJ doit être verouillé pour que le clavier réponde ! Les titres doivent se trouver dans le répertoire QB64.sinon ça ne marche pas.

20 titre$(i) = "highway to hell.MP3"                                             'notez que ce titre est facultatif !vous devez y mettre vos propres titres...
30 titre$(i + 1) = "hell  bells.MP3"
40 titre$(i + 2) = "back to black.MP3"
41 LOCATE 20, 20: PRINT "select 1-2-3 to play song AND E TO STOP THE PROG "

51 k$ = INKEY$:
52 IF k$ = "0" THEN i = 0: GOTO 90
53 IF k$ = "1" THEN i = 1: GOTO 90
54 IF k$ = "2" THEN i = 2: GOTO 90
55 IF k$ = "E" THEN END
80 GOTO 20
90 LOCATE 1, 1: PRINT titre$(i): _SNDSTOP handle&: _SNDCLOSE handle&: handle& = _SNDOPEN(titre$(i), "sync,vol"): _SNDVOL handle&, .3: _SNDPLAY handle&
100 GOTO 20

Aucun commentaire:

Enregistrer un commentaire