-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 29 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 9 |
5 files changed, 42 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 125fd72..303e56e 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -80,133 +80,133 @@ static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ) { setCaption( tr("OpiePlayer - Audio") ); Config cfg("OpiePlayer"); cfg.setGroup("AudioWidget"); QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); 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( backgroundPix ) ); 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) ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } AudioWidget::~AudioWidget() { - mediaPlayerState->isStreaming = FALSE; + mediaPlayerState->setIsStreaming( FALSE ); for ( int i = 0; i < 3; 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 ) { // qDebug("set position %d",i); updateSlider( i, mediaPlayerState->length() ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState->position(), max ); } void AudioWidget::setView( char view ) { - if (mediaPlayerState->isStreaming) { + if (mediaPlayerState->streaming() ) { if( !slider->isHidden()) slider->hide(); disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); } 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 ); 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 ); } } diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 0ab0124..38ba08f 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp @@ -30,103 +30,96 @@ MediaPlayer::MediaPlayer( QObject *parent, const char *name ) connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 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( 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() ) ); } 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 ) { if ( !play ) { mediaPlayerState->setPaused( FALSE ); return; } if ( mediaPlayerState->paused() ) { mediaPlayerState->setPaused( FALSE ); return; } const DocLnk *playListCurrent = playList->current(); if ( playListCurrent != NULL ) { currentFile = playListCurrent; } audioUI->setTickerText( currentFile->file( ) ); xineControl->play( currentFile->file() ); - - // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben - - // Ob auch video 'v' : 'a' - // mediaPlayerState->setView( 'v' ); - - // abspielen starten. } void MediaPlayer::prev() { if ( playList->prev() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->last() ) { play(); } } else { mediaPlayerState->setList(); } } void MediaPlayer::next() { if ( playList->next() ) { play(); } else if ( mediaPlayerState->looping() ) { if ( playList->first() ) { play(); } } else { mediaPlayerState->setList(); } } void MediaPlayer::startDecreasingVolume() { volumeDirection = -1; startTimer( 100 ); // da kommt demnächst osound denk ich mal // AudioDevice::decreaseVolume(); } void MediaPlayer::startIncreasingVolume() { volumeDirection = +1; startTimer( 100 ); // AudioDevice::increaseVolume(); } void MediaPlayer::stopChangingVolume() { killTimers(); } diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 3090b08..778cd1e 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp @@ -11,233 +11,258 @@ //#define MediaPlayerDebug(x) qDebug x #define MediaPlayerDebug(x) MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) : QObject( parent, name ) { Config cfg( "OpiePlayer" ); readConfig( cfg ); } MediaPlayerState::~MediaPlayerState() { Config cfg( "OpiePlayer" ); writeConfig( cfg ); } 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'; } void MediaPlayerState::writeConfig( Config& cfg ) const { cfg.setGroup("Options"); cfg.writeEntry("FullScreen", isFullscreen ); cfg.writeEntry("Scaling", isScaled ); cfg.writeEntry("Looping", isLooping ); cfg.writeEntry("Shuffle", isShuffled ); cfg.writeEntry("UsePlayList", usePlaylist ); } // public stuff + + +bool MediaPlayerState::streaming() { + return isStreaming; +} + bool MediaPlayerState::fullscreen() { return isFullscreen; } bool MediaPlayerState::scaled() { return isScaled; } bool MediaPlayerState::looping() { return isLooping; } bool MediaPlayerState::shuffled() { return isShuffled; } bool MediaPlayerState:: playlist() { return usePlaylist; } bool MediaPlayerState::paused() { return isPaused; } bool MediaPlayerState::playing() { return isPlaying; } +bool MediaPlayerState::stop() { + return isStoped; +} + long MediaPlayerState::position() { return curPosition; } long MediaPlayerState::length() { return curLength; } char MediaPlayerState::view() { return curView; } // slots +void MediaPlayerState::setIsStreaming( bool b ) { + if ( isStreaming == b ) { + return; + } + isStreaming = b; +} + + void MediaPlayerState::setFullscreen( bool b ) { if ( isFullscreen == b ) { return; } isFullscreen = b; emit fullscreenToggled(b); } void MediaPlayerState::setScaled( bool b ) { if ( isScaled == b ) { return; } isScaled = b; emit scaledToggled(b); } void MediaPlayerState::setLooping( bool b ) { if ( isLooping == b ) { return; } isLooping = b; emit loopingToggled(b); } void MediaPlayerState::setShuffled( bool b ) { if ( isShuffled == b ) { return; } isShuffled = b; emit shuffledToggled(b); } void MediaPlayerState::setPlaylist( bool b ) { if ( usePlaylist == b ) { return; } usePlaylist = b; emit playlistToggled(b); } void MediaPlayerState::setPaused( bool b ) { if ( isPaused == b ) { return; } isPaused = b; emit pausedToggled(b); } void MediaPlayerState::setPlaying( bool b ) { if ( isPlaying == b ) { return; } isPlaying = b; + isStoped = !b; emit playingToggled(b); } +void MediaPlayerState::setStop( bool b ) { + if ( isStoped == b ) { + return; + } + isStoped = b; + emit stopToggled(b); +} + void MediaPlayerState::setPosition( long p ) { if ( curPosition == p ) { return; } curPosition = p; emit positionChanged(p); } void MediaPlayerState::updatePosition( long p ){ if ( curPosition == p ) { return; } curPosition = p; emit positionUpdated(p); } void MediaPlayerState::setLength( long l ) { if ( curLength == l ) { return; } curLength = l; emit lengthChanged(l); } void MediaPlayerState::setView( char v ) { if ( curView == v ) { return; } curView = v; emit viewChanged(v); } void MediaPlayerState::setPrev(){ emit prev(); } void MediaPlayerState::setNext() { emit next(); } void MediaPlayerState::setList() { setPlaying( FALSE ); setView('l'); } void MediaPlayerState::setVideo() { setView('v'); } void MediaPlayerState::setAudio() { setView('a'); } - - void MediaPlayerState::toggleFullscreen() { setFullscreen( !isFullscreen ); } void MediaPlayerState::toggleScaled() { setScaled( !isScaled); } void MediaPlayerState::toggleLooping() { setLooping( !isLooping); } void MediaPlayerState::toggleShuffled() { setShuffled( !isShuffled); } void MediaPlayerState::togglePlaylist() { setPlaylist( !usePlaylist); } void MediaPlayerState::togglePaused() { setPaused( !isPaused); } void MediaPlayerState::togglePlaying() { setPlaying( !isPlaying); } diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index dbbb0f2..20e3552 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h @@ -1,94 +1,100 @@ #ifndef MEDIA_PLAYER_STATE_H #define MEDIA_PLAYER_STATE_H #include <qobject.h> class MediaPlayerDecoder; class Config; class MediaPlayerState : public QObject { Q_OBJECT public: MediaPlayerState( QObject *parent, const char *name ); ~MediaPlayerState(); - bool isStreaming; + bool streaming(); bool fullscreen(); bool scaled(); bool looping(); bool shuffled(); bool playlist(); bool paused(); bool playing(); + bool stop(); long position(); long length(); char view(); public slots: + void setIsStreaming( bool b ); void setFullscreen( bool b ); void setScaled( bool b ); void setLooping( bool b ); void setShuffled( bool b ); void setPlaylist( bool b ); void setPaused( bool b ); void setPlaying( bool b ); + void setStop( bool b ); void setPosition( long p ); void updatePosition( long p ); void setLength( long l ); void setView( char v ); void setPrev(); void setNext(); void setList(); void setVideo(); void setAudio(); void toggleFullscreen(); void toggleScaled(); void toggleLooping(); void toggleShuffled(); void togglePlaylist(); void togglePaused(); void togglePlaying(); signals: void fullscreenToggled( bool ); void scaledToggled( bool ); void loopingToggled( bool ); void shuffledToggled( bool ); void playlistToggled( bool ); void pausedToggled( bool ); void playingToggled( bool ); + void stopToggled( bool ); void positionChanged( long ); // When the slider is moved void positionUpdated( long ); // When the media file progresses void lengthChanged( long ); void viewChanged( char ); void prev(); void next(); private: + bool isStreaming; bool isFullscreen; bool isScaled; bool isLooping; bool isShuffled; bool usePlaylist; bool isPaused; bool isPlaying; + bool isStoped; long curPosition; long curLength; char curView; void readConfig( Config& cfg ); void writeConfig( Config& cfg ) const; }; #endif // MEDIA_PLAYER_STATE_H diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index cda9be2..5b674f8 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp @@ -1,59 +1,62 @@ #include "xinecontrol.h" #include "mediaplayerstate.h" extern MediaPlayerState *mediaPlayerState; XineControl::XineControl( QObject *parent, const char *name ) : QObject( parent, name ) { libXine = new XINE::Lib(); connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) ); connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); } XineControl::~XineControl() { delete libXine; } void XineControl::play( const QString& fileName ) { libXine->play( fileName ); mediaPlayerState->setPlaying( true ); // default to audio view until we know how to handle video mediaPlayerState->setView('a'); // determines of slider is shown - mediaPlayerState->isStreaming = false; + // mediaPlayerState->setIsStreaming( false ); // hier dann schaun welcher view } void XineControl::stop( bool isSet ) { - if ( isSet) { + if ( !isSet) { libXine->stop(); + mediaPlayerState->setNext(); + //mediaPlayerState->setPlaying( false ); + } else { + // play again } - // mediaPlayerState->setPlaying( false ); } void XineControl::pause( bool isSet) { libXine->pause(); } int XineControl::currentTime() { // todo: jede sekunde überprüfen m_currentTime = libXine->currentTime(); return m_currentTime; } void XineControl::length() { m_length = libXine->length(); mediaPlayerState->setLength( m_length ); } int XineControl::position() { m_position = (m_currentTime/m_length*100); mediaPlayerState->setPosition( m_position ); return m_position; emit positionChanged( m_position ); } |