Logo Search packages:      
Sourcecode: ultrastar-ng version File versions  Download package

void CAudio::seek ( int  seek_dist  ) 

This methods seek forward in the stream (backwards if argument is negative), and continues playing.

Parameters:
seek_dist number of milliseconds to seek from current position

Definition at line 258 of file audio.cpp.

References getLength(), getPosition(), and isPlaying().

                                {
      if (isPlaying()){
            int position = getPosition()+seek_dist;
            if ( position < 0) position = 0;
            if ( position > getLength() - 1000){
                  fprintf(stdout,"seeking too far ahead\n");
                  return;
            }
            fprintf(stdout,"seeking from %d to %d\n",getPosition(),position);
#ifdef USE_LIBXINE_AUDIO
            xine_play(stream,0,position);
#endif
#ifdef USE_GSTREAMER_AUDIO
            gst_element_set_state (music, GST_STATE_PAUSED);
            GstState state_paused = GST_STATE_PAUSED;
            gst_element_get_state (music, NULL, &state_paused, GST_CLOCK_TIME_NONE);
            if( !gst_element_seek_simple(music, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, position*GST_MSECOND))
                  g_print("playPreview() seek failed\n");
            gst_element_set_state (music, GST_STATE_PLAYING);
#endif
      }
}


Generated by  Doxygen 1.6.0   Back to index