author | llornkcor <llornkcor> | 2002-04-21 12:59:29 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-21 12:59:29 (UTC) |
commit | 1c7b8ce5b548a414845b873428bf5a6b36eebb83 (patch) (side-by-side diff) | |
tree | a87a17860a1b0454154bd2c4874cb61c01c7db11 | |
parent | c7a23ea04b627db855934fac5061d7e291cdf230 (diff) | |
download | opie-1c7b8ce5b548a414845b873428bf5a6b36eebb83.zip opie-1c7b8ce5b548a414845b873428bf5a6b36eebb83.tar.gz opie-1c7b8ce5b548a414845b873428bf5a6b36eebb83.tar.bz2 |
hide slider when streaming
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 3 | ||||
-rw-r--r-- | core/multimedia/opieplayer/libmpeg3/libmpeg3.pro | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.pro | 2 |
4 files changed, 5 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 20345b7..b9561d5 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -11,193 +11,194 @@ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** 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. ** **********************************************************************/ #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qwidget.h> #include <qpixmap.h> #include <qbutton.h> #include <qpainter.h> #include <qframe.h> #include "audiowidget.h" #include "mediaplayerstate.h" extern MediaPlayerState *mediaPlayerState; static const int xo = -2; // movable x offset static const int yo = 22; // movable y offset struct MediaButton { int xPos, yPos; int color; bool isToggle, isBig, isHeld, isDown; }; // Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist }; static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ) { // QPEApplication::grabKeyboard(); setCaption( tr("OpiePlayer") ); setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); songInfo = new Ticker( this ); songInfo->setFocusPolicy( QWidget::NoFocus ); songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); slider = new QSlider( Qt::Horizontal, this ); slider->setFixedWidth( 220 ); slider->setFixedHeight( 20 ); slider->setMinValue( 0 ); slider->setMaxValue( 1 ); slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); slider->setFocusPolicy( QWidget::NoFocus ); slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 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) ) ); if( !mediaPlayerState->isStreaming) { // this stops the slider from being moved, thus // does not stop stream when it reaches the end connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); } // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); - + if (mediaPlayerState->isStreaming) slider->hide(); + } AudioWidget::~AudioWidget() { for ( int i = 0; i < 4; i++ ) delete pixmaps[i]; } static bool audioSliderBeingMoved = FALSE; void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider->width() == 0 ) return; long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); mediaPlayerState->setPosition( val ); } void AudioWidget::setPosition( long i ) { updateSlider( i, mediaPlayerState->length() ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { if ( view == 'a' ) { startTimer( 150 ); showMaximized(); } else { killTimers(); hide(); } } void AudioWidget::updateSlider( long i, long 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 ); } } void AudioWidget::setToggleButton( int i, bool down ) { if ( down != audioButtons[i].isDown ) toggleButton( i ); } void AudioWidget::toggleButton( int i ) { audioButtons[i].isDown = !audioButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void AudioWidget::paintButton( QPainter *p, int i ) { int x = audioButtons[i].xPos; int y = audioButtons[i].yPos; int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); } void AudioWidget::timerEvent( QTimerEvent * ) { static int frame = 0; if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { frame = frame >= 7 ? 0 : frame + 1; int x = audioButtons[AudioPlay].xPos; int y = audioButtons[AudioPlay].yPos; QPainter p( this ); // Optimize to only draw the little bit of the changing images which is different p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro b/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro index e50aa4e..f5e5954 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro @@ -1,43 +1,43 @@ TEMPLATE = lib CONFIG += qt warn_on release HEADERS = libmpeg3plugin.h libmpeg3pluginimpl.h SOURCES = libmpeg3plugin.cpp libmpeg3pluginimpl.cpp \ bitstream.c \ libmpeg3.c \ mpeg3atrack.c \ mpeg3css.c \ mpeg3demux.c \ mpeg3io.c \ mpeg3title.c \ mpeg3vtrack.c \ audio/ac3.c \ audio/bit_allocation.c \ audio/dct.c \ audio/exponents.c \ audio/header.c \ audio/layer2.c \ audio/layer3.c \ audio/mantissa.c \ audio/mpeg3audio.c \ audio/pcm.c \ audio/synthesizers.c \ audio/tables.c \ video/getpicture.c \ video/headers.c \ video/idct.c \ video/macroblocks.c \ video/mmxtest.c \ video/motion.c \ video/mpeg3video.c \ video/output.c \ video/reconstruct.c \ video/seek.c \ video/slice.c \ video/vlc.c TARGET = mpeg3plugin TMAKE_CC=g++ -DESTDIR = ../../plugins/codecs +DESTDIR = $(OPIEDIR)/plugins/codecs INCLUDEPATH += $(OPIEDIR)/include .. DEPENDPATH += ../$(OPIEDIR)/include .. LIBS += -lqpe -lpthread -lm VERSION = 1.0.0 diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 15175d0..01596a0 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -154,194 +154,194 @@ void LoopControl::timerEvent( QTimerEvent *te ) { void LoopControl::setPosition( long pos ) { audioMutex->lock(); if ( hasVideoChannel && hasAudioChannel ) { playtime.restart(); playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); current_frame = pos + 1; mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); prev_frame = current_frame - 1; currentSample = (int)( (double)current_frame * freq / framerate ); mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); audioSampleCounter = currentSample - 1; } else if ( hasVideoChannel ) { playtime.restart(); playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); current_frame = pos + 1; mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); prev_frame = current_frame - 1; } else if ( hasAudioChannel ) { playtime.restart(); playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); currentSample = pos + 1; mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); audioSampleCounter = currentSample - 1; } audioMutex->unlock(); } void LoopControl::startVideo() { if ( moreVideo ) { if ( mediaPlayerState->curDecoder() ) { if ( hasAudioChannel && !isMuted ) { current_frame = long( playtime.elapsed() * framerate / 1000 ); if ( prev_frame != -1 && current_frame <= prev_frame ) return; } else { // Don't skip current_frame++; } if ( prev_frame == -1 || current_frame > prev_frame ) { if ( current_frame > prev_frame + 1 ) { mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); } moreVideo = videoUI->playVideo(); prev_frame = current_frame; } } else { moreVideo = FALSE; killTimer( videoId ); } } } void LoopControl::startAudio() { //qDebug("start audio"); 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); 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 ( ( 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 ); - if( mediaPlayerState->isStreaming == FALSE); +// if( mediaPlayerState->isStreaming == FALSE) audioSampleCounter = currentSample + samplesRead - 1; moreAudio = readOk && (audioSampleCounter <= total_audio_samples); } else { moreAudio = FALSE; } } audioMutex->unlock(); } void LoopControl::killTimers() { audioMutex->lock(); if ( hasVideoChannel ) killTimer( videoId ); killTimer( sliderId ); threadOkToGo = FALSE; audioMutex->unlock(); } void LoopControl::startTimers() { audioMutex->lock(); moreVideo = FALSE; moreAudio = FALSE; if ( hasVideoChannel ) { moreVideo = TRUE; int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value videoId = startTimer( mSecsBetweenFrames ); } if ( hasAudioChannel ) { moreAudio = TRUE; threadOkToGo = TRUE; } sliderId = startTimer( 300 ); // update slider every 1/3 second audioMutex->unlock(); } void LoopControl::setPaused( bool pause ) { if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) return; if ( pause ) { killTimers(); } else { // Force an update of the position mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); // Just like we never stopped startTimers(); } } void LoopControl::stop( bool willPlayAgainShortly ) { #if defined(Q_WS_QWS) && !defined(QT_NO_COP) if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { disabledSuspendScreenSaver = FALSE; // Re-enable the suspend mode QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } #endif if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { killTimers(); audioMutex->lock(); mediaPlayerState->curDecoder()->close(); if ( audioDevice ) { delete audioDevice; delete audioBuffer; audioDevice = 0; audioBuffer = 0; } audioMutex->unlock(); diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.pro b/core/multimedia/opieplayer/wavplugin/wavplugin.pro index 2160431..f0834de 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.pro +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.pro @@ -1,10 +1,10 @@ TEMPLATE = lib CONFIG += qt warn_on release HEADERS = wavplugin.h wavpluginimpl.h SOURCES = wavplugin.cpp wavpluginimpl.cpp TARGET = wavplugin -DESTDIR = ../../plugins/codecs +DESTDIR = $(OPIEDIR)/plugins/codecs INCLUDEPATH += $(OPIEDIR)/include .. DEPENDPATH += ../$(OPIEDIR)/include .. LIBS += -lqpe VERSION = 1.0.0 |