How to play a file repeatedly?

David Jarvie lists at astrojar.org.uk
Fri Mar 12 13:11:40 GMT 2004


I want to play a sound file repeatedly, starting it again as soon as it has 
finished playing. I have got it working by calling the following code each 
time it finishes playing:

        KArtsServer aserver;
        KDE::PlayObjectFactory factory(aserver.server());
        mPlayObject = factory.createPlayObject(audioFile, true);
        connect(mPlayObject, SIGNAL(playObjectCreated()), 
SLOT(checkAudioPlay()));
        if (!mPlayObject->object().isNull())
                checkAudioPlay();

and in the checkAudioPlay() method,

        mPlayObject->play();

However, this reloads the file every time, which in the case of a network file 
is an undesirable overhead. I tried the following when the play was complete:

	Arts::poTime t0((long)0, (long)0, 0, string());
        Arts::poTime current = mPlayObject->currentTime();
        if (current.seconds || current.ms)
                mPlayObject->seek(t0);
        else
                mPlayObject->play();

but it results in a long gap (typically 5 seconds) between plays, which for a 
very short sound file is unacceptable.

How can I play a file repeatedly without gaps and without reloading each time?

--
David Jarvie.



More information about the kde-multimedia mailing list