author | llornkcor <llornkcor> | 2002-03-19 12:15:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-03-19 12:15:24 (UTC) |
commit | 58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5 (patch) (side-by-side diff) | |
tree | 6f58918f36e66d026d4bbb67574f2d195f15b6ad | |
parent | 7a4ff15ff356a484a498249f01354dce549eaec2 (diff) | |
download | opie-58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5.zip opie-58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5.tar.gz opie-58a456b92ba8986d4ea2375ddcfd6dd1d84c8fe5.tar.bz2 |
reverted back till I figure out
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.h | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 30 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mpegplayer.pro | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 8 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 173 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 1 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 19 |
8 files changed, 158 insertions, 80 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 3901446..cda3f77 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -217,26 +217,28 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { bool isOnButton = dist <= (radius * radius); // QRect r( x, y, 64 + 22*size, 64 + 22*size ); // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); - qDebug("button toggled %d",i); + qDebug("button toggled1 %d",i); switch (i) { case AudioVolumeUp: emit moreClicked(); return; case AudioVolumeDown: emit lessClicked(); return; } } else if ( !isOnButton && audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; toggleButton(i); + qDebug("button toggled2 %d",i); } } else { if ( audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; if ( !audioButtons[i].isToggle ) setToggleButton( i, FALSE ); + qDebug("button toggled3 %d",i); switch (i) { case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; case AudioStop: mediaPlayerState->setPlaying(FALSE); return; case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; case AudioNext: mediaPlayerState->setNext(); return; case AudioPrevious: mediaPlayerState->setPrev(); return; diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h index a2850aa..d1d72b6 100644 --- a/core/multimedia/opieplayer/audiowidget.h +++ b/core/multimedia/opieplayer/audiowidget.h @@ -14,12 +14,13 @@ ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ + #ifndef AUDIO_WIDGET_H #define AUDIO_WIDGET_H #include <qwidget.h> #include <qpainter.h> #include <qdrawutil.h> diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 4b2827e..b9f96de 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -16,13 +16,12 @@ ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ // L.J.Potter added changes Fri 02-15-2002 - #include <qpe/qpeapplication.h> #ifdef Q_WS_QWS #include <qpe/qcopenvelope_qws.h> #endif #include <stdio.h> @@ -218,12 +217,13 @@ void LoopControl::startVideo() { } } void LoopControl::startAudio() { +//qDebug("start audio"); audioMutex->lock(); if ( moreAudio ) { if ( !isMuted && mediaPlayerState->curDecoder() ) { currentSample = audioSampleCounter + 1; @@ -233,20 +233,20 @@ void LoopControl::startAudio() { long samplesRead = 0; bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; long sampleWaitTime = currentSample - sampleWeShouldBeAt; -// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { -// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); -// } -// else if ( sampleWaitTime <= -5000 ) { -// // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); -// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); -// currentSample = sampleWeShouldBeAt; -// } +// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { +// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); +// } +// else if ( sampleWaitTime <= -5000 ) { +// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); +// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); +// currentSample = sampleWeShouldBeAt; +// } audioDevice->write( audioBuffer, samplesRead * 2 * channels ); audioSampleCounter = currentSample + samplesRead - 1; moreAudio = readOk && (audioSampleCounter <= total_audio_samples); @@ -375,33 +375,31 @@ bool LoopControl::init( const QString& filename ) { hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; if ( hasAudioChannel ) { int astream = 0; channels = mediaPlayerState->curDecoder()->audioChannels( astream ); -// qDebug( "LC- channels = %d", channels ); + qDebug( "LC- channels = %d", channels ); if ( !total_audio_samples ) total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); // total_audio_samples += 1000; mediaPlayerState->setLength( total_audio_samples ); freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); -// qDebug( "LC- frequency = %d", freq ); + qDebug( "LC- frequency = %d", freq ); audioSampleCounter = 0; int bits_per_sample; - if ( mediaPlayerState->curDecoder()->pluginName() == QString("WavPlugin") ) { + if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); -// qDebug("using stupid hack"); + qDebug("using stupid hack"); } else { - bits_per_sample=0; -// freq=44100; - channels=2; + bits_per_sample=0; } audioDevice = new AudioDevice( freq, channels, bits_per_sample); audioBuffer = new char[ audioDevice->bufferSize() ]; channels = audioDevice->channels(); diff --git a/core/multimedia/opieplayer/mpegplayer.pro b/core/multimedia/opieplayer/mpegplayer.pro index b9e9ffe..241e29e 100644 --- a/core/multimedia/opieplayer/mpegplayer.pro +++ b/core/multimedia/opieplayer/mpegplayer.pro @@ -19,8 +19,8 @@ LIBS += -lqpe -lpthread # LIBS += libmpeg3/libmpeg3.a -lpthread # LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include -TRANSLATIONS = ../i18n/de/mpegplayer.ts +TRANSLATIONS += ../i18n/de/mpegplayer.ts TRANSLATIONS += ../i18n/pt_BR/mpegplayer.ts diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 991301a..756e3b4 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -52,13 +52,13 @@ PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) { qDebug("starting playlistselector"); // #ifdef USE_PLAYLIST_BACKGROUND // setStaticBackground( TRUE ); // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); - setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); +// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); // #endif // addColumn("Title",236); // setAllColumnsShowFocus( TRUE ); addColumn( tr( "Playlist Selection" ) ); header()->hide(); setSorting( -1, FALSE ); @@ -70,15 +70,15 @@ PlayListSelection::~PlayListSelection() { // #ifdef USE_PLAYLIST_BACKGROUND void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { // qDebug("drawBackground"); p->fillRect( r, QBrush( white ) ); - QImage logo = Resource::loadImage( "launcher/opielogo" ); - if ( !logo.isNull() ) - p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); +// QImage logo = Resource::loadImage( "launcher/opielogo" ); +// if ( !logo.isNull() ) +// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); } // #endif void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { if ( event->state() == QMouseEvent::LeftButton ) { diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 524747e..cf665c8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -103,12 +103,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { d = new PlayListWidgetPrivate; d->setDocumentUsed = FALSE; d->current = NULL; fromSetDocument = FALSE; + insanityBool=FALSE; // menuTimer = new QTimer( this ,"menu timer"), // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); setBackgroundMode( PaletteButton ); setCaption( tr("OpiePlayer") ); @@ -203,15 +204,15 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch QWidget *aTab; aTab = new QWidget( tabWidget, "aTab" ); audioView = new QListView( aTab, "Audioview" ); audioView->setMinimumSize(233,260); - audioView->addColumn( "Title",150); - audioView->addColumn("Size", 45); - audioView->addColumn("Media",35); + audioView->addColumn( "Title",140); + audioView->addColumn("Size", -1); + audioView->addColumn("Media",-1); audioView->setColumnAlignment(1, Qt::AlignRight); audioView->setColumnAlignment(2, Qt::AlignRight); audioView->setAllColumnsShowFocus(TRUE); tabWidget->insertTab(aTab,"Audio"); QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); @@ -238,15 +239,15 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QWidget *vTab; vTab = new QWidget( tabWidget, "vTab" ); videoView = new QListView( vTab, "Videoview" ); videoView->setMinimumSize(233,260); - videoView->addColumn("Title",150); - videoView->addColumn("Size",45); - videoView->addColumn("Media",35); + videoView->addColumn("Title",140); + videoView->addColumn("Size",-1); + videoView->addColumn("Media",-1); videoView->setColumnAlignment(1, Qt::AlignRight); videoView->setColumnAlignment(2, Qt::AlignRight); videoView->setAllColumnsShowFocus(TRUE); QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); @@ -483,44 +484,56 @@ const DocLnk *PlayListWidget::current() { // this is fugly // if(dit.current()->linkFile() == setDocFileRef) { // qDebug(setDocFileRef); // return dit; // } // } // } else - switch (tabWidget->currentPageIndex()) { - case 0: //playlist - { - if ( mediaPlayerState->playlist() ) { - return d->selectedFiles->current(); - } - else if ( d->setDocumentUsed && d->current ) { - return d->current; - } else { - return d->files->selected(); - } +// qDebug("current"); +// switch (tabWidget->currentPageIndex()) { +// case 0: //playlist +// { + qDebug("playlist"); + if ( mediaPlayerState->playlist() ) { + return d->selectedFiles->current(); } - break; - case 1: { //audio - Global::findDocuments(&files, "audio/*"); - QListIterator<DocLnk> dit( files.children() ); - for ( ; dit.current(); ++dit ) { - if( dit.current()->name() == audioView->currentItem()->text(0)) - return dit; - } - } - break; - case 2: { // video - Global::findDocuments(&vFiles, "video/*"); - QListIterator<DocLnk> Vdit( vFiles.children() ); - for ( ; Vdit.current(); ++Vdit ) { - if( Vdit.current()->name() == videoView->currentItem()->text(0)) - return Vdit; - } + else if ( d->setDocumentUsed && d->current ) { + return d->current; + } else { + return d->files->selected(); } - break; - }; +// } +// break; +// case 1://audio +// { +// qDebug("audioView"); +// Global::findDocuments(&files, "audio/*"); +// QListIterator<DocLnk> dit( files.children() ); +// for ( ; dit.current(); ++dit ) { +// if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { +// qDebug("here"); +// insanityBool=TRUE; +// return dit; +// } +// } +// } +// break; +// case 2: // video +// { +// qDebug("videoView"); +// Global::findDocuments(&vFiles, "video/*"); +// QListIterator<DocLnk> Vdit( vFiles.children() ); +// for ( ; Vdit.current(); ++Vdit ) { +// if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { +// insanityBool=TRUE; +// return Vdit; +// } +// } +// } +// break; +// }; +// return 0; } bool PlayListWidget::prev() { if ( mediaPlayerState->playlist() ) { if ( mediaPlayerState->shuffled() ) { const DocLnk *cur = current(); @@ -651,24 +664,55 @@ void PlayListWidget::setView( char view ) { else hide(); } void PlayListWidget::addSelected() { - switch (tabWidget->currentPageIndex()) { - case 0: //playlist - break; - case 1: { //audio - addToSelection( audioView->selectedItem() ); - } - break; - case 2: { // video - addToSelection( videoView->selectedItem() ); - } - break; - }; + Config cfg( "MediaPlayer" ); + cfg.setGroup("PlayList"); + QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); + int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); + + switch (tabWidget->currentPageIndex()) { + case 0: //playlist + break; + case 1: { //audio + for ( int i = 0; i < noOfFiles; i++ ) { + QString entryName; + entryName.sprintf( "File%i", i + 1 ); + QString linkFile = cfg.readEntry( entryName ); + if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { + int result= QMessageBox::warning(this,"OpiePlayer", + tr("This is all ready in your playlist.\nContinue?"), + tr("Yes"),tr("No"),0,0,1); + if (result !=0) + return; + } + } + addToSelection( audioView->selectedItem() ); + tabWidget->setCurrentPage(1); + } + break; + case 2: { // video + for ( int i = 0; i < noOfFiles; i++ ) { + QString entryName; + entryName.sprintf( "File%i", i + 1 ); + QString linkFile = cfg.readEntry( entryName ); + if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { + int result= QMessageBox::warning(this,"OpiePlayer", + tr("This is all ready in your playlist.\nContinue?"), + tr("Yes"),tr("No"),0,0,1); + if (result !=0) + return; + } + } + addToSelection( videoView->selectedItem() ); + tabWidget->setCurrentPage(2); + } + break; + }; } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } @@ -752,13 +796,44 @@ void PlayListWidget::tabChanged(QWidget *widg) { } /* play button is pressed*/ void PlayListWidget::btnPlay(bool b) { - mediaPlayerState->setPlaying(b); +// mediaPlayerState->setPlaying(b); + switch ( tabWidget->currentPageIndex()) { + case 0: + { + mediaPlayerState->setPlaying(b); + } + break; + case 1: + { + addToSelection( audioView->selectedItem() ); + mediaPlayerState->setPlaying(b); +// qApp->processEvents(); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(1); +// mediaPlayerState->setPlaying(FALSE); + } + break; + case 2: + { + addToSelection( videoView->selectedItem() ); + mediaPlayerState->setPlaying(b); + qApp->processEvents(); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(2); +// mediaPlayerState->setPlaying(FALSE); + } + break; + }; + + + + } void PlayListWidget::deletePlaylist() { switch( QMessageBox::information( this, (tr("Remove Playlist?")), (tr("You really want to delete\nthis playlist?")), (tr("Yes")), (tr("No")), 0 )){ diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index effc600..10a42df 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h @@ -46,12 +46,13 @@ public: QAction *fullScreenButton, *scaleButton; DocLnkSet files; DocLnkSet vFiles; QListView *audioView, *videoView, *playlistView; QLabel *libString; bool fromSetDocument; + bool insanityBool; QString setDocFileRef; // retrieve the current playlist entry (media file link) const DocLnk *current(); void useSelectedDocument(); /* QTimer * menuTimer; */ FileSelector* playLists; diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index bb5f9e8..23b36e5 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp @@ -200,23 +200,24 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { } } else { if ( videoButtons[i].isHeld ) { videoButtons[i].isHeld = FALSE; if ( !videoButtons[i].isToggle ) setToggleButton( i, FALSE ); - switch (i) { - case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; - case VideoStop: mediaPlayerState->setPlaying(FALSE); return; - case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; - case VideoNext: mediaPlayerState->setNext(); return; - case VideoPrevious: mediaPlayerState->setPrev(); return; - case VideoPlayList: mediaPlayerState->setList(); return; - case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; - } } } + switch (i) { + case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; + case VideoStop: mediaPlayerState->setPlaying(FALSE); return; + case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; + case VideoNext: mediaPlayerState->setNext(); return; + case VideoPrevious: mediaPlayerState->setPrev(); return; + case VideoPlayList: mediaPlayerState->setList(); return; + case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; + } + } } void VideoWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); |