[ create a new paste ] login | about

Link: http://codepad.org/ikXAzfdg    [ raw code | fork ]

D, pasted on Nov 4:
module sdl_stream;

import std.stdio;
import derelict.sdl2.sdl;
import derelict.sdl2.image;
import derelict.sdl2.mixer;
import derelict.sdl2.ttf;
import derelict.sdl2.net;

class Sdl_stream{


this(){

    // This example shows how to load all of the SDL2 libraries. You only need
    // to call the load methods for those libraries you actually need to load.

    // Load the SDL 2 library.
    DerelictSDL2.load();

    // Load the SDL2_image library.
    DerelictSDL2Image.load();

    // Load the SDL2_mixer library.
    DerelictSDL2Mixer.load();

    // Load the SDL2_ttf library
    DerelictSDL2ttf.load();

    // Load the SDL2_net library.
    DerelictSDL2Net.load();
    
    SDL_Init(SDL_INIT_EVERYTHING);
    
    if(Mix_OpenAudio(22050,MIX_DEFAULT_FORMAT,2,4096) == -1){
    writeln("Error in Opening Audio");}
    
    }
    
public void play(const char* filename){
    
    Mix_Music *music = null;
    music = Mix_LoadMUS(filename);
    
    if(music == null){
    writeln("Error locating file");
    }
    
    if(Mix_PlayingMusic() == 0){
      if(Mix_PlayMusic(music, 0) ==-1){
      writeln("Error playing file");
      }
     }
}


public void pauseTrack(){
    Mix_PauseMusic();
    }
    
public void resumeTrack(){
    Mix_ResumeMusic();
    }
}    


Create a new paste based on this one


Comments: