[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kdelibs-phonon/phonon
From:       Matthias Kretz <kretz () kde ! org>
Date:       2006-01-18 22:40:23
Message-ID: 1137624023.057873.16119.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 499873 by mkretz:

fixed bug because it was so easy ;-)
When restoring an AbstractMediaProducer use two new slots to resume the playing
or paused state. Both then will call seek to restore the right position again.


 M  +3 -1      BUGS  
 M  +17 -8     abstractmediaproducer.cpp  
 M  +4 -0      abstractmediaproducer.h  
 M  +11 -1     mediaobject.cpp  


--- branches/work/kdelibs-phonon/phonon/BUGS #499872:499873
@@ -1 +1,3 @@
-calling a phononBackendChange doesn't restore the right position in the MediaObject
+When the backend changes there's a drop in the playback. When it's in
+PlayingState it could time how long it takes until the playback resumes and add
+that time to the seek.
--- branches/work/kdelibs-phonon/phonon/abstractmediaproducer.cpp #499872:499873
@@ -156,10 +156,6 @@
 	// set up attributes
 	m_iface->setTickInterval( d->tickInterval );
 
-	// FIXME: seeking probably only works in PlayingState
-	if( d->currentTime > 0 )
-		m_iface->seek( d->currentTime );
-
 	foreach( AudioPath* a, d->audioPaths )
 		m_iface->addAudioPath( a->iface() );
 	foreach( VideoPath* v, d->videoPaths )
@@ -173,17 +169,30 @@
 			break;
 		case PlayingState:
 		case BufferingState:
-			QTimer::singleShot( 0, this, SLOT( play() ) );
+			QTimer::singleShot( 0, this, SLOT( resumePlay() ) );
 			break;
 		case PausedState:
-			// FIXME: Going from StoppedState or even LoadingState into
-			// PausedState is not going to work.
-			QTimer::singleShot( 0, this, SLOT( pause() ) );
+			QTimer::singleShot( 0, this, SLOT( resumePause() ) );
 			break;
 	}
 	d->state = m_iface->state();
 }
 
+void AbstractMediaProducer::resumePlay()
+{
+	m_iface->play();
+	if( d->currentTime > 0 )
+		m_iface->seek( d->currentTime );
+}
+
+void AbstractMediaProducer::resumePause()
+{
+	m_iface->play();
+	if( d->currentTime > 0 )
+		m_iface->seek( d->currentTime );
+	m_iface->pause();
+}
+
 } //namespace Phonon
 
 #include "abstractmediaproducer.moc"
--- branches/work/kdelibs-phonon/phonon/abstractmediaproducer.h #499872:499873
@@ -207,6 +207,10 @@
 			 * \see setTickInterval, tickInterval
 			 */
 			void tick( long time );
+
+		private slots:
+			void resumePlay();
+			void resumePause();
 	};
 } //namespace Phonon
 
--- branches/work/kdelibs-phonon/phonon/mediaobject.cpp #499872:499873
@@ -60,7 +60,16 @@
 void MediaObject::setUrl( const KURL& url )
 {
 	if( iface() )
+	{
 		m_iface->setUrl( url );
+		if( state() == Phonon::ErrorState )
+		{
+			deleteIface();
+			//TODO: at this point MediaObject should try to use an Ifaces::ByteStream
+			//instead and send the data it receives from a KIO Job via writeBuffer.
+			//This essentially makes all media frameworks read data via KIO...
+		}
+	}
 	else
 		d->url = url;
 }
@@ -96,7 +105,8 @@
 	connect( m_iface->qobject(), SIGNAL( length( long ) ), SIGNAL( length( long ) ) );
 
 	// set up attributes
-	m_iface->setUrl( d->url );
+	if( !d->url.isEmpty() )
+		m_iface->setUrl( d->url );
 	if( state() == Phonon::ErrorState )
 	{
 		deleteIface();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic