25 files changed, 505 insertions, 285 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 9a10eb4..5fef792 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -184,23 +184,24 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, } AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { - d = new AudioDevicePrivate; + qDebug("creating new audio device"); + d = new AudioDevicePrivate; d->frequency = f; d->channels = chs; d->bytesPerSample = bps; -// qDebug("%d",bps); + qDebug("%d",bps); int format=0; if( bps == 8) format = AFMT_U8; else if( bps <= 0) format = AFMT_S16_LE; else format = AFMT_S16_LE; -// qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); + qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); int fragments = 0x10000 * 8 + sound_fragment_shift; int capabilities = 0; diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp new file mode 100644 index 0000000..b443747 --- a/dev/null +++ b/core/multimedia/opieplayer/inputDialog.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'inputDialog.ui' +** +** Created: Sat Mar 2 07:55:03 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "inputDialog.h" + +#include <qlineedit.h> +#include <qlayout.h> +#include <qvariant.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +/* + * Constructs a InputDialog which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + if ( !name ) + setName( "InputDialog" ); + resize( 234, 50 ); + setMaximumSize( QSize( 240, 50 ) ); + setCaption( tr(name ) ); + + LineEdit1 = new QLineEdit( this, "LineEdit1" ); + LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +InputDialog::~InputDialog() +{ + inputText= LineEdit1->text(); + +} + diff --git a/core/multimedia/opieplayer/inputDialog.h b/core/multimedia/opieplayer/inputDialog.h new file mode 100644 index 0000000..26d5cd0 --- a/dev/null +++ b/core/multimedia/opieplayer/inputDialog.h @@ -0,0 +1,31 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'inputDialog.ui' +** +** Created: Sat Mar 2 07:54:46 2002 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef INPUTDIALOG_H +#define INPUTDIALOG_H + +#include <qvariant.h> +#include <qdialog.h> +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QLineEdit; + +class InputDialog : public QDialog +{ + Q_OBJECT + +public: + InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~InputDialog(); + QString inputText; + QLineEdit* LineEdit1; + +}; + +#endif // INPUTDIALOG_H diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index d163458..b240b77 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h @@ -18,14 +18,14 @@ ** **********************************************************************/ #ifndef LIBMAD_PLUGIN_H #define LIBMAD_PLUGIN_H #include <qstring.h> -//#include <qpe/mediaplayerplugininterface.h> -#include "../mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> +/* #include "../mediaplayerplugininterface.h" */ // #define OLD_MEDIAPLAYER_API class LibMadPluginData; @@ -50,13 +50,13 @@ public: // If decoder doesn't support audio then return 0 here int audioStreams(); int audioChannels( int stream ); int audioFrequency( int stream ); int audioSamples( int stream ); bool audioSetSample( long sample, int stream ); - int audioBitsPerSample(int) {return 0;} +/* int audioBitsPerSample(int) {return 0;} */ long audioGetSample( int stream ); #ifdef OLD_MEDIAPLAYER_API bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); bool audioReadSamples( short *output, int channel, long samples, int stream ); bool audioReReadSamples( short *output, int channel, long samples, int stream ); diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp b/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp index 028c658..67779e8 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.cpp @@ -27,20 +27,20 @@ LibMadPluginImpl::LibMadPluginImpl() } LibMadPluginImpl::~LibMadPluginImpl() { if ( libmadplugin ) - delete libmadplugin; + delete libmadplugin; } MediaPlayerDecoder *LibMadPluginImpl::decoder() { if ( !libmadplugin ) - libmadplugin = new LibMadPlugin; + libmadplugin = new LibMadPlugin; return libmadplugin; } MediaPlayerEncoder *LibMadPluginImpl::encoder() { @@ -51,14 +51,14 @@ MediaPlayerEncoder *LibMadPluginImpl::encoder() #ifndef QT_NO_COMPONENT QRESULT LibMadPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; - if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) - *iface = this, (*iface)->addRef(); + if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) + *iface = this, (*iface)->addRef(); return QS_OK; } Q_EXPORT_INTERFACE() { diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h index bc864ee..9b35b90 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h @@ -17,14 +17,14 @@ ** not clear to you. ** **********************************************************************/ #ifndef LIBMAD_PLUGIN_IMPL_H #define LIBMAD_PLUGIN_IMPL_H -//#include <qpe/mediaplayerplugininterface.h> -#include "../mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> +//#include "../mediaplayerplugininterface.h" class LibMadPlugin; class LibMadPluginImpl : public MediaPlayerPluginInterface diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h index bd31706..b573e84 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h @@ -21,14 +21,13 @@ #define LIBMPEG3_PLUGIN_H #include <qstring.h> #include <qapplication.h> #include "libmpeg3.h" #include "mpeg3protos.h" -//#include <qpe/mediaplayerplugininterface.h> -#include "../mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> // #define OLD_MEDIAPLAYER_API class LibMpeg3Plugin : public MediaPlayerDecoder { @@ -48,13 +47,13 @@ public: const QString &fileInfo() { return strInfo = ""; } // If decoder doesn't support audio then return 0 here int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } - int audioBitsPerSample(int) { return 0;} +/* int audioBitsPerSample(int) { return 0;} */ int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } #ifdef OLD_MEDIAPLAYER_API bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); @@ -71,21 +70,21 @@ public: double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; } int videoFrames( int stream ) { return file ? mpeg3_video_frames( file, stream ) : 0; } /* { if ( file ) { - int frames = mpeg3_video_frames( file, stream ); - if ( frames == 1 ) { - int res = mpeg3_seek_percentage( file, 0.99 ); - printf("res: %i\n", res ); - mpeg3video_seek( file->vtrack[stream]->video ); - frames = mpeg3_get_frame( file, stream ); - mpeg3_seek_percentage( file, 0.0 ); - } - return frames; + int frames = mpeg3_video_frames( file, stream ); + if ( frames == 1 ) { + int res = mpeg3_seek_percentage( file, 0.99 ); + printf("res: %i\n", res ); + mpeg3video_seek( file->vtrack[stream]->video ); + frames = mpeg3_get_frame( file, stream ); + mpeg3_seek_percentage( file, 0.0 ); + } + return frames; } return 0; } */ bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; } long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; } diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp index e7216af..bf3f372 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp @@ -27,20 +27,20 @@ LibMpeg3PluginImpl::LibMpeg3PluginImpl() } LibMpeg3PluginImpl::~LibMpeg3PluginImpl() { if ( libmpeg3plugin ) - delete libmpeg3plugin; + delete libmpeg3plugin; } MediaPlayerDecoder *LibMpeg3PluginImpl::decoder() { if ( !libmpeg3plugin ) - libmpeg3plugin = new LibMpeg3Plugin; + libmpeg3plugin = new LibMpeg3Plugin; return libmpeg3plugin; } MediaPlayerEncoder *LibMpeg3PluginImpl::encoder() { @@ -51,14 +51,14 @@ MediaPlayerEncoder *LibMpeg3PluginImpl::encoder() #ifndef QT_NO_COMPONENT QRESULT LibMpeg3PluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; - if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) - *iface = this, (*iface)->addRef(); + if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) + *iface = this, (*iface)->addRef(); return QS_OK; } Q_EXPORT_INTERFACE() { diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h index a2f5211..ef3743e 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h @@ -17,14 +17,14 @@ ** not clear to you. ** **********************************************************************/ #ifndef LIBMPEG3_PLUGIN_IMPL_H #define LIBMPEG3_PLUGIN_IMPL_H -//#include <qpe/mediaplayerplugininterface.h> -#include "../mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> +//#include "../mediaplayerplugininterface.h" class LibMpeg3Plugin; class LibMpeg3PluginImpl : public MediaPlayerPluginInterface diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 90a7cc6..cb8de8a 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -31,13 +31,13 @@ #include <pthread.h> #include <errno.h> #include <unistd.h> #include "loopcontrol.h" #include "videowidget.h" #include "audiodevice.h" -#include "mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> #include "mediaplayerstate.h" extern VideoWidget *videoUI; // now only needed to tell it to play a frame extern MediaPlayerState *mediaPlayerState; @@ -98,13 +98,13 @@ Mutex *audioMutex; LoopControl::LoopControl( QObject *parent, const char *name ) : QObject( parent, name ) { isMuted = FALSE; connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); - +//qDebug("starting loopcontrol"); audioMutex = new Mutex; pthread_attr_init(&audio_attr); #define USE_REALTIME_AUDIO_THREAD #ifdef USE_REALTIME_AUDIO_THREAD // Attempt to set it to real-time round robin @@ -115,12 +115,13 @@ LoopControl::LoopControl( QObject *parent, const char *name ) } else { qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); pthread_attr_destroy(&audio_attr); pthread_attr_init(&audio_attr); } #endif +//qDebug("create audio thread"); pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); } LoopControl::~LoopControl() { stop(); @@ -217,14 +218,14 @@ void LoopControl::startVideo() { } } void LoopControl::startAudio() { +//qDebug("start audio"); audioMutex->lock(); - if ( moreAudio ) { if ( !isMuted && mediaPlayerState->curDecoder() ) { currentSample = audioSampleCounter + 1; @@ -233,20 +234,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); @@ -388,14 +389,19 @@ bool LoopControl::init( const QString& filename ) { mediaPlayerState->setLength( total_audio_samples ); freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); qDebug( "LC- frequency = %d", freq ); audioSampleCounter = 0; - - int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); + int bits_per_sample; + if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { + bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); + qDebug("using stupid hack"); + } else { + bits_per_sample=0; + } audioDevice = new AudioDevice( freq, channels, bits_per_sample); audioBuffer = new char[ audioDevice->bufferSize() ]; channels = audioDevice->channels(); //### must check which frequency is actually used. @@ -434,13 +440,13 @@ bool LoopControl::init( const QString& filename ) { return TRUE; } void LoopControl::play() { - + qDebug("LC- play"); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { disabledSuspendScreenSaver = TRUE; previousSuspendMode = hasVideoChannel; // Stop the screen from blanking and power saving state QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp index 720a1ca..4f43ff6 100644 --- a/core/multimedia/opieplayer/main.cpp +++ b/core/multimedia/opieplayer/main.cpp @@ -44,13 +44,13 @@ int main(int argc, char **argv) { VideoWidget vw( 0, "videoUI" ); videoUI = &vw; LoopControl lc( 0, "loopControl" ); loopControl = &lc; MediaPlayer mp( 0, "mediaPlayer" ); - pl.setCaption( MediaPlayer::tr("Media Player") ); + pl.setCaption( MediaPlayer::tr("OpiePlayer") ); a.showMainDocumentWidget(&pl); return a.exec(); } diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index ce42c2c..c971a3c 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp @@ -45,14 +45,14 @@ extern MediaPlayerState *mediaPlayerState; MediaPlayer::MediaPlayer( QObject *parent, const char *name ) : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); - connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); - connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); + connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); + connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); } @@ -62,99 +62,94 @@ MediaPlayer::~MediaPlayer() { } void MediaPlayer::pauseCheck( bool b ) { // Only pause if playing if ( b && !mediaPlayerState->playing() ) - mediaPlayerState->setPaused( FALSE ); + mediaPlayerState->setPaused( FALSE ); } void MediaPlayer::play() { mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } void MediaPlayer::setPlaying( bool play ) { - if ( !play ) { - mediaPlayerState->setPaused( FALSE ); - loopControl->stop( FALSE ); - return; + mediaPlayerState->setPaused( FALSE ); + loopControl->stop( FALSE ); + return; } if ( mediaPlayerState->paused() ) { - mediaPlayerState->setPaused( FALSE ); - return; + mediaPlayerState->setPaused( FALSE ); + return; } const DocLnk *playListCurrent = playList->current(); - if ( playListCurrent != NULL ) { - loopControl->stop( TRUE ); - currentFile = playListCurrent; + loopControl->stop( TRUE ); + currentFile = playListCurrent; } - if ( currentFile == NULL ) { - QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); - mediaPlayerState->setPlaying( FALSE ); - return; + QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) ); + mediaPlayerState->setPlaying( FALSE ); + return; } - if ( !QFile::exists( currentFile->file() ) ) { - QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); - mediaPlayerState->setPlaying( FALSE ); - return; + QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); + mediaPlayerState->setPlaying( FALSE ); + return; } if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { - QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); - mediaPlayerState->setPlaying( FALSE ); - return; + QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); + mediaPlayerState->setPlaying( FALSE ); + return; } if ( !loopControl->init( currentFile->file() ) ) { - QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); - mediaPlayerState->setPlaying( FALSE ); - return; + QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" ); + mediaPlayerState->setPlaying( FALSE ); + return; } - long seconds = loopControl->totalPlaytime(); QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); QString tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; QString fileInfo = mediaPlayerState->curDecoder()->fileInfo(); if ( !fileInfo.isEmpty() ) - tickerText += ", " + fileInfo; + tickerText += ", " + fileInfo; audioUI->setTickerText( tickerText + "." ); loopControl->play(); mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' ); } void MediaPlayer::prev() { if ( playList->prev() ) - play(); + play(); else if ( mediaPlayerState->looping() ) { if ( playList->last() ) - play(); + play(); } else - mediaPlayerState->setList(); + mediaPlayerState->setList(); } void MediaPlayer::next() { if ( playList->next() ) - play(); + play(); else if ( mediaPlayerState->looping() ) { if ( playList->first() ) - play(); + play(); } else - mediaPlayerState->setList(); + mediaPlayerState->setList(); } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); @@ -173,11 +168,11 @@ void MediaPlayer::stopChangingVolume() { killTimers(); } void MediaPlayer::timerEvent( QTimerEvent * ) { if ( volumeDirection == +1 ) - AudioDevice::increaseVolume(); + AudioDevice::increaseVolume(); else if ( volumeDirection == -1 ) AudioDevice::decreaseVolume(); } diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h index 73f8124..d6e90cb 100644 --- a/core/multimedia/opieplayer/mediaplayer.h +++ b/core/multimedia/opieplayer/mediaplayer.h @@ -46,13 +46,13 @@ private slots: void stopChangingVolume(); protected: void timerEvent( QTimerEvent *e ); private: - int volumeDirection; - const DocLnk *currentFile; + int volumeDirection; + const DocLnk *currentFile; }; #endif // MEDIA_PLAYER_H diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h index 339b2e4..97e4066 100644 --- a/core/multimedia/opieplayer/mediaplayerplugininterface.h +++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h @@ -20,14 +20,18 @@ #ifndef MEDIA_PLAYER_PLUGIN_INTERFACE_H #define MEDIA_PLAYER_PLUGIN_INTERFACE_H #include <qpe/qcom.h> #ifndef QT_NO_COMPONENT -// {c0093632-b44c-4cf7-a279-d82fe8a8890c} +# ifndef IID_OpiePlayerPlugin +// {F56F6CE0-1333-41FD-9B46-C0AF44D0B006} +# define IID_OpiePlayerPlugin QUuid( 0xF56F6CE0, 0x1333, 0x41FD, 0x9B, 0x46, 0xC0, 0xAF, 0x44, 0xD0, 0xB0, 0x06); +# endif # ifndef IID_MediaPlayerPlugin +// {c0093632-b44c-4cf7-a279-d82fe8a8890c} # define IID_MediaPlayerPlugin QUuid( 0xc0093632, 0xb44c, 0x4cf7, 0xa2, 0x79, 0xd8, 0x2f, 0xe8, 0xa8, 0x89, 0x0c ) # endif #endif enum ColorFormat { @@ -90,22 +94,31 @@ public: virtual bool supportsSMP() = 0; virtual bool supportsStereo() = 0; virtual bool supportsScaling() = 0; // File Properies virtual long getPlayTime() { return -1; } +#ifdef IID_OpiePlayerPlugin virtual int audioBitsPerSample( int stream ) = 0; +#endif }; class MediaPlayerEncoder; struct MediaPlayerPluginInterface : public QUnknownInterface { virtual MediaPlayerDecoder *decoder() = 0; virtual MediaPlayerEncoder *encoder() = 0; }; +#ifdef IID_OpiePlayerPlugin +struct OpiePlayerPluginInterface : public QUnknownInterface +{ + virtual MediaPlayerDecoder *decoder() = 0; + virtual MediaPlayerEncoder *encoder() = 0; +}; +#endif #endif diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 13741f6..a960c49 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp @@ -20,16 +20,17 @@ #include <qpe/qpeapplication.h> #include <qpe/qlibrary.h> #include <qpe/config.h> #include <qvaluelist.h> #include <qobject.h> #include <qdir.h> -#include "mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> #include "mediaplayerstate.h" + #ifdef QT_NO_COMPONENT // Plugins which are compiled in when no plugin architecture available #include "libmad/libmadpluginimpl.h" #include "libmpeg3/libmpeg3pluginimpl.h" #include "wavplugin/wavpluginimpl.h" #endif @@ -57,12 +58,13 @@ void MediaPlayerState::readConfig( Config& cfg ) { cfg.setGroup("Options"); isFullscreen = cfg.readBoolEntry( "FullScreen" ); isScaled = cfg.readBoolEntry( "Scaling" ); isLooping = cfg.readBoolEntry( "Looping" ); isShuffled = cfg.readBoolEntry( "Shuffle" ); usePlaylist = cfg.readBoolEntry( "UsePlayList" ); + usePlaylist = TRUE; isPlaying = FALSE; isPaused = FALSE; curPosition = 0; curLength = 0; curView = 'l'; } @@ -118,13 +120,13 @@ MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { // ### hack to get true sample count // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { // return libwavdecoder; // } void MediaPlayerState::loadPlugins() { - + qDebug("load plugins"); #ifndef QT_NO_COMPONENT QValueList<MediaPlayerPlugin>::Iterator mit; for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { (*mit).iface->release(); (*mit).library->unload(); delete (*mit).library; @@ -135,18 +137,17 @@ void MediaPlayerState::loadPlugins() { QDir dir( path, "lib*.so" ); QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { MediaPlayerPluginInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); - - MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); +// qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { - MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); +// qDebug( "loading: %s", QString( path + "/" + *it ).latin1() ); MediaPlayerPlugin plugin; plugin.library = lib; plugin.iface = iface; plugin.decoder = plugin.iface->decoder(); plugin.encoder = plugin.iface->encoder(); diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h index e82c263..ad273f1 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.h +++ b/core/multimedia/opieplayer/mediaplayerstate.h @@ -1,10 +1,10 @@ /********************************************************************** -** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. +** Copyright (C) 2000 Trolltech AS. All rights reserved. ** -** This file is part of the Qtopia Environment. +** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** @@ -17,12 +17,13 @@ ** not clear to you. ** **********************************************************************/ #ifndef MEDIA_PLAYER_STATE_H #define MEDIA_PLAYER_STATE_H + #include <qobject.h> class MediaPlayerDecoder; class Config; @@ -30,53 +31,54 @@ class Config; class MediaPlayerState : public QObject { Q_OBJECT public: MediaPlayerState( QObject *parent, const char *name ); ~MediaPlayerState(); - bool fullscreen() { return isFullscreen; } - bool scaled() { return isScaled; } - bool looping() { return isLooping; } - bool shuffled() { return isShuffled; } - bool playlist() { return usePlaylist; } - bool paused() { return isPaused; } - bool playing() { return isPlaying; } - long position() { return curPosition; } - long length() { return curLength; } - char view() { return curView; } + + bool fullscreen() { return isFullscreen; } + bool scaled() { return isScaled; } + bool looping() { return isLooping; } + bool shuffled() { return isShuffled; } + bool playlist() { return usePlaylist; } + bool paused() { return isPaused; } + bool playing() { return isPlaying; } + long position() { return curPosition; } + long length() { return curLength; } + char view() { return curView; } MediaPlayerDecoder *newDecoder( const QString& file ); MediaPlayerDecoder *curDecoder(); MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the - // number of audio samples if we are using the libmad plugin + // number of audio samples if we are using the libmad plugin public slots: void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } - void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } - void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } + void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } + void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } - void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } - void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } - - void setPrev() { emit prev(); } - void setNext() { emit next(); } - void setList() { setPlaying( FALSE ); setView('l'); } - void setVideo() { setView('v'); } - void setAudio() { setView('a'); } - - void toggleFullscreen() { setFullscreen( !isFullscreen ); } - void toggleScaled() { setScaled( !isScaled); } - void toggleLooping() { setLooping( !isLooping); } - void toggleShuffled() { setShuffled( !isShuffled); } - void togglePlaylist() { setPlaylist( !usePlaylist); } - void togglePaused() { setPaused( !isPaused); } - void togglePlaying() { setPlaying( !isPlaying); } + void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } + void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } + + void setPrev() { emit prev(); } + void setNext() { emit next(); } + void setList() { setPlaying( FALSE ); setView('l'); } + void setVideo() { setView('v'); } + void setAudio() { setView('a'); } + + void toggleFullscreen() { setFullscreen( !isFullscreen ); } + void toggleScaled() { setScaled( !isScaled); } + void toggleLooping() { setLooping( !isLooping); } + void toggleShuffled() { setShuffled( !isShuffled); } + void togglePlaylist() { setPlaylist( !usePlaylist); } + void togglePaused() { setPaused( !isPaused); } + void togglePlaying() { setPlaying( !isPlaying); } signals: void fullscreenToggled( bool ); void scaledToggled( bool ); void loopingToggled( bool ); void shuffledToggled( bool ); @@ -102,12 +104,13 @@ private: long curPosition; long curLength; char curView; MediaPlayerDecoder *decoder; MediaPlayerDecoder *libmpeg3decoder; +// MediaPlayerDecoder *libwavdecoder; void loadPlugins(); void readConfig( Config& cfg ); void writeConfig( Config& cfg ) const; }; diff --git a/core/multimedia/opieplayer/mpegplayer.pro b/core/multimedia/opieplayer/mpegplayer.pro index 41f2de0..5bea541 100644 --- a/core/multimedia/opieplayer/mpegplayer.pro +++ b/core/multimedia/opieplayer/mpegplayer.pro @@ -1,22 +1,25 @@ TEMPLATE = app CONFIG = qt warn_on release #release DESTDIR = $(OPIEDIR)/bin HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ - videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h + videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h SOURCES = main.cpp \ loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ - videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp + videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp TARGET = mpegplayer INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lpthread # INTERFACES = # INCLUDEPATH += $(OPIEDIR)/include # CONFIG+=static # TMAKE_CXXFLAGS += -DQPIM_STANDALONE # LIBS += libmpeg3/libmpeg3.a -lpthread # LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so +INCLUDEPATH += $(OPIEDIR)/include +DEPENDPATH += $(OPIEDIR)/include + TRANSLATIONS = ../i18n/de/mpegplayer.ts diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 2c62e86..d70df51 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp @@ -52,15 +52,15 @@ PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) { // #ifdef USE_PLAYLIST_BACKGROUND setStaticBackground( TRUE ); // setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/background" ) ); setBackgroundPixmap( Resource::loadPixmap( "opielogo" ) ); // #endif - addColumn("Title",236); - setAllColumnsShowFocus( TRUE ); - addColumn( tr( "Playlist Selection" ) ); +// addColumn("Title",236); +// setAllColumnsShowFocus( TRUE ); + addColumn( tr( "Playlist Selection" ) ); header()->hide(); setSorting( -1, FALSE ); } PlayListSelection::~PlayListSelection() { diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 202f351..7862d8d 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp @@ -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. ** **********************************************************************/ +// code added by L. J. Potter Sat 03-02-2002 06:17:54 #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/fileselector.h> #include <qpe/qpeapplication.h> @@ -37,18 +38,24 @@ #include <qmainwindow.h> #include <qmessagebox.h> #include <qtoolbutton.h> #include <qtabwidget.h> #include <qlistview.h> #include <qpoint.h> +#include <qlineedit.h> +#include <qpushbutton.h> + //#include <qtimer.h> #include "playlistselection.h" #include "playlistwidget.h" #include "mediaplayerstate.h" +#include "fileBrowser.h" +#include "inputDialog.h" + #include <stdlib.h> #define BUTTONS_ON_TOOLBAR #define SIDE_BUTTONS #define CAN_SAVE_LOAD_PLAYLISTS @@ -116,26 +123,40 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) // Create Menubar QPEMenuBar *menu = new QPEMenuBar( toolbar ); menu->setMargin( 0 ); QPEToolBar *bar = new QPEToolBar( this ); bar->setLabel( tr( "Play Operations" ) ); - d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),"mpegplayer/add_to_playlist",this , SLOT(addSelected()) ); - d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", this , SLOT(removeSelected()) ); - d->tbPlay = new ToolButton( bar, tr( "Play" ),"mpegplayer/play", mediaPlayerState, SLOT( setPlaying(bool)), TRUE ); - d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); - d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); +// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", +// this , SLOT( addSelected()) ); + tbDeletePlaylist = new QPushButton( Resource::loadIconSet("close"),"",bar,"close"); + tbDeletePlaylist->setFlat(TRUE); + tbDeletePlaylist->setFixedSize(20,20); + connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); + + d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", + this , SLOT(addSelected()) ); + d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", + this , SLOT(removeSelected()) ); +// d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); + d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", + this , SLOT( btnPlay(bool) ), TRUE ); + d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", + mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); + d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", + mediaPlayerState, SLOT(setLooping(bool)), TRUE ); + tbDeletePlaylist->hide(); QPopupMenu *pmPlayList = new QPopupMenu( this ); menu->insertItem( tr( "File" ), pmPlayList ); new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); - new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); + // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); QPopupMenu *pmView = new QPopupMenu( this ); menu->insertItem( tr( "View" ), pmView ); fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); @@ -148,13 +169,13 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); tabWidget = new QTabWidget( hbox6, "tabWidget" ); tabWidget->setTabShape(QTabWidget::Triangular); - + QWidget *pTab; pTab = new QWidget( tabWidget, "pTab" ); playlistView = new QListView( pTab, "Videoview" ); playlistView->setMinimumSize(236,260); tabWidget->insertTab( pTab,"Playlist"); @@ -225,41 +246,45 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) QListViewItem * newItem; if ( QFile( Vdit.current()->file()).exists() ) { newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); } } - // add the library area - QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); -// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); -// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); +//playlists list + QWidget *LTab; + LTab = new QWidget( tabWidget, "LTab" ); + playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy + playLists->setMinimumSize(233,260);; + tabWidget->insertTab(LTab,"Lists"); + connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); +// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); - connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); - connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); - connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), - this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); - connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), - this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); +// add the library area + QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); - connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); - // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); - // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); - connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); - connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); - connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); + connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), + this, SLOT( fauxPlay( QListViewItem *) ) ); + connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), + this, SLOT( fauxPlay( QListViewItem *)) ); -// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); -// connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); -// connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); +// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); +// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); - connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); + connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); + connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); - connect( d->selectedFiles, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); + connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); + connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); + connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); + connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); + connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); + + connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); setCentralWidget( vbox5 ); Config cfg( "MediaPlayer" ); readConfig( cfg ); @@ -284,28 +309,30 @@ void PlayListWidget::initializeStates() { d->tbLoop->setOn( mediaPlayerState->looping() ); d->tbShuffle->setOn( mediaPlayerState->shuffled() ); // d->tbFull->setOn( mediaPlayerState->fullscreen() ); // d->tbScale->setOn( mediaPlayerState->scaled() ); // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); // setPlaylist( mediaPlayerState->playlist() ); + setPlaylist( true); + d->selectedFiles->first(); + } void PlayListWidget::readConfig( Config& cfg ) { cfg.setGroup("PlayList"); int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); for ( int i = 0; i < noOfFiles; i++ ) { - QString entryName; - entryName.sprintf( "File%i", i + 1 ); - QString linkFile = cfg.readEntry( entryName ); - DocLnk lnk( linkFile ); - if ( lnk.isValid() ) + QString entryName; + entryName.sprintf( "File%i", i + 1 ); + QString linkFile = cfg.readEntry( entryName ); + DocLnk lnk( linkFile ); + if ( lnk.isValid() ) d->selectedFiles->addToSelection( lnk ); - } } void PlayListWidget::writeConfig( Config& cfg ) const { cfg.setGroup("PlayList"); @@ -331,39 +358,32 @@ void PlayListWidget::writeConfig( Config& cfg ) const { "Your playlist " "may be missing some entries\n" "the next time you start it." ) ); } } - noOfFiles++; + noOfFiles++; } } while ( d->selectedFiles->next() ); cfg.writeEntry("NumberOfFiles", noOfFiles ); + + } void PlayListWidget::addToSelection( const DocLnk& lnk ) { - d->setDocumentUsed = FALSE; + qDebug("add"); + d->setDocumentUsed = FALSE; if ( mediaPlayerState->playlist() ) d->selectedFiles->addToSelection( lnk ); else mediaPlayerState->setPlaying( TRUE ); } -void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { - qDebug("add"); -// d->selectedFiles->addToSelection( lnk ); - // } -// else -// mediaPlayerState->setPlaying( TRUE ); -// -} - - void PlayListWidget::clearList() { while ( first() ) d->selectedFiles->removeSelected(); } @@ -393,22 +413,22 @@ void PlayListWidget::addAllVideoToList() { d->selectedFiles->addToSelection( **dit ); } void PlayListWidget::setDocument(const QString& fileref) { if ( fileref.isNull() ) { - QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); - return; + QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); + return; } if ( mediaPlayerState->playlist() ) - addToSelection( DocLnk( fileref ) ); + addToSelection( DocLnk( fileref ) ); else { - d->setDocumentUsed = TRUE; - if ( d->current ) - delete d->current; - d->current = new DocLnk( fileref ); + d->setDocumentUsed = TRUE; + if ( d->current ) + delete d->current; + d->current = new DocLnk( fileref ); } mediaPlayerState->setPlaying( FALSE ); mediaPlayerState->setPlaying( TRUE ); } @@ -423,18 +443,22 @@ void PlayListWidget::setActiveWindow() { void PlayListWidget::useSelectedDocument() { d->setDocumentUsed = FALSE; } const DocLnk *PlayListWidget::current() { - if ( mediaPlayerState->playlist() ) - return d->selectedFiles->current(); + +// qDebug("in Playlist widget ::current"); + if ( mediaPlayerState->playlist() ) { + return d->selectedFiles->current(); + } else if ( d->setDocumentUsed && d->current ) { - return d->current; - } else - return d->files->selected(); + return d->current; + } else { + return d->files->selected(); + } } bool PlayListWidget::prev() { if ( mediaPlayerState->playlist() ) { if ( mediaPlayerState->shuffled() ) { @@ -498,26 +522,54 @@ bool PlayListWidget::last() { else return mediaPlayerState->looping(); } void PlayListWidget::saveList() { + QString filename; -// pseudo code -// filename = QLineEdit->getText(); - Config cfg( filename + ".playlist" ); - writeConfig( cfg ); + InputDialog *fileDlg; + fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); + fileDlg->exec(); + if( fileDlg->result() == 1 ) { + filename = fileDlg->LineEdit1->text();//+".playlist"; + qDebug("saving playlist "+filename+".playlist"); + +// DocLnk *lnk; +// lnk.setName( filename); //sets file name +// // lnk.setComment(title); +// lnk.setFile( filename+".playlist"); //sets File property +// lnk.setType("player/plain");// hey is this a REGISTERED mime type?!?!? ;D +// lnk.setIcon("MPEGPlayer"); +// if(!lnk.writeLink()) +// qDebug("Writing doclink did not work"); + + Config cfg( filename +".playlist"); + writeConfig( cfg ); + } + DocLnk lnk; + lnk.setName( filename); //sets file name +// lnk.setComment(title); + lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property + lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D + lnk.setIcon("MPEGPlayer"); + if(!lnk.writeLink()) + qDebug("Writing doclink did not work"); + + if(fileDlg) + delete fileDlg; } -void PlayListWidget::loadList() { - QString filename; -// pseudo code -// filename = FileSelector->openFile( "*.playlist" ); - Config cfg( filename + ".playlist" ); - readConfig( cfg ); +void PlayListWidget::loadList( const DocLnk & lnk) { + + clearList(); + Config cfg( lnk.file()); + readConfig(cfg); + tabWidget->setCurrentPage(0); + setCaption("OpiePlayer: "+lnk.name()); } void PlayListWidget::setPlaylist( bool shown ) { if ( shown ) d->playListFrame->show(); @@ -531,119 +583,180 @@ void PlayListWidget::setView( char view ) { showMaximized(); else hide(); } void PlayListWidget::addSelected() { -// QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); - int tabPage=tabWidget->currentPageIndex(); - switch (tabPage) { - case 0: //playlist + + switch (tabWidget->currentPageIndex()) { + case 0: //playlist break; - case 1: { //audio - addToSelection( audioView->selectedItem() ); - } - break; - case 2: { // video - addToSelection( videoView->selectedItem() ); - } - break; - }; + case 1: { //audio + addToSelection( audioView->selectedItem() ); + } + break; + case 2: { // video + addToSelection( videoView->selectedItem() ); + } + break; + }; } void PlayListWidget::removeSelected() { d->selectedFiles->removeSelected( ); } void PlayListWidget::playIt( QListViewItem *it) { // d->setDocumentUsed = FALSE; - mediaPlayerState->setPlaying(true); + mediaPlayerState->setPlaying(TRUE); } void PlayListWidget::addToSelection( QListViewItem *it) { - d->setDocumentUsed = FALSE; + d->setDocumentUsed = FALSE; - if(it) { - qDebug("add to selection"); - int tabPage=tabWidget->currentPageIndex(); - switch (tabPage) { - case 1: { + if(it) { +// qDebug("add to selection"); + switch (tabWidget->currentPageIndex()) { + case 1: { +// qDebug("case 1"); + QListIterator<DocLnk> dit( files.children() ); + for ( ; dit.current(); ++dit ) { +// qDebug(dit.current()->name()); + if( dit.current()->name() == it->text(0)) { + d->selectedFiles->addToSelection( **dit ); + } + } + } + break; + case 2: { +// qDebug("case 2"); + QListIterator<DocLnk> dit( vFiles.children() ); + for ( ; dit.current(); ++dit ) { +// qDebug(dit.current()->name()); + if( dit.current()->name() == it->text(0)) { + d->selectedFiles->addToSelection( **dit ); + } + } + } + break; + case 0: + break; + }; + tabWidget->setCurrentPage(0); +// mediaPlayerState->setPlaying( TRUE ); + } +} + +void PlayListWidget::tabChanged(QWidget *widg) { + + switch ( tabWidget->currentPageIndex()) { + case 0: + { + if( !tbDeletePlaylist->isHidden()) + tbDeletePlaylist->hide(); + d->tbRemoveFromList->setEnabled(TRUE); + d->tbAddToList->setEnabled(FALSE); + } + break; + case 1: + { + if( !tbDeletePlaylist->isHidden()) + tbDeletePlaylist->hide(); + d->tbRemoveFromList->setEnabled(FALSE); + d->tbAddToList->setEnabled(TRUE); + } + break; + case 2: + { + if( !tbDeletePlaylist->isHidden()) + tbDeletePlaylist->hide(); + d->tbRemoveFromList->setEnabled(FALSE); + d->tbAddToList->setEnabled(TRUE); + } + break; + case 3: + { + if( tbDeletePlaylist->isHidden()) + tbDeletePlaylist->show(); + playLists->reread(); + } + break; + }; +} + +/* + list is right clicked*/ +void PlayListWidget::fauxPlay(QListViewItem *it) { + + switch (tabWidget->currentPageIndex()) { + case 0: //playlist + break; + case 1: { //audio QListIterator<DocLnk> dit( files.children() ); for ( ; dit.current(); ++dit ) { +// qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } - } + } break; - case 2: { + case 2: { // video QListIterator<DocLnk> dit( vFiles.children() ); for ( ; dit.current(); ++dit ) { - qDebug(dit.current()->name()); +// qDebug(dit.current()->name()); if( dit.current()->name() == it->text(0)) { d->selectedFiles->addToSelection( **dit ); } } } break; - case 0: - break; }; - tabWidget->setCurrentPage(0); -// mediaPlayerState->setPlaying( TRUE ); - } + mediaPlayerState->setPlaying( TRUE ); +// tabWidget->setCurrentPage(0); + d->selectedFiles->removeSelected(); } -void PlayListWidget::tabChanged(QWidget *widg) { - - int tabPage=tabWidget->currentPageIndex(); - switch (tabPage) { +/* + play button is pressed*/ +void PlayListWidget::btnPlay(bool b) { // this is fugly + switch ( tabWidget->currentPageIndex()) { case 0: { - d->tbRemoveFromList->setEnabled(TRUE); - d->tbAddToList->setEnabled(FALSE); + mediaPlayerState->setPlaying(b); } - break; - case 1: - { - d->tbRemoveFromList->setEnabled(FALSE); - d->tbAddToList->setEnabled(TRUE); - } - break; - case 2: - { - d->tbRemoveFromList->setEnabled(FALSE); - d->tbAddToList->setEnabled(TRUE); - } - break; - }; -} - -// void PlayListWidget::cancelMenuTimer() { -// if( menuTimer->isActive() ) -// menuTimer->stop(); -// } - -// void PlayListWidget::showFileMenu() { - -// } - -// void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) -// { -// // QListView::contentsMousePressEvent( e ); -// menuTimer->start( 750, TRUE ); -// } + break; + case 1: + { + addToSelection( audioView->selectedItem() ); + mediaPlayerState->setPlaying(b); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(1); + } + break; + case 2: + { + addToSelection( videoView->selectedItem() ); + mediaPlayerState->setPlaying(b); + d->selectedFiles->removeSelected( ); + tabWidget->setCurrentPage(2); + } + break; + }; +} -// void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) -// { -// // QListView::contentsMouseReleaseEvent( e ); -// menuTimer->stop(); -// } -// // void PlayListWidget::setFullScreen() { -// mediaPlayerState->toggleFullscreen( ); -// } +void PlayListWidget::deletePlaylist() { + switch( QMessageBox::information( this, (tr("Remove Playlist?")), + (tr("You really want to delete\nthis playlist?")), + (tr("Yes")), (tr("No")), 0 )){ + case 0: // Yes clicked, + QFile().remove(playLists->selected()->file()); + QFile().remove(playLists->selected()->linkFile()); + playLists->reread(); + break; + case 1: // Cancel + break; + }; -// void PlayListWidget::setScaled() { -// mediaPlayerState->toggleScaled(); -// } +} diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 5b05f11..46272a0 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h @@ -20,12 +20,15 @@ #ifndef PLAY_LIST_WIDGET_H #define PLAY_LIST_WIDGET_H #include <qmainwindow.h> #include <qpe/applnk.h> #include <qtabwidget.h> +#include <fileselector.h> +#include <qpushbutton.h> + /* #include <qtimer.h> */ class PlayListWidgetPrivate; class Config; class QListViewItem; @@ -46,28 +49,31 @@ public: QListView *audioView, *videoView, *playlistView; QLabel *libString; // retrieve the current playlist entry (media file link) const DocLnk *current(); void useSelectedDocument(); /* QTimer * menuTimer; */ - + FileSelector* playLists; + QPushButton *tbDeletePlaylist; public slots: void setDocument( const QString& fileref ); void addToSelection( const DocLnk& ); // Add a media file to the playlist void addToSelection( QListViewItem* ); // Add a media file to the playlist - void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist void setActiveWindow(); // need to handle this to show the right view void setPlaylist( bool ); // Show/Hide the playlist void setView( char ); void clearList(); void addAllToList(); void addAllMusicToList(); void addAllVideoToList(); void saveList(); // Save the playlist - void loadList(); // Load a playlist + void loadList( const DocLnk &); // Load a playlist void playIt( QListViewItem *); + void fauxPlay(QListViewItem *); + void btnPlay(bool); + void deletePlaylist(); bool first(); bool last(); bool next(); bool prev(); void addSelected(); void removeSelected(); diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 1f128a4..be838c4 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp @@ -15,13 +15,13 @@ ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qpe/resource.h> -#include "mediaplayerplugininterface.h" +#include <qpe/mediaplayerplugininterface.h> #include <qwidget.h> #include <qpainter.h> #include <qpixmap.h> #include <qslider.h> #include <qdrawutil.h> #include "videowidget.h" diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 7ac63c0..4a0da16 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp @@ -67,13 +67,13 @@ public: max = out = sound_buffer_size; wavedata_remaining = 0; samples_due = 0; samples = -1; } - // expands out samples to the frequency of 44kHz + // expands out samples to the frequency of 44kHz //not any more bool add( short *output, long count, long& done, bool stereo ) { done = 0; qApp->processEvents(); if ( input == 0 ) { @@ -85,12 +85,14 @@ public: int l,r; if ( getSample(l, r) == FALSE ) { qDebug("didn't get sample"); return FALSE; } samples_due += chunkdata.samplesPerSec; + printf("samples due %d\r", samples_due); + fflush(stdout); while ( count && (samples_due > chunkdata.samplesPerSec) ) { *output++ = l; if ( stereo ) *output++ = r; samples_due -= chunkdata.samplesPerSec; count--; @@ -325,16 +327,16 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { // qDebug( "WavPlugin::audioReadSamples" ); return d->add( output, samples, samplesMade, channels != 1 ); } double WavPlugin::getTime() { -// qDebug( "WavPlugin::getTime" ); - return 0.0; +// qDebug( "WavPlugin::getTime" ); //this is a stupid hack here!! + return d->chunkdata.wBitsPerSample; /*0.0*/; } -int WavPlugin::audioBitsPerSample( int ) { -// qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); - return d->chunkdata.wBitsPerSample; // -} +// int WavPlugin::audioBitsPerSample( int ) { +// // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); +// return d->chunkdata.wBitsPerSample; // +// } diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h index 6ae6e06..1c8ba14 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.h +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h @@ -21,13 +21,14 @@ #ifndef WAV_PLUGIN_H #define WAV_PLUGIN_H #include <qstring.h> #include <qapplication.h> -#include "../mediaplayerplugininterface.h" +/* #include "../mediaplayerplugininterface.h" */ +#include <qpe/mediaplayerplugininterface.h> // #define OLD_MEDIAPLAYER_API class WavPluginData; @@ -50,13 +51,13 @@ public: const QString &fileInfo() { return strInfo = ""; } // If decoder doesn't support audio then return 0 here int audioStreams(); int audioChannels( int stream ); int audioFrequency( int stream ); - int audioBitsPerSample( int stream ); +/* int audioBitsPerSample( int stream ); */ int audioSamples( int stream ); bool audioSetSample( long sample, int stream ); long audioGetSample( int stream ); #ifdef OLD_MEDIAPLAYER_API bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp index 2923180..c232d7b 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.cpp @@ -26,20 +26,20 @@ WavPluginImpl::WavPluginImpl() } WavPluginImpl::~WavPluginImpl() { if ( libmadplugin ) - delete libmadplugin; + delete libmadplugin; } MediaPlayerDecoder *WavPluginImpl::decoder() { if ( !libmadplugin ) - libmadplugin = new WavPlugin; + libmadplugin = new WavPlugin; return libmadplugin; } MediaPlayerEncoder *WavPluginImpl::encoder() { @@ -50,14 +50,14 @@ MediaPlayerEncoder *WavPluginImpl::encoder() #ifndef QT_NO_COMPONENT QRESULT WavPluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; - if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) - *iface = this, (*iface)->addRef(); + if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) ) + *iface = this, (*iface)->addRef(); return QS_OK; } Q_EXPORT_INTERFACE() { diff --git a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h index 10f9305..fb1fa73 100644 --- a/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h +++ b/core/multimedia/opieplayer/wavplugin/wavpluginimpl.h @@ -17,13 +17,14 @@ ** not clear to you. ** **********************************************************************/ #ifndef WAV_PLUGIN_IMPL_H #define WAV_PLUGIN_IMPL_H -#include "../mediaplayerplugininterface.h" + +/* #include "../mediaplayerplugininterface.h" */ class WavPlugin; class WavPluginImpl : public MediaPlayerPluginInterface |