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

Josiah Bryan jbryan at productiveconcepts.com
Wed Mar 3 13:48:16 CET 2010


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.)
>   
>> In my test program, I setup a QMediaPlayer and QVideoWidget like this:
>>
>> player = new QMediaPlayer(this);
>> connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
>>        this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
>> videoWidget = new QVideoWidget;
>> videoWidget->setMediaObject(player);
>> media = QUrl::fromLocalFile("/data/video/loops/082_JumpBack.mov");
>> player->setMedia(media);
>> player->play();
>>
>> ...and in my statusChanged(QMediaPlayer::MediaStatus) slot, when I get 
>> the EndOfMedia status, I've tried:
>>     
>
> I think just player->play() should be enough, 
> it's a bug in the current backend implementation.
>   
After trying setPlaybackMode, I went back and tried just player->play() 
- didn't do anything.
> Btw what OS are you using?
>   
Linux - CentOS 5.3, running KDE.

Using gstreamer backend.

Thanks!
-Josiah




More information about the Qt-interest-old mailing list