Descrição: Exemplo que ilustra como controlar a execução de uma música.
Autor: Edirlei Soares de Lima
Download: Exemplos06.zip
Código Fonte:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "Graphics.h" #include "Audio.h" Graphics graphics; Image botao_play; Image botao_pause; Image botao_stop; Audio Musica; void MainLoop() { graphics.DrawImage2D(botao_play); graphics.DrawImage2D(botao_pause); graphics.DrawImage2D(botao_stop); } void BotaoPlayClick( int button, int state, int x, int y) { if ((button == MOUSE_LEFT_BUTTON)&&(state == MOUSE_STATE_DOWN)) { Musica.Play(); } } void BotaoPauseClick( int button, int state, int x, int y) { if ((button == MOUSE_LEFT_BUTTON)&&(state == MOUSE_STATE_DOWN)) { if (Musica.IsPlaying() == true ) Musica.Pause(); else Musica.Play(); } } void BotaoStopClick( int button, int state, int x, int y) { if ((button == MOUSE_LEFT_BUTTON)&&(state == MOUSE_STATE_DOWN)) { Musica.Stop(); } } int main( void ) { graphics.CreateMainWindow(800, 600, "Exemplo 06 - Audio" ); graphics.SetBackgroundColor(152,209,250); botao_play.LoadPNGImage( "Button-Play-icon.png" ); botao_play.SetPosition(80, 200, 128, 128); botao_play.SetOnClick(BotaoPlayClick); botao_pause.LoadPNGImage( "Button-Pause-icon.png" ); botao_pause.SetPosition(336, 200, 128, 128); botao_pause.SetOnClick(BotaoPauseClick); botao_stop.LoadPNGImage( "Button-Stop-icon.png" ); botao_stop.SetPosition(592, 200, 128, 128); botao_stop.SetOnClick(BotaoStopClick); Musica.LoadAudio( "Music.mp3" ); graphics.SetMainLoop(MainLoop); graphics.StartMainLoop(); return 0; } |