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

void CAudio::playPreview ( char *  filename  ) 

This method starts the audio playback at 30sec from the beginning of the track. If a track is already playing it is stopped. It also computes the length variable.

Parameters:
filename the track filename

Definition at line 91 of file audio.cpp.

References isPlaying(), and stopMusic().

{
        if (isPlaying()) 
            stopMusic();

#ifdef USE_LIBXINE_AUDIO
        int pos_stream;
      int pos_time;

        if (!xine_open(stream, filename) || !xine_play(stream, 0, 30000)) {
            printf("could not open %s\n", filename);
        }

      if( !xine_get_pos_length(stream, &pos_stream, &pos_time, &length) )
            length = LENGTH_ERROR;

        xine_playing = 1;
#endif
#ifdef USE_GSTREAMER_AUDIO
      if( filename[0] == '/' )
            g_object_set (G_OBJECT (music), "uri", g_strconcat("file://",filename,NULL), NULL);
      else
            g_object_set (G_OBJECT (music), "uri", g_strconcat("file://",get_current_dir_name(),"/",filename,NULL), NULL);
      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(music, 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
            GST_SEEK_TYPE_SET, 30*GST_SECOND,
            GST_SEEK_TYPE_SET, 60*GST_SECOND))
            g_print("playPreview() seek failed\n");
      gst_element_set_state (music, GST_STATE_PLAYING);
      GstFormat fmt = GST_FORMAT_TIME;
      gint64 len;
      if (!gst_element_query_duration (music, &fmt, &len))
            length = LENGTH_ERROR;
      else
            length = (int) (len/GST_MSECOND);
#endif
}


Generated by  Doxygen 1.6.0   Back to index