Beispiel #1
0
void PlayMP3File (const char *filename) {
    if (strlen(filename) >= PLAYMP3FILE_MAX_FILENAME_LEN)
        quit("!PlayMP3File: filename too long");

    debug_script_log("PlayMP3File %s", filename);

    AssetPath asset_name("", filename);

    int useChan = prepare_for_new_music ();
    bool doLoop = (play.music_repeat > 0);

    if ((channels[useChan] = my_load_static_ogg(asset_name, 150, doLoop)) != NULL) {
        channels[useChan]->play();
        current_music_type = MUS_OGG;
        play.cur_music_number = 1000;
        // save the filename (if it's not what we were supplied with)
        if (filename != &play.playmp3file_name[0])
            strcpy (play.playmp3file_name, filename);
    }
    else if ((channels[useChan] = my_load_static_mp3(asset_name, 150, doLoop)) != NULL) {
        channels[useChan]->play();
        current_music_type = MUS_MP3;
        play.cur_music_number = 1000;
        // save the filename (if it's not what we were supplied with)
        if (filename != &play.playmp3file_name[0])
            strcpy (play.playmp3file_name, filename);
    }
    else
        debug_script_warn ("PlayMP3File: file '%s' not found or cannot play", filename);

    post_new_music_check(useChan);

    update_music_volume();
}
Beispiel #2
0
void IAGSEngine::PlaySoundChannel (int32 channel, int32 soundType, int32 volume, int32 loop, const char *filename) {
  stop_and_destroy_channel (channel);
  SOUNDCLIP *newcha = NULL;

  if (((soundType == PSND_MP3STREAM) || (soundType == PSND_OGGSTREAM)) 
    && (loop != 0))
    quit("IAGSEngine::PlaySoundChannel: streamed samples cannot loop");

  if (soundType == PSND_WAVE)
    newcha = my_load_wave (filename, volume, loop);
  else if (soundType == PSND_MP3STREAM)
    newcha = my_load_mp3 (filename, volume);
  else if (soundType == PSND_OGGSTREAM)
    newcha = my_load_ogg (filename, volume);
  else if (soundType == PSND_MP3STATIC)
    newcha = my_load_static_mp3 (filename, volume, (loop != 0));
  else if (soundType == PSND_OGGSTATIC)
    newcha = my_load_static_ogg (filename, volume, (loop != 0));
  else if (soundType == PSND_MIDI) {
    if (midi_pos >= 0)
      quit("!IAGSEngine::PlaySoundChannel: MIDI already in use");
    newcha = my_load_midi (filename, loop);
    newcha->set_volume (volume);
  }
  else if (soundType == PSND_MOD) {
    newcha = my_load_mod (filename, loop);
    newcha->set_volume (volume);
  }
  else
    quit("!IAGSEngine::PlaySoundChannel: unknown sound type");

  channels[channel] = newcha;
}