summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp16
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp31
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp24
-rw-r--r--core/multimedia/opieplayer/loopcontrol_threaded.cpp18
-rw-r--r--core/multimedia/opieplayer/mediaplayer.cpp6
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp2
-rw-r--r--core/multimedia/opieplayer/om3u.cpp4
-rw-r--r--core/multimedia/opieplayer/playlistselection.cpp2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp142
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp14
10 files changed, 117 insertions, 142 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 73e41dc..d01d2ba 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -134,128 +134,128 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
Config cfg("qpe"); // qtopia is "Sound"
cfg.setGroup("Volume"); // qtopia is "Settings"
cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume
# endif
//#endif
// qDebug( "setting volume to: 0x%x", volume );
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
// Send notification that the volume has changed
QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
#endif
}
AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
- qDebug("creating new audio device");
+ // qDebug("creating new audio device");
// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
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;
#ifdef KEEP_DEVICE_OPEN
if ( AudioDevicePrivate::dspFd == 0 ) {
#endif
if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
// perror("open(\"/dev/dsp\") sending to /dev/null instead");
perror("open(\"/dev/dsp\")");
QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
exit(-1); //harsh?
// d->handle = ::open( "/dev/null", O_WRONLY );
// WTF?!?!
}
#ifdef KEEP_DEVICE_OPEN
AudioDevicePrivate::dspFd = d->handle;
} else {
d->handle = AudioDevicePrivate::dspFd;
}
#endif
if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
- qDebug("freq %d", d->frequency);
+ // qDebug("freq %d", d->frequency);
if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
perror("ioctl(\"SNDCTL_DSP_SPEED\")");
- qDebug("channels %d",d->channels);
+ // qDebug("channels %d",d->channels);
if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
d->channels = ( d->channels == 1 ) ? 2 : d->channels;
if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
perror("ioctl(\"SNDCTL_DSP_CHANNELS\")");
}
// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
d->bufferSize = sound_fragment_bytes;
d->unwrittenBuffer = new char[d->bufferSize];
d->unwritten = 0;
d->can_GETOSPACE = TRUE; // until we find otherwise
//if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels );
//if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency );
//if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" );
//if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" );
//if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" );
//if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" );
}
AudioDevice::~AudioDevice() {
- qDebug("destryo audiodevice");
+ // qDebug("destryo audiodevice");
// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
# ifndef KEEP_DEVICE_OPEN
close( d->handle ); // Now it should be safe to shut the handle
# endif
delete d->unwrittenBuffer;
delete d;
// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE;
}
void AudioDevice::volumeChanged( bool muted )
{
AudioDevicePrivate::muted = muted;
}
void AudioDevice::write( char *buffer, unsigned int length )
{
int t = ::write( d->handle, buffer, length );
if ( t<0 ) t = 0;
if ( t != (int)length) {
- qDebug("Ahhh!! memcpys 1");
+ // qDebug("Ahhh!! memcpys 1");
memcpy(d->unwrittenBuffer,buffer+t,length-t);
d->unwritten = length-t;
}
//#endif
}
unsigned int AudioDevice::channels() const
{
return d->channels;
}
unsigned int AudioDevice::frequency() const
{
return d->frequency;
@@ -292,22 +292,22 @@ unsigned int AudioDevice::canWrite() const
d->unwritten -= t;
} else {
d->unwritten = 0;
}
}
if ( d->unwritten )
return 0;
else
return d->bufferSize;
}
}
int AudioDevice::bytesWritten() {
int buffered = 0;
if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
- qDebug( "failed to get audio device position" );
+ // qDebug( "failed to get audio device position" );
return -1;
}
return buffered;
}
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index a1973e9..b187cb4 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -63,47 +63,47 @@ const char *skin_mask_file_names[10] = {
"down", "loop", "playlist", "forward", "back"
};
static void changeTextColor( QWidget *w ) {
QPalette p = w->palette();
p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
w->setPalette( p );
}
static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
{
setCaption( tr("OpiePlayer") );
- qDebug("<<<<<audioWidget");
+ // qDebug("<<<<<audioWidget");
Config cfg("OpiePlayer");
cfg.setGroup("Options");
skin = cfg.readEntry("Skin","default");
//skin = "scaleTest";
// color of background, frame, degree of transparency
// QString skinPath = "opieplayer/skins/" + skin;
QString skinPath;
skinPath = "opieplayer2/skins/" + skin;
if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
skinPath = "opieplayer2/skins/default";
- qDebug("skin path " + skinPath);
+ // qDebug("skin path " + skinPath);
pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
imgButtonMask->fill( 0 );
for ( int i = 0; i < 10; i++ ) {
QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
masks[i] = new QBitmap( filename );
if ( !masks[i]->isNull() ) {
QImage imgMask = masks[i]->convertToImage();
uchar **dest = imgButtonMask->jumpTable();
for ( int y = 0; y < imgUp->height(); y++ ) {
@@ -147,48 +147,49 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
// Intialise state
setLength( mediaPlayerState->length() );
setPosition( mediaPlayerState->position() );
setLooping( mediaPlayerState->fullscreen() );
// setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState->playing() );
-
+this->setFocus();
}
AudioWidget::~AudioWidget() {
+ // setPlaying( false);
for ( int i = 0; i < 10; i++ ) {
- delete buttonPixUp[i];
- delete buttonPixDown[i];
+ if(buttonPixUp[i]) delete buttonPixUp[i];
+ if(buttonPixDown[i]) delete buttonPixDown[i];
}
- delete pixBg;
- delete imgUp;
- delete imgDn;
- delete imgButtonMask;
+ if(pixBg) delete pixBg;
+ if(imgUp) delete imgUp;
+ if(imgDn) delete imgDn;
+ if(imgButtonMask) delete imgButtonMask;
for ( int i = 0; i < 10; i++ ) {
- delete masks[i];
+ if(masks[i]) delete masks[i];
}
}
QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
QPixmap pix( img.width(), img.height() );
QPainter p( &pix );
p.drawTiledPixmap( pix.rect(), bg, offset );
p.drawImage( 0, 0, img );
return new QPixmap( pix );
}
QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
{
QPixmap *pixmap = new QPixmap( pix );
@@ -266,43 +267,45 @@ void AudioWidget::setView( char view ) {
} else {
// this stops the slider from being moved, thus
// does not stop stream when it reaches the end
slider.show();
connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
}
if ( view == 'a' ) {
startTimer( 150 );
// show();
showMaximized();
} else {
killTimers();
hide();
}
+
}
static QString timeAsString( long length ) {
length /= 44100;
int minutes = length / 60;
int seconds = length % 60;
return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
}
void AudioWidget::updateSlider( long i, long max ) {
+this->setFocus();
time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
if ( max == 0 )
return;
// Will flicker too much if we don't do this
// Scale to something reasonable
int width = slider.width();
int val = int((double)i * width / max);
if ( !audioSliderBeingMoved ) {
if ( slider.value() != val )
slider.setValue( val );
if ( slider.maxValue() != width )
slider.setMaxValue( width );
}
}
@@ -344,45 +347,45 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
}
*/
}
void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
for ( int i = 0; i < numButtons; i++ ) {
if ( event->state() == QMouseEvent::LeftButton ) {
// The test to see if the mouse click is inside the button or not
int x = event->pos().x() - xoff;
int y = event->pos().y() - yoff;
bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
&& y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
- if ( isOnButton && i == AudioVolumeUp )
- qDebug("on up");
+// if ( isOnButton && i == AudioVolumeUp )
+// qDebug("on up");
if ( isOnButton && !audioButtons[i].isHeld ) {
audioButtons[i].isHeld = TRUE;
toggleButton(i);
switch (i) {
case AudioVolumeUp:
- qDebug("more clicked");
+ // qDebug("more clicked");
emit moreClicked();
return;
case AudioVolumeDown:
- qDebug("less clicked");
+ // qDebug("less clicked");
emit lessClicked();
return;
case AudioForward:
emit forwardClicked();
return;
case AudioBack:
emit backClicked();
return;
}
} else if ( !isOnButton && audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
if ( audioButtons[i].isHeld ) {
audioButtons[i].isHeld = FALSE;
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 8cf0a75..82242a3 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -87,50 +87,50 @@ void *startAudioThread( void *ptr ) {
if ( threadOkToGo && mpegView->moreAudio )
mpegView->startAudio();
else
usleep( 10000 ); // Semi-buzy-wait till we are playing again
}
return 0;
}
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");
+ //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
if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
sched_param params;
params.sched_priority = 50;
pthread_attr_setschedparam(&audio_attr,&params);
} else {
- qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
+ // 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");
+ //qDebug("create audio thread");
pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
}
LoopControl::~LoopControl() {
stop();
}
static long prev_frame = 0;
static int currentSample = 0;
void LoopControl::timerEvent( QTimerEvent *te ) {
if ( te->timerId() == videoId )
@@ -214,47 +214,47 @@ void LoopControl::startVideo() {
}
}
}
void LoopControl::startAudio() {
audioMutex->lock();
if ( moreAudio ) {
if ( !isMuted && mediaPlayerState->curDecoder() ) {
currentSample = audioSampleCounter + 1;
- if ( currentSample != audioSampleCounter + 1 )
- qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
+// if ( currentSample != audioSampleCounter + 1 )
+// qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
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;
// this causes drop outs not sure why its even here
if ( hasVideoChannel ) {
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 );
+ // 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 );
if( mediaPlayerState->isStreaming == FALSE)
audioSampleCounter = currentSample + samplesRead - 1;
moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
} else {
moreAudio = FALSE;
@@ -348,75 +348,75 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
audioMutex->unlock();
}
audioSampleCounter=0;
current_frame=0;
total_audio_samples=0;
}
bool LoopControl::init( const QString& filename ) {
stop();
audioMutex->lock();
fileName = filename;
stream = 0; // only play stream 0 for now
current_frame = total_video_frames = total_audio_samples = 0;
- qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
+ // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
// ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
// if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
// if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) {
// total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
// mediaPlayerState->libMpeg3Decoder()->close();
// }
// }
if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
audioMutex->unlock();
return FALSE;
}
hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
if ( hasAudioChannel ) {
int astream = 0;
if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") )
channels = 2; //dont akx me why, but it needs this hack
else
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;
- qDebug("total samples %d", total_audio_samples);
+ // qDebug("total samples %d", total_audio_samples);
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("LibWavPlugin") ) {
bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime();
- qDebug("using stupid hack");
+ // 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.
static const int size = 1;
short int buf[size];
long samplesRead = 0;
mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
}
if ( hasVideoChannel ) {
@@ -438,33 +438,33 @@ bool LoopControl::init( const QString& filename ) {
}
current_frame = 0;
prev_frame = -1;
connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
audioMutex->unlock();
return TRUE;
}
void LoopControl::play() {
- qDebug("LC- play");
+ // qDebug("LC- play");
mediaPlayerState->setPosition( 0); //uglyhack
#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)" )
<< ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
}
#endif
playtime.start();
startTimers();
}
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
index e99c97b..364e77b 100644
--- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp
+++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp
@@ -179,33 +179,33 @@ void LoopControl::timerEvent( QTimerEvent* ) {
}
}
void LoopControl::setPosition( long pos ) {
if ( sendingNewPos ) {
sendingNewPos = FALSE;
return;
}
if ( hasVideoChannel && hasAudioChannel ) {
videoMutex->lock();
audioMutex->lock();
-qDebug("setting position");
+ //qDebug("setting position");
playtime.restart();
playtime = playtime.addMSecs( -pos * 1000 / framerate );
//begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
current_frame = pos + 1;
mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
prev_frame = current_frame - 1;
currentSample = (int)( current_frame * freq / framerate );
mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
audioSampleCounter = currentSample - 1;
audioMutex->unlock();
videoMutex->unlock();
} else if ( hasVideoChannel ) {
videoMutex->lock();
playtime.restart();
playtime = playtime.addMSecs( -pos * 1000 / framerate );
//begin = clock() - (double)pos * CLOCKS_PER_SEC / framerate;
@@ -295,151 +295,151 @@ void LoopControl::startVideo() {
// qDebug("elapsed: %i %i (%f)", int( playtime.elapsed() ), current_frame, framerate );
} else {
videoMutex->lock();
current_frame++;
videoMutex->unlock();
}
videoMutex->lock();
bool check = current_frame && current_frame > prev_frame;
videoMutex->unlock();
if ( check ) {
videoMutex->lock();
if ( current_frame > prev_frame + 1 ) {
- qDebug("skipped a frame");
+ // qDebug("skipped a frame");
mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
}
prev_frame = current_frame;
if ( moreVideo = videoUI->playVideo() )
emitChangePos = TRUE;
videoMutex->unlock();
}
} else
moreVideo = FALSE;
}
if ( !moreVideo && !moreAudio )
emitPlayFinished = TRUE;
pthread_exit(NULL);
}
void LoopControl::startAudio() {
moreAudio = TRUE;
while ( moreAudio ) {
if ( !isMuted && mediaPlayerState->curDecoder() && hasAudioChannel ) {
audioMutex->lock();
currentSample = mediaPlayerState->curDecoder()->audioGetSample( stream );
if ( currentSample == 0 )
currentSample = audioSampleCounter + 1;
- if ( currentSample != audioSampleCounter + 1 )
- qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
+// if ( currentSample != audioSampleCounter + 1 )
+// qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
audioMutex->unlock();
/*
int sampleWeShouldBeAt = int( playtime.elapsed() ) * freq / 1000;
if ( sampleWeShouldBeAt - currentSample > 20000 ) {
mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
currentSample = sampleWeShouldBeAt;
}
*/
long samplesRead = 0;
const long samples = 1024;
moreAudio = !mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, samples, samplesRead, stream );
audioMutex->lock();
long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
//long sampleWeShouldBeAt = long( clock() - begin ) * (double) freq / CLOCKS_PER_SEC;
long sampleWaitTime = currentSample - sampleWeShouldBeAt;
audioMutex->unlock();
if ( sampleWaitTime >= 0 && sampleWaitTime <= 2000 ) {
//qDebug("sampleWaitTime: %i", sampleWaitTime);
usleep( ( sampleWaitTime * 1000000 ) / ( freq ) );
} else {
audioMutex->lock();
if ( sampleWaitTime <= -2000 ) {
- qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
+ // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
currentSample = sampleWeShouldBeAt;
}
audioMutex->unlock();
}
audioDevice->write( audioBuffer, samplesRead * 2 * channels );
audioMutex->lock();
// audioSampleCounter += samplesRead;
audioSampleCounter = currentSample + samplesRead - 1;
audioMutex->unlock();
if ( !hasVideoChannel )
emitChangePos = TRUE;
//qDebug("currentSample: %i audioSampleCounter: %i total_audio_samples: %i", currentSample, audioSampleCounter, total_audio_samples);
// qDebug("current: %i counter: %i total: %i", currentSample, audioSampleCounter, (int)total_audio_samples);
moreAudio = audioSampleCounter <= total_audio_samples;
} else {
if ( mediaPlayerState->curDecoder() && hasAudioChannel )
usleep( 100000 ); // Check every 1/10 sec to see if mute is off
else
moreAudio = FALSE;
}
}
- qDebug( "End of file" );
+ // qDebug( "End of file" );
if ( !moreVideo && !moreAudio )
emitPlayFinished = TRUE;
pthread_exit(NULL);
}
void LoopControl::killTimers() {
if ( hasVideoChannel ) {
if ( pthread_self() != video_tid ) {
if ( pthread_cancel(video_tid) == 0 ) {
void *thread_result = 0;
if ( pthread_join(video_tid,&thread_result) != 0 )
- qDebug("thread join error 1");
+ // qDebug("thread join error 1");
pthread_attr_destroy(&video_attr);
}
}
}
if ( hasAudioChannel ) {
if ( pthread_self() != audio_tid ) {
if ( pthread_cancel(audio_tid) == 0 ) {
void *thread_result = 0;
if ( pthread_join(audio_tid,&thread_result) != 0 )
- qDebug("thread join error 2");
+ // qDebug("thread join error 2");
pthread_attr_destroy(&audio_attr);
}
}
}
}
void LoopControl::startTimers() {
moreVideo = FALSE;
moreAudio = FALSE;
if ( hasVideoChannel ) {
moreVideo = TRUE;
pthread_attr_init(&video_attr);
pthread_create(&video_tid, &video_attr, (void * (*)(void *))startVideoThread, this);
}
@@ -500,33 +500,33 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
delete audioDevice;
delete audioBuffer;
audioDevice = 0;
audioBuffer = 0;
}
}
}
bool LoopControl::init( const QString& filename ) {
stop();
fileName = filename;
stream = 0; // only play stream 0 for now
current_frame = total_video_frames = total_audio_samples = 0;
- qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
+ // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() );
// ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
mediaPlayerState->libMpeg3Decoder()->close();
}
}
if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) )
return FALSE;
hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
if ( hasAudioChannel ) {
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp
index 4f3823a..753b2e3 100644
--- a/core/multimedia/opieplayer/mediaplayer.cpp
+++ b/core/multimedia/opieplayer/mediaplayer.cpp
@@ -67,44 +67,44 @@ MediaPlayer::~MediaPlayer() {
void MediaPlayer::pauseCheck( bool b ) {
// Only pause if playing
if ( b && !mediaPlayerState->playing() )
mediaPlayerState->setPaused( FALSE );
}
void MediaPlayer::play() {
mediaPlayerState->setPlaying( FALSE );
mediaPlayerState->setPlaying( TRUE );
}
void MediaPlayer::setPlaying( bool play ) {
- qDebug("MediaPlayer setPlaying");
+ // qDebug("MediaPlayer setPlaying %d", play);
if ( !play ) {
mediaPlayerState->setPaused( FALSE );
loopControl->stop( FALSE );
return;
}
if ( mediaPlayerState->paused() ) {
mediaPlayerState->setPaused( FALSE );
return;
}
- qDebug("about to ctrash");
+ // qDebug("about to ctrash");
const DocLnk *playListCurrent = playList->current();
if ( playListCurrent != NULL ) {
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;
}
if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
QMessageBox::critical( 0, tr( "File not found"),
tr( "The following file was not found: <i>" )
+ currentFile->file() + "</i>" );
@@ -243,33 +243,33 @@ void MediaPlayer::timerEvent( QTimerEvent * ) {
p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
}
}
void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_Home:
break;
case Key_F9: //activity
break;
case Key_F10: //contacts
break;
case Key_F11: //menu
break;
case Key_F12: //home
- qDebug("Blank here");
+ // qDebug("Blank here");
break;
case Key_F13: //mail
break;
}
}
void MediaPlayer::doBlank() {
}
void MediaPlayer::doUnblank() {
}
void MediaPlayer::cleanUp() {
// QPEApplication::grabKeyboard();
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index cf166d6..6823076 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -114,33 +114,33 @@ MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
MediaPlayerDecoder *MediaPlayerState::curDecoder() {
return decoder;
}
// ### hack to get true sample count
MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
return libmpeg3decoder;
}
// ### hack to get true sample count
// MediaPlayerDecoder *MediaPlayerState::libWavDecoder() {
// return libwavdecoder;
// }
void MediaPlayerState::loadPlugins() {
- qDebug("load plugins");
+ // 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;
}
pluginList.clear();
QString path = QPEApplication::qpeDir() + "/plugins/codecs";
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 );
diff --git a/core/multimedia/opieplayer/om3u.cpp b/core/multimedia/opieplayer/om3u.cpp
index 3541e5f..8b92a8c 100644
--- a/core/multimedia/opieplayer/om3u.cpp
+++ b/core/multimedia/opieplayer/om3u.cpp
@@ -57,33 +57,33 @@ static inline QString fullBaseName ( const QFileInfo &fi )
Om3u::Om3u( const QString &filePath, int mode)
: QStringList (){
//qDebug("<<<<<<<new m3u "+filePath);
f.setName(filePath);
f.open(mode);
}
Om3u::~Om3u(){}
void Om3u::readM3u() {
// qDebug("<<<<<<reading m3u "+f.name());
QTextStream t(&f);
QString s;
while ( !t.atEnd() ) {
s=t.readLine();
- qDebug(s);
+ // qDebug(s);
if( s.find( "#", 0, TRUE) == -1 ) {
if( s.left(2) == "E:" || s.left(2) == "P:" ) {
s = s.right( s.length() -2 );
QFileInfo f( s );
QString name = fullBaseName ( f );
name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
s=s.replace( QRegExp( "\\" ), "/" );
append(s);
// qDebug(s);
} else { // is url
s.replace( QRegExp( "%20" )," " );
QString name;
// if( name.left( 4 ) == "http" ) {
// name = s.right( s.length() - 7 );
// } else {
name = s;
@@ -122,33 +122,33 @@ void Om3u::readPls() { //it's a pls file
if( s.at( s.length() - 4) == '.') // if this is probably a file
append(s);
else { //if its a url
if( name.right( 1 ).find( '/' ) == -1) {
s += "/";
}
append(s);
}
}
}
}
void Om3u::write() { //writes list to m3u file
QString list;
if(count()>0) {
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
- qDebug(*it);
+ // qDebug(*it);
list += *it+"\n";
}
f.writeBlock( list, list.length() );
}
// f.close();
}
void Om3u::add(const QString &filePath) { //adds to m3u file
append(filePath);
}
void Om3u::remove(const QString &filePath) { //removes from m3u list
QString list, currentFile;
if(count()>0) {
for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) {
currentFile=*it;
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp
index 67187f8..94567f2 100644
--- a/core/multimedia/opieplayer/playlistselection.cpp
+++ b/core/multimedia/opieplayer/playlistselection.cpp
@@ -181,33 +181,33 @@ bool PlayListSelection::last() {
return FALSE;
ensureItemVisible( selectedItem() );
return TRUE;
}
void PlayListSelection::unSelect()
{
QListViewItem *item = selectedItem();
setSelected( currentItem(), FALSE);
}
void PlayListSelection::writeCurrent( Config& cfg ) {
cfg.setGroup("PlayList");
QListViewItem *item = selectedItem();
if ( item )
cfg.writeEntry("current", item->text(0) );
- qDebug(item->text(0));
+ // qDebug(item->text(0));
}
void PlayListSelection::setSelectedItem(const QString &strk ) {
unSelect();
QListViewItemIterator it( this );
for ( ; it.current(); ++it ) {
// qDebug( it.current()->text(0));
if( strk == it.current()->text(0)) {
// qDebug( "We have a match "+strk);
setSelected( it.current(), TRUE);
ensureItemVisible( it.current() );
return;
}
}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 7ea95ab..1fc7dd8 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -294,39 +294,38 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
videoView->addColumn(tr("Title"),-1);
videoView->addColumn(tr("Size"),-1);
videoView->addColumn(tr("Media"),-1);
videoView->addColumn(tr( "Path" ), -1 );
videoView->setColumnAlignment(1, Qt::AlignRight);
videoView->setColumnAlignment(2, Qt::AlignRight);
videoView->setAllColumnsShowFocus(TRUE);
videoView->setMultiSelection( TRUE );
videoView->setSelectionMode( QListView::Extended);
QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
tabWidget->insertTab( vTab,tr("Video"));
QWidget *LTab;
LTab = new QWidget( tabWidget, "LTab" );
- playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
+ playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE);
QGridLayout *layoutL = new QGridLayout( LTab );
layoutL->setSpacing( 2);
layoutL->setMargin( 2);
layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 );
-// playLists->setMinimumSize(233,260);
tabWidget->insertTab(LTab,tr("Lists"));
connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
///audioView
connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
@@ -345,38 +344,38 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
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 *) ) );
setCentralWidget( vbox5 );
Config cfg( "OpiePlayer" );
readConfig( cfg );
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
- loadList(DocLnk( currentPlaylist));
- setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
+
+ currentPlayList = cfg.readEntry("CurrentPlaylist","default");
+ loadList(DocLnk( currentPlayList));
+ setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList)));
initializeStates();
- // audioUI->setFocus();
}
PlayListWidget::~PlayListWidget() {
Config cfg( "OpiePlayer" );
writeConfig( cfg );
if ( d->current )
delete d->current;
if(d) delete d;
}
void PlayListWidget::initializeStates() {
d->tbPlay->setOn( mediaPlayerState->playing() );
@@ -408,64 +407,71 @@ void PlayListWidget::writeConfig( Config& cfg ) const {
d->selectedFiles->writeCurrent( cfg);
cfg.setGroup("PlayList");
int noOfFiles = 0;
d->selectedFiles->first();
do {
const DocLnk *lnk = d->selectedFiles->current();
if ( lnk ) {
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
// qDebug(entryName);
cfg.writeEntry( entryName, lnk->linkFile() );
// if this link does exist, add it so we have the file
// next time...
if ( !QFile::exists( lnk->linkFile() ) ) {
// the way writing lnks doesn't really check for out
// of disk space, but check it anyway.
- if ( !lnk->writeLink() ) {
- QMessageBox::critical( 0, tr("Out of space"),
- tr( "There was a problem saving "
- "the playlist.\n"
- "Your playlist "
- "may be missing some entries\n"
- "the next time you start it." )
- );
- }
+// if ( !lnk->writeLink() ) {
+// QMessageBox::critical( 0, tr("Out of space"),
+// tr( "There was a problem saving "
+// "the playlist.\n"
+// "Your playlist "
+// "may be missing some entries\n"
+// "the next time you start it." )
+// );
+// }
+
}
noOfFiles++;
}
}
while ( d->selectedFiles->next() );
cfg.writeEntry("NumberOfFiles", noOfFiles );
}
void PlayListWidget::addToSelection( const DocLnk& lnk ) {
d->setDocumentUsed = false;
if ( mediaPlayerState->playlist() ) {
if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
d->selectedFiles->addToSelection( lnk );
}
else
mediaPlayerState->setPlaying( true);
+
}
void PlayListWidget::clearList() {
while ( first() )
d->selectedFiles->removeSelected();
+ Config cfg( "OpiePlayer" );
+ cfg.setGroup("PlayList");
+ cfg.writeEntry("CurrentPlaylist","");
+ currentPlayList="";
+
}
void PlayListWidget::addAllToList() {
DocLnkSet filesAll;
Global::findDocuments(&filesAll, "video/*;audio/*");
QListIterator<DocLnk> Adit( filesAll.children() );
for ( ; Adit.current(); ++Adit )
if(QFileInfo(Adit.current()->file()).exists())
d->selectedFiles->addToSelection( **Adit );
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
@@ -484,142 +490,129 @@ void PlayListWidget::addAllMusicToList() {
void PlayListWidget::addAllVideoToList() {
QListIterator<DocLnk> dit( vFiles.children() );
for ( ; dit.current(); ++dit )
if(QFileInfo( dit.current()->file()).exists())
d->selectedFiles->addToSelection( **dit );
tabWidget->setCurrentPage(0);
writeCurrentM3u();
d->selectedFiles->first();
}
void PlayListWidget::setDocument(const QString& fileref) {
fromSetDocument = true;
d->setDocumentUsed = TRUE;
- d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
- mediaPlayerState->setPlaying( FALSE );
- qApp->processEvents();
- mediaPlayerState->setPlaying( TRUE );
+ setDocumentEx(fileref);
}
void PlayListWidget::setDocumentEx(const QString& fileref) {
-
+ qDebug("opieplayer receive "+fileref);
+ clearList();
+ DocLnk lnk;
QFileInfo fileInfo(fileref);
if ( !fileInfo.exists() ) {
QMessageBox::critical( 0, tr( "Invalid File" ),
tr( "There was a problem in getting the file." ) );
return;
}
- qDebug("setDocument "+fileref);
+ // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref);
QString extension = fileInfo.extension(false);
if( extension.find( "m3u", 0, false) != -1) { //is m3u
readm3u( fileref);
}
else if( extension.find( "pls", 0, false) != -1 ) { //is pls
readPls( fileref);
}
else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
clearList();
- DocLnk lnk;
lnk.setName( fileInfo.baseName() ); //sets name
lnk.setFile( fileref ); //sets file name
+ lnk.setIcon("Sound");
//addToSelection( lnk );
loadList( lnk);
d->selectedFiles->first();
} else {
- clearList();
- DocLnk lnk;
+ if( fileref.find(".desktop",0,TRUE) != -1) {
+ lnk = DocLnk(fileref);
+ } else {
lnk.setName( fileInfo.baseName() ); //sets name
lnk.setFile( fileref ); //sets file name
+ lnk.setIcon("Sound");
+ }
+
addToSelection( lnk );
// addToSelection( DocLnk( fileref ) );
+ lnk.removeLinkFile();
+ // qApp->processEvents();
+ }
+ setCaption(tr("OpiePlayer"));
d->setDocumentUsed = TRUE;
+ d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true );
mediaPlayerState->setPlaying( FALSE );
qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
- // qApp->processEvents();
- setCaption(tr("OpiePlayer"));
- }
+
}
void PlayListWidget::setActiveWindow() {
- qDebug("SETTING active window");
-
+ // qDebug("SETTING active window");
// When we get raised we need to ensure that it switches views
char origView = mediaPlayerState->view();
mediaPlayerState->setView( 'l' ); // invalidate
mediaPlayerState->setView( origView ); // now switch back
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() { // this is fugly
-
-// if( fromSetDocument) {
-// qDebug("from setDoc");
-// DocLnkSet files;
-// Global::findDocuments(&files, "video/*;audio/*");
-// QListIterator<DocLnk> dit( files.children() );
-// for ( ; dit.current(); ++dit ) {
-// if(dit.current()->linkFile() == setDocFileRef) {
-// qDebug(setDocFileRef);
-// return dit;
-// }
-// }
-// } else
-
- qDebug("current");
-
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
{
- qDebug("playlist");
+ // qDebug("playlist");
if ( mediaPlayerState->playlist() ) {
return d->selectedFiles->current();
}
else if ( d->setDocumentUsed && d->current ) {
return d->current;
} else {
return &(d->files->selectedDocument());
}
}
break;
case 1://audio
{
- qDebug("audioView");
+ // qDebug("audioView");
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");
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() ) {
@@ -704,33 +697,32 @@ void PlayListWidget::loadList( const DocLnk & lnk) {
void PlayListWidget::setPlaylist( bool shown ) {
if ( shown )
d->playListFrame->show();
else
d->playListFrame->hide();
}
void PlayListWidget::setView( char view ) {
if ( view == 'l' )
showMaximized();
else
hide();
}
void PlayListWidget::addSelected() {
- qDebug("addSelected");
DocLnk lnk;
QString filename;
switch (tabWidget->currentPageIndex()) {
case 0: //playlist
return;
break;
case 1: { //audio
QListViewItemIterator it( audioView );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() ) {
filename = it.current()->text(3);
lnk.setName( QFileInfo(filename).baseName() ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
}
@@ -754,33 +746,32 @@ void PlayListWidget::addSelected() {
videoView->clearSelection();
}
break;
};
// tabWidget->setCurrentPage(0);
writeCurrentM3u();
}
void PlayListWidget::removeSelected() {
d->selectedFiles->removeSelected( );
}
void PlayListWidget::playIt( QListViewItem *) {
// d->setDocumentUsed = FALSE;
// mediaPlayerState->curPosition =0;
- qDebug("playIt");
// mediaPlayerState->setPlaying(FALSE);
mediaPlayerState->setPlaying(TRUE);
d->selectedFiles->unSelect();
}
void PlayListWidget::addToSelection( QListViewItem *it) {
d->setDocumentUsed = FALSE;
if(it) {
switch ( tabWidget->currentPageIndex()) {
case 0: //playlist
return;
break;
};
// case 1: {
DocLnk lnk;
@@ -828,63 +819,59 @@ void PlayListWidget::tabChanged(QWidget *) {
tbDeletePlaylist->hide();
d->tbRemoveFromList->setEnabled(FALSE);
d->tbAddToList->setEnabled(TRUE);
}
break;
case 3:
{
if( tbDeletePlaylist->isHidden())
tbDeletePlaylist->show();
playLists->reread();
}
break;
};
}
void PlayListWidget::btnPlay(bool b) {
- qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b);
// mediaPlayerState->setPlaying(b);
switch ( tabWidget->currentPageIndex()) {
case 0:
{
- qDebug("1");
// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
// QMessageBox::message("Note","You are trying to play\na malformed url.");
// } else {
mediaPlayerState->setPlaying(b);
insanityBool=FALSE;
qDebug("insanity");
// }
}
break;
case 1:
{
- qDebug("2");
// d->selectedFiles->unSelect();
addToSelection( audioView->currentItem() );
mediaPlayerState->setPlaying( b);
d->selectedFiles->removeSelected( );
d->selectedFiles->unSelect();
tabWidget->setCurrentPage(1);
insanityBool=FALSE;
}// audioView->clearSelection();
break;
case 2:
{
- qDebug("3");
addToSelection( videoView->currentItem() );
mediaPlayerState->setPlaying( b);
// qApp->processEvents();
d->selectedFiles->removeSelected( );
d->selectedFiles->unSelect();
tabWidget->setCurrentPage(2);
insanityBool=FALSE;
}// videoView->clearSelection();
break;
};
}
void PlayListWidget::deletePlaylist() {
switch( QMessageBox::information( this, (tr("Remove Playlist?")),
@@ -909,60 +896,59 @@ void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int
QPopupMenu m;
m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
m.insertSeparator();
if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::playSelected()
{
- qDebug("playSelected");
btnPlay( true);
// d->selectedFiles->unSelect();
}
void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
{
switch (mouse) {
case 1:
break;
case 2:{
QPopupMenu m;
m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
// m.insertSeparator();
// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
m.exec( QCursor::pos() );
}
break;
};
}
void PlayListWidget::listDelete() {
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
+ currentPlayList = cfg.readEntry("CurrentPlaylist","");
QString file;
// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
switch ( tabWidget->currentPageIndex()) {
case 0:
break;
case 1:
{
file = audioView->currentItem()->text(0);
QListIterator<DocLnk> Pdit( files.children() );
for ( ; Pdit.current(); ++Pdit ) {
if( Pdit.current()->name() == file) {
LnkProperties prop( Pdit.current() );
prop.showMaximized();
prop.exec();
}
}
@@ -1060,94 +1046,84 @@ void PlayListWidget::populateVideoView() {
const QString name = (*it)->name();
const QString path = (*it)->path();
if( Vdit.current()->file().find(path) != -1 ) storage=name;
}
QListViewItem * newItem;
if ( QFile( Vdit.current()->file()).exists() ) {
newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
QString::number( QFile( Vdit.current()->file() ).size() ),
storage, Vdit.current()->file());
newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
}
}
}
void PlayListWidget::openFile() {
- qDebug("<<<<<<<<<OPEN File");
QString filename, name;
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
filename = fileDlg->text();
- qDebug( "Selected filename is " + filename );
-// Om3u *m3uList;
+ // qDebug( "Selected filename is " + filename );
DocLnk lnk;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString m3uFile;
m3uFile = filename;
if(filename.left(4) == "http") {
if(filename.find(":",8,TRUE) != -1) { //found a port
-// m3uFile = filename.left( filename.find( ":",8,TRUE));
m3uFile = filename;
if( m3uFile.right( 1 ).find( '/' ) == -1) {
m3uFile += "/";
}
filename = m3uFile;
-// qDebug("1 "+m3uFile);
-// } else if(filename.left(4) == "http"){
-// m3uFile=filename;
-// m3uFile = m3uFile.right( m3uFile.length() - 7);
-// qDebug("2 "+m3uFile);
-// } else{
-// m3uFile=filename;
-// qDebug("3 "+m3uFile);
- }
+ = }
lnk.setName( m3uFile ); //sets name
lnk.setFile( filename ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
d->selectedFiles->addToSelection( lnk );
writeCurrentM3u();
}
else if( filename.right( 3) == "m3u" ) {
readm3u( filename );
} else if( filename.right(3) == "pls" ) {
readPls( filename );
} else {
lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
lnk.setFile( filename ); //sets file name
d->selectedFiles->addToSelection( lnk);
+ lnk.removeLinkFile();
writeCurrentM3u();
}
}
if( fileDlg ) {
delete fileDlg;
}
}
/*
reads m3u and shows files/urls to playlist widget */
void PlayListWidget::readm3u( const QString &filename ) {
- qDebug( "read m3u filename " + filename );
+ // qDebug( "read m3u filename " + filename );
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readM3u();
DocLnk lnk;
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// qDebug("reading "+ s);
if(s.left(4)=="http") {
lnk.setName( s ); //sets file name
lnk.setIcon("opieplayer2/musicfile");
// if(s.right(4) != '.' || s.right(5) != '.')
if(s.right(4) != '.' || s.right(5) != '.' )
if( s.right(1) != "/")
@@ -1178,33 +1154,33 @@ void PlayListWidget::readm3u( const QString &filename ) {
config.write();
currentPlayList=filename;
// m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
d->selectedFiles->setSelectedItem( s);
setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
}
/*
reads pls and adds files/urls to playlist */
void PlayListWidget::readPls( const QString &filename ) {
- qDebug( "pls filename is " + filename );
+ // qDebug( "pls filename is " + filename );
Om3u *m3uList;
QString s, name;
m3uList = new Om3u( filename, IO_ReadOnly );
m3uList->readPls();
for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
s = *it;
// s.replace( QRegExp( "%20" )," " );
DocLnk lnk( s );
QFileInfo f( s );
QString name = fullBaseName ( f);
if( name.left( 4 ) == "http" ) {
name = s.right( s.length() - 7);
} else {
name = s;
@@ -1221,46 +1197,46 @@ void PlayListWidget::readPls( const QString &filename ) {
}
lnk.setFile( s );
}
lnk.setType( "audio/x-mpegurl" );
lnk.writeLink();
d->selectedFiles->addToSelection( lnk );
}
m3uList->close();
if(m3uList) delete m3uList;
}
/*
writes current playlist to current m3u file */
void PlayListWidget::writeCurrentM3u() {
- qDebug("writing to current m3u");
+ // qDebug("writing to current m3u");
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
- QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
+ currentPlayList = cfg.readEntry("CurrentPlaylist","");
Om3u *m3uList;
- m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
+ m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate );
if( d->selectedFiles->first()) {
do {
- qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
+ // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
m3uList->add( d->selectedFiles->current()->file() );
}
while ( d->selectedFiles->next() );
- qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
+ // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
m3uList->write();
m3uList->close();
if(m3uList) delete m3uList;
}
}
/*
writes current playlist to m3u file */
void PlayListWidget::writem3u() {
InputDialog *fileDlg;
fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
fileDlg->exec();
QString name, filename, list;
Om3u *m3uList;
@@ -1291,74 +1267,72 @@ void PlayListWidget::writem3u() {
if(fileDlg) delete fileDlg;
DocLnk lnk;
lnk.setFile( filename);
lnk.setIcon("opieplayer2/playlist2");
lnk.setName( name); //sets file name
// qDebug(filename);
Config config( "OpiePlayer" );
config.setGroup( "PlayList" );
config.writeEntry("CurrentPlaylist",filename);
currentPlayList=filename;
if(!lnk.writeLink()) {
- qDebug("Writing doclink did not work");
+ // qDebug("Writing doclink did not work");
}
setCaption(tr("OpiePlayer: ") + name);
}
}
}
void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
{
switch ( e->key() ) {
////////////////////////////// Zaurus keys
case Key_F9: //activity
// if(audioUI->isHidden())
// audioUI->showMaximized();
break;
case Key_F10: //contacts
// if( videoUI->isHidden())
// videoUI->showMaximized();
break;
case Key_F11: //menu
break;
case Key_F12: //home
// doBlank();
break;
case Key_F13: //mail
// doUnblank();
break;
case Key_Q: //add to playlist
- qDebug("Add");
addSelected();
break;
case Key_R: //remove from playlist
removeSelected();
break;
// case Key_P: //play
// qDebug("Play");
// playSelected();
// break;
case Key_Space:
- qDebug("Play");
// playSelected(); puh
break;
case Key_1:
tabWidget->setCurrentPage(0);
break;
case Key_2:
tabWidget->setCurrentPage(1);
break;
case Key_3:
tabWidget->setCurrentPage(2);
break;
case Key_4:
tabWidget->setCurrentPage(3);
break;
case Key_Down:
if ( !d->selectedFiles->next() )
@@ -1385,45 +1359,45 @@ void PlayListWidget::keyPressEvent( QKeyEvent *)
// break;
// case Key_R: //remove from playlist
// removeSelected();
// break;
// case Key_P: //play
// qDebug("Play");
// playSelected();
// break;
// case Key_Space:
// qDebug("Play");
// playSelected();
// break;
// }
}
void PlayListWidget::doBlank() {
- qDebug("do blanking");
+ // qDebug("do blanking");
fd=open("/dev/fb0",O_RDWR);
if (fd != -1) {
ioctl(fd,FBIOBLANK,1);
// close(fd);
}
}
void PlayListWidget::doUnblank() {
// this crashes opieplayer with a segfault
// int fd;
// fd=open("/dev/fb0",O_RDWR);
- qDebug("do unblanking");
+ // qDebug("do unblanking");
if (fd != -1) {
ioctl(fd,FBIOBLANK,0);
close(fd);
}
QCopEnvelope h("QPE/System", "setBacklight(int)");
h <<-3;// v[1]; // -3 Force on
}
void PlayListWidget::populateSkinsMenu() {
int item = 0;
defaultSkinIndex = 0;
QString skinName;
Config cfg( "OpiePlayer" );
cfg.setGroup("Options" );
QString skin = cfg.readEntry( "Skin", "default" );
@@ -1448,33 +1422,33 @@ void PlayListWidget::populateSkinsMenu() {
++it;
}
}
void PlayListWidget::skinsMenuActivated( int item ) {
for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
skinsMenu->setItemChecked( i, FALSE );
}
skinsMenu->setItemChecked( item, TRUE );
Config cfg( "OpiePlayer" );
cfg.setGroup("Options");
cfg.writeEntry("Skin", skinsMenu->text( item ) );
}
void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
- qDebug("qcop message "+msg );
+ // qDebug("qcop message "+msg );
QDataStream stream ( data, IO_ReadOnly );
if ( msg == "play()" ) { //plays current selection
btnPlay( true);
} else if ( msg == "stop()" ) {
mediaPlayerState->setPlaying( false);
} else if ( msg == "togglePause()" ) {
mediaPlayerState->togglePaused();
} else if ( msg == "next()" ) { //select next in lis
mediaPlayerState->setNext();
} else if ( msg == "prev()" ) { //select previous in list
mediaPlayerState->setPrev();
} else if ( msg == "toggleLooping()" ) { //loop or not loop
mediaPlayerState->toggleLooping();
} else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
mediaPlayerState->toggleShuffled();
} else if ( msg == "volUp()" ) { //volume more
@@ -1485,22 +1459,20 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
// emit lessReleased();
} else if ( msg == "play(QString)" ) { //play this now
QString file;
stream >> file;
setDocumentEx( (const QString &) file);
} else if ( msg == "add(QString)" ) { //add to playlist
QString file;
stream >> file;
QFileInfo fileInfo(file);
DocLnk lnk;
lnk.setName( fileInfo.baseName() ); //sets name
lnk.setFile( file ); //sets file name
addToSelection( lnk );
} else if ( msg == "rem(QString)" ) { //remove from playlist
QString file;
stream >> file;
-
} else if ( msg == "setDocument(QString)" ) { //loop or not loop
QCopEnvelope h("QPE/Application/opieplayer", "raise()");
}
-
}
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 48104ca..02c8568 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -73,66 +73,66 @@ const char *skinV_mask_file_names[7] = {
static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 )
{
setCaption( tr("OpiePlayer") );
Config cfg("OpiePlayer");
cfg.setGroup("Options");
skin = cfg.readEntry("Skin","default");
QString skinPath;
skinPath = "opieplayer2/skins/" + skin;
if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
skinPath = "opieplayer2/skins/default";
- qDebug("skin path " + skinPath);
+ // qDebug("skin path " + skinPath);
// QString skinPath = "opieplayer2/skins/" + skin;
pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
imgButtonMask->fill( 0 );
for ( int i = 0; i < 7; i++ )
{
QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath +
"/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
- qDebug("loading "+filename);
+ // qDebug("loading "+filename);
masks[i] = new QBitmap( filename );
if ( !masks[i]->isNull() )
{
QImage imgMask = masks[i]->convertToImage();
uchar **dest = imgButtonMask->jumpTable();
for ( int y = 0; y < imgUp->height(); y++ )
{
uchar *line = dest[y];
for ( int x = 0; x < imgUp->width(); x++ )
{
if ( !qRed( imgMask.pixel( x, y ) ) )
line[x] = i + 1;
}
}
}
}
- qDebug("finished loading first pics");
+ // qDebug("finished loading first pics");
for ( int i = 0; i < 7; i++ )
{
buttonPixUp[i] = NULL;
buttonPixDown[i] = NULL;
}
setBackgroundPixmap( *pixBg );
currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
slider = new QSlider( Qt::Horizontal, this );
slider->setMinValue( 0 );
slider->setMaxValue( 1 );
slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
slider->setFocusPolicy( QWidget::NoFocus );
// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
@@ -338,55 +338,55 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
}
} else if ( !isOnButton && videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
toggleButton(i);
}
} else {
if ( videoButtons[i].isHeld ) {
videoButtons[i].isHeld = FALSE;
if ( !videoButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
switch(i) {
case VideoPlay: {
- qDebug("play");
+ // qDebug("play");
if( !mediaPlayerState->playing()) {
mediaPlayerState->setPlaying( true);
setToggleButton( i-1, false );
setToggleButton( i, false );
return;
}
if( mediaPlayerState->isPaused ) {
- qDebug("isPaused");
+ // qDebug("isPaused");
setToggleButton( i, FALSE );
mediaPlayerState->setPaused( FALSE );
return;
} else if( !mediaPlayerState->isPaused ) {
- qDebug("is not paused");
+ // qDebug("is not paused");
setToggleButton( i, TRUE );
mediaPlayerState->setPaused( TRUE );
return;
} else {
return;
}
}
- case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
+ case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
case VideoNext: mediaPlayerState->setNext(); return;
case VideoPrevious: mediaPlayerState->setPrev(); return;
case VideoVolUp: emit moreReleased(); return;
case VideoVolDown: emit lessReleased(); return;
case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
}
}
}
}
}
void VideoWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}