Play audio

The simpliest way :

Here the simpliest way to play an audio file. You just open the file and load it in the waave engine :

  /* open the audio file */ 
  WVStream* stream = WV_getStream(filename);
  
  /* check file type */
  int streamType = WV_getStreamType(stream);
  if(streamType != WV_STREAM_TYPE_AUDIO)
    return 0; //not an audio file
  
  /* load */
  WV_loadStream(stream);

You can now play, pause ..., the stream when you want :

  /* play */
  WV_playStream(stream);

Set playing methods :

Before loading the stream you can set playing attibutes.

Play only the audio of a movie :

  /* check file type */
  int streamType = WV_getStreamType(stream);
  if(streamType == WV_STREAM_TYPE_AUDIOVIDEO)
    WV_disableVideo(stream);
  

Loop playing :

  /* enable looping play */
  WV_setEOFMethod(stream, WV_LOOPING_STREAM);
  
  /* disable looping play */
  WV_setEOFMethod(stream, WV_BLOCKING_STREAM);
  

Set seeking behavior :

  /* if the stream is paused, seek cause restart playing */
  WV_setSeekMethod(stream, WV_PLAYING_SEEK);

  /* if the stream is paused, it stay paused after the seek */
  WV_setSeekMethod(stream, WV_BLOCKING_SEEK);

Set play behavior :

  /* if play command is sended while the stream is playing, it do nothing */
  WV_setPlayMethod(stream, WV_NEUTRAL_PLAY);

  /* if play command is sended while the stream is playing, it restart at the beginning */
  WV_setPlayMethod(stream, WV_LOOPING_PLAY);

The End Of File event :

You will receive an WV_EOF_EVENT when the end of a stream is reached. To know to witch stream the event refer see the event.user.data1 field.

  /* check event */
  switch( event.type ) {
  
  case SDL_EOF_EVENT:
    endedStream = event.user.data1;
    // do whant you want 
    break;

    ...
  }