PDA

View Full Version : phonon VideoPlayer seek



rbp
30th October 2008, 06:53
hello,

I am trying to load a video with VideoPlayer and start playing from a
certain point. Here is the relevant code:

video = new Phonon::VideoPlayer(Phonon::VideoCategory);
video->play(Phonon::MediaSource(filename));
video->seek(frame);

However the seek here is ignored and the video will always plays from the start.
If I try seeking at other times it does work, so does that mean I can only seek in an already loaded video? If so, how do I detect when the video is loaded? - VideoPlayer does not send any useful signals

Richard

wysota
30th October 2008, 09:02
Note that the backend is free to ignore the seek request if the media source isn't seekable

The source won't be seekable until its frame index is fully loaded which probably takes a second or so. I suggest you connect to MediaObject::seekableChanged() signal and when it fires, seek to the proper place.

rbp
31st October 2008, 00:36
Thanks wysota, I didn't notice the MediaSource signals.
I saw that part you quoted in the documentation but assumed it was referring to certain file types not being seekable.

Richard

rbp
31st October 2008, 01:08
strangely I'm getting an error when connecting the signal:


connect(video->mediaObject(), SIGNAL(seekableChanged(bool)), this, SLOT(seekAnimation(bool)));


error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'Phonon::MediaObject *' to 'const QObject *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast


MediaObject inherits from QOjbect and I've seen examples (http://api.kde.org/extragear-api/graphics-apidocs/digikam/html/mediaplayerview_8cpp-source.html) around the internet using just this syntax.
Can you see why? If it matters, I'm using VS2008 and Qt 4.4.2.

rbp
31st October 2008, 05:53
I tried including the header and now it all works:

#include <phonon/mediaobject.h>