[vlc-devel] commit: fix the fetching of the total time of the media loaded, and small optimization when loading media (Martin T. H. Sandsmark )
git version control
git at videolan.org
Wed Jan 6 20:46:16 CET 2010
vlc | branch: master | Martin T. H. Sandsmark <sandsmark at samfundet.no> | Wed Jan 6 20:40:52 2010 +0100| [5ddff2bd707a2fd5698ad50bff52619b4bd066b6] | committer: Jean-Baptiste Kempf
fix the fetching of the total time of the media loaded, and small optimization when loading media
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ddff2bd707a2fd5698ad50bff52619b4bd066b6
---
bindings/phonon/vlc/vlcmediaobject.cpp | 17 ++++-------------
bindings/phonon/vlc/vlcmediaobject.h | 4 ----
2 files changed, 4 insertions(+), 17 deletions(-)
diff --git a/bindings/phonon/vlc/vlcmediaobject.cpp b/bindings/phonon/vlc/vlcmediaobject.cpp
index ca9760f..2097207 100644
--- a/bindings/phonon/vlc/vlcmediaobject.cpp
+++ b/bindings/phonon/vlc/vlcmediaobject.cpp
@@ -32,10 +32,6 @@ namespace Phonon
{
namespace VLC {
-// VLC returns a strange position
-// We have to multiply by VLC_POSITION_RESOLUTION
-static const int vlcPositionResolution = 1000;
-
VLCMediaObject::VLCMediaObject(QObject * parent)
: MediaObject(parent), VLCMediaController()
{
@@ -96,10 +92,6 @@ void VLCMediaObject::loadMediaInternal(const QString & filename)
b_play_request_reached = false;
- // Optimization: wait to see if play() is run just after loadMedia()
- // 100 milliseconds should be fine
- QTimer::singleShot(100, this, SLOT(loadMediaInternal()));
-
// Get meta data (artist, title, etc...)
updateMetaData();
@@ -109,10 +101,10 @@ void VLCMediaObject::loadMediaInternal(const QString & filename)
// so let's send our own events...
// This will reset the GUI
clearMediaController();
-}
-void VLCMediaObject::loadMediaInternal()
-{
+ // We need to do this, otherwise we never get any events with the real length
+ libvlc_media_get_duration(p_vlc_media, vlc_exception);
+
if (b_play_request_reached) {
// The media is playing, no need to load it
return;
@@ -198,7 +190,7 @@ void VLCMediaObject::connectToAllVLCEvents()
libvlc_MediaPlayerTimeChanged,
libvlc_MediaPlayerTitleChanged,
libvlc_MediaPlayerPositionChanged,
- libvlc_MediaPlayerSeekableChanged,
+ //libvlc_MediaPlayerSeekableChanged, //FIXME: doesn't work anymore? it asserts
libvlc_MediaPlayerPausableChanged,
};
int i_nbEvents = sizeof(eventsMediaPlayer) / sizeof(*eventsMediaPlayer);
@@ -362,7 +354,6 @@ void VLCMediaObject::libvlc_callback(const libvlc_event_t *p_event, void *p_user
// Get duration of media descriptor object item
libvlc_time_t totalTime = libvlc_media_get_duration(p_vlc_mediaObject->p_vlc_media, vlc_exception);
vlcExceptionRaised();
- totalTime = totalTime / vlcPositionResolution;
if (totalTime != p_vlc_mediaObject->i_total_time) {
p_vlc_mediaObject->i_total_time = totalTime;
diff --git a/bindings/phonon/vlc/vlcmediaobject.h b/bindings/phonon/vlc/vlcmediaobject.h
index 0972fbd..08dac29 100644
--- a/bindings/phonon/vlc/vlcmediaobject.h
+++ b/bindings/phonon/vlc/vlcmediaobject.h
@@ -99,10 +99,6 @@ protected:
qint64 currentTimeInternal() const;
-private slots:
-
- void loadMediaInternal();
-
private:
/**
More information about the vlc-devel
mailing list