Kaktusen

Music Player

Jul 20th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | None | 0 0
  1. #include "SDL/SDL.h"
  2. #include "SDL/SDL_mixer.h"
  3.  
  4. #include <iostream>
  5. #include <fstream>
  6. #include <string>
  7.  
  8. #include "surface.h"
  9.  
  10. using namespace std;
  11.  
  12. ofstream output("output.txt");
  13. string sound;
  14.  
  15. void playSound();
  16. void stopSound();
  17. void pauseSound();
  18. void resumeSound();
  19. void loadSound();
  20. void convertFile();
  21. void exit();
  22.  
  23. Mix_Music *music;
  24.  
  25. void write(string writing) {
  26.     output << writing << endl;
  27. }
  28.  
  29. int main(int argc, char *args[]) {
  30.     SDL_Init(SDL_INIT_EVERYTHING);
  31.     Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096);
  32.     SDL_WM_SetCaption("Kaktus MP3 Player", NULL);
  33.  
  34.     screen = SDL_SetVideoMode(340, 125, 32, SDL_SWSURFACE);
  35.     write("Screen loaded");
  36.     background = SDL_LoadBMP("images/background.bmp");
  37.     write("Background loaded");
  38.  
  39.     SDL_BlitSurface(background, NULL, screen, NULL);
  40.  
  41.     SDL_Flip(screen);
  42.  
  43.     convertFile();
  44.     write(sound);
  45.  
  46.     playSound();
  47.  
  48.     SDL_Delay(2000);
  49.  
  50.     write("Porgram exit");
  51.     exit();
  52.     Mix_CloseAudio();
  53.     SDL_Quit();
  54.     return 0;
  55. }
  56.  
  57. void playSound() {
  58.     music = Mix_LoadMUS(sound);
  59.     Mix_PlayMusic(music, -1);
  60. }
  61.  
  62. void convertFile() {
  63.  
  64. }
  65.  
  66. void exit() {
  67.     SDL_FreeSurface(background);
  68.     Mix_FreeMusic(music);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment