[Qt-interest] Looping Videos in QtMobility-1.0tp with QMediaPlayer?

Josiah Bryan jbryan at productiveconcepts.com
Mon Mar 8 16:58:19 CET 2010


Josiah Bryan wrote:
> dmytro.poplavskiy at nokia.com wrote:
>   
>> Hi Josiah,
>>
>> On 03/03/2010, at 2:12 PM, ext Josiah Bryan wrote:  
>>     
>>> Hey All -
>>>
>>> I've been playing with the QtMobility 1.0 (TP) - the API looks 
>>> fantastically useful! I'm quite excited about the possibilities.
>>>
>>> One key piece of functionality that I can't quite seem to figure out, 
>>> but I would heavy use of, is *looping* a video - e.g. to use as a 
>>> background beneath a presentation.
>>>       
>> One way to achieve this is to use QMediaPlaylist with
>> one of loop playback modes (CurrentItemInLoop or Loop).
>>
>> If the playback backend supports intrinsic playlist,
>> it may use this information to preload the next item 
>> or just not to stop the current one.
>> In the worst case, if playback backend doesn't provide
>> playlists functions, QMediaPlaylist will use internal local memory playlist
>> to achieve the similar behaviour ( but with possible gaps, like you currently have ).
>>     
> I created a QMediaPlayList(player), then called:
> playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
>
> However, when media reaches the end, it just stops - no looping.
> (I took out my code in the statusChanged slot for this test.)
>   
Here's a simple program that reproduces the problem:

#include <QtGui>

#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QVideoWidget>

QTM_USE_NAMESPACE

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QMediaPlayer * player = new QMediaPlayer();
    QMediaPlaylist * playlist = new QMediaPlaylist();
    playlist->setMediaObject(player);

    QVideoWidget * videoWidget = new QVideoWidget;
    videoWidget->setMediaObject(player);
   
    playlist->addMedia(QUrl::fromLocalFile("082_JumpBack.mov"));
    playlist->setCurrentIndex(0);
    playlist->setPlaybackMode(QMediaPlaylist::Loop);
   
    videoWidget->show();
    player->play();
   
    return app.exec();
}

You can download the sample loop I'm using from my server at:

http://corp.productiveconcepts.com/082_JumpBack.mov (5131 KB)

Using the phonon backend, it loops BUT with a flash of black between the 
loops. (Which is odd, since I know I can get phonon to loop almost 
perfectly when using it directly by just seeking to 0 when receiving the 
media finished signal.)
Using the gstreamer backend - it just stops dead at the end of the video 
- no looping at all.

I'm using CentOS 5.3 as my OS.

Any ideas or hints of how to make looping work with QMediaPlayer?

Thanks!
-josiah






More information about the Qt-interest-old mailing list