How play part of a sound file?

Erik sigra at home.se
Fri Oct 5 14:08:50 BST 2007


Matthias Kretz skrev:
> Hi,
>
> first you should go to api.kde.org instead of developer.kde.org. The 
> documentation you were looking at was "Generated on Fri Oct 6 00:29:29 2006"
>
> Regarding your question: the current API is not meant for any exact timings 
> (which is also impossible with xine at least). But if close to 3000ms/8000ms 
> is good enough for you you can do the following:
>
> m_media = new MediaObject;
> AudioOutput *out = new AudioOutput(Phonon::MusicCategory, m_media);
> Phonon::createPath(m_media, out);
> m_media->setCurrentSource(...);
> m_media->pause();
> m_media->seek(3000);
> m_media->play();
> m_media->setTickInterval(100);
> connect(m_media, SIGNAL(tick(qint64)), SLOT(tick(qint64)));
>
> .
> .
> .
>
> void tick(qint64 position)
> {
>   if (position > 7900) {
>     m_media->stop();
>   }
> }
>   
I was hoping for a cleaner solution. If it is not possible to specify
the time interval when playing the sound, maybe there is a way to
specify it when loading it? (In your example, in your example, something
like "setCurrentSource(path, time_interval)").

> On Friday 05 October 2007, Erik wrote:
>   
>> I need to play a part of a sound file, for example from 3000 ms to 8000
>> ms. I looked at the documentation at
>> [http://developer.kde.org/documentation/library/cvs-api/kdelibs-apidocs/pho
>> non/html/classPhonon_1_1AudioPlayer.html] without finding what I was looking
>> for. There is "void seek (qint64 ms)", so I suppose I could call
>> "seek(3000); play()" but that does not tell it to stop at 8000 ms.



More information about the kde-multimedia mailing list