fordon_greeman / moosicpalyer

Branch: 9c07b8b
Switch branches/tags
main
theidioticdev init 9c07b8b 14d ago
60 lines · 1.3 KB Raw Blame History
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include "raylib.h"
5
6 int
7 main ()
8 {
9 const int width = 640;
10 const int height = 480;
11
12 InitWindow (width, height, "moosic palyer");
13 SetTargetFPS (60);
14 InitAudioDevice();
15 Music song;
16 FILE *f = popen("zenity --file-selection", "r");
17 if (f != NULL)
18 {
19 char song_path[1024];
20 if (fgets(song_path, sizeof(song_path), f) != NULL) {
21 song_path[strcspn(song_path, "\n")] = 0;
22
23 song = LoadMusicStream(song_path);
24 PlayMusicStream(song);
25 }
26 pclose(f);
27 }
28
29 while (!WindowShouldClose ())
30 {
31 UpdateMusicStream (song);
32
33 if (IsKeyPressed (KEY_P) == true && IsMusicStreamPlaying (song))
34 {
35 PauseMusicStream (song);
36 }
37 else if (IsKeyPressed (KEY_P) == true && !IsMusicStreamPlaying (song))
38 {
39 ResumeMusicStream (song);
40 }
41
42 BeginDrawing ();
43 ClearBackground (BLACK);
44
45 if (!IsMusicStreamPlaying (song))
46 {
47 DrawText("paused :<", width / 2, height /2 , 14, RAYWHITE);
48 }
49 else
50 {
51 DrawText("currently playing music :D", width / 2, height / 2 , 14, RAYWHITE);
52 }
53 EndDrawing ();
54
55 }
56 UnloadMusicStream(song);
57 CloseAudioDevice ();
58 CloseWindow ();
59 return 0;
60 }