Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

mediaplayerstate.cpp

Go to the documentation of this file.
00001 /*
00002                             This file is part of the Opie Project
00003 
00004                              Copyright (c)  2002 Max Reiss <harlekin@handhelds.org>
00005                              Copyright (c)  2002 L. Potter <ljp@llornkcor.com>
00006                              Copyright (c)  2002 Holger Freyther <zecke@handhelds.org>
00007               =.
00008             .=l.
00009            .>+-=
00010  _;:,     .>    :=|.         This program is free software; you can
00011 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00012 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00013 .="- .-=="i,     .._         License as published by the Free Software
00014  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00015      ._= =}       :          or (at your option) any later version.
00016     .%`+i>       _;_.
00017     .i_,=:_.      -<s.       This program is distributed in the hope that
00018      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00019     : ..    .:,     . . .    without even the implied warranty of
00020     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00021   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00022 ..}^=.=       =       ;      General Public License for more
00023 ++=   -.     .`     .:       details.
00024  :     =  ...= . :.=-
00025  -.   .:....=;==+<;          You should have received a copy of the GNU
00026   -_. . .   )=.  =           General Public License along with
00027     --        :-=`           this library; see the file COPYING.LIB.
00028                              If not, write to the Free Software Foundation,
00029                              Inc., 59 Temple Place - Suite 330,
00030                              Boston, MA 02111-1307, USA.
00031 
00032 */
00033 
00034 // this file is based on work by trolltech
00035 
00036 #include <qpe/config.h>
00037 #include "mediaplayerstate.h"
00038 
00039 #include <assert.h>
00040 
00041 #define MediaPlayerDebug(x)
00042 
00043 
00044 MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
00045         : QObject( parent, name ) {
00046     Config cfg( "OpiePlayer" );
00047     readConfig( cfg );
00048     streaming = false;
00049     seekable = true;
00050 }
00051 
00052 
00053 MediaPlayerState::~MediaPlayerState() {
00054     Config cfg( "OpiePlayer" );
00055     writeConfig( cfg );
00056 }
00057 
00058 
00059 void MediaPlayerState::readConfig( Config& cfg ) {
00060     cfg.setGroup("Options");
00061     fullscreen = cfg.readBoolEntry( "FullScreen" );
00062     scaled = cfg.readBoolEntry( "Scaling" );
00063     looping = cfg.readBoolEntry( "Looping" );
00064     shuffled = cfg.readBoolEntry( "Shuffle" );
00065     videoGamma = cfg.readNumEntry( "VideoGamma" );
00066     playing = FALSE;
00067     streaming = FALSE;
00068     paused = FALSE;
00069     curPosition = 0;
00070     curLength = 0;
00071     m_displayType = MediaSelection;
00072 }
00073 
00074 
00075 void MediaPlayerState::writeConfig( Config& cfg ) const {
00076     cfg.setGroup( "Options" );
00077     cfg.writeEntry( "FullScreen", fullscreen );
00078     cfg.writeEntry( "Scaling", scaled );
00079     cfg.writeEntry( "Looping", looping );
00080     cfg.writeEntry( "Shuffle", shuffled );
00081     cfg.writeEntry( "VideoGamma",  videoGamma );
00082 }
00083 
00084 MediaPlayerState::DisplayType MediaPlayerState::displayType() const
00085 {
00086     return m_displayType;
00087 }
00088 
00089 // slots
00090 void MediaPlayerState::setIsStreaming( bool b ) {
00091     streaming = b;
00092 }
00093 
00094 void MediaPlayerState::setIsSeekable( bool b ) {
00095     seekable = b;
00096     emit isSeekableToggled(b);
00097 }
00098 
00099 
00100 void MediaPlayerState::setFullscreen( bool b ) {
00101     if ( fullscreen == b ) {
00102         return;
00103     }
00104     fullscreen = b;
00105     emit fullscreenToggled(b);
00106 }
00107 
00108 
00109 void MediaPlayerState::setBlanked( bool b ) {
00110     if ( blanked == b ) {
00111         return;
00112     }
00113     blanked = b;
00114     emit blankToggled(b);
00115 }
00116 
00117 
00118 void MediaPlayerState::setScaled( bool b ) {
00119     if ( scaled == b ) {
00120         return;
00121     }
00122     scaled = b;
00123     emit scaledToggled(b);
00124 }
00125 
00126 void MediaPlayerState::setLooping( bool b ) {
00127     if ( looping    == b ) {
00128         return;
00129     }
00130     looping = b;
00131     emit loopingToggled(b);
00132 }
00133 
00134 void MediaPlayerState::setShuffled( bool b ) {
00135     if ( shuffled   == b ) {
00136         return;
00137     }
00138     shuffled = b;
00139     emit shuffledToggled(b);
00140 }
00141 
00142 void MediaPlayerState::setPaused( bool b ) {
00143       if ( paused  == b ) {
00144           paused = FALSE;
00145           emit pausedToggled(FALSE);
00146           return;
00147       }
00148      paused = b;
00149      emit pausedToggled(b);
00150 }
00151 
00152 void MediaPlayerState::setPlaying( bool b ) {
00153     if ( playing  == b ) {
00154         return;
00155     }
00156     playing = b;
00157     stopped = !b;
00158     emit playingToggled(b);
00159 }
00160 
00161 void MediaPlayerState::setStopped( bool b ) {
00162     if ( stopped  == b ) {
00163         return;
00164     }
00165     stopped = b;
00166     emit stopToggled(b);
00167 }
00168 
00169 void MediaPlayerState::setPosition( long p ) {
00170     if ( curPosition == p ) {
00171         return;
00172     }
00173     curPosition = p;
00174     emit positionChanged(p);
00175 }
00176 
00177 void MediaPlayerState::updatePosition( long p ){
00178     if ( curPosition  == p ) {
00179         return;
00180     }
00181     curPosition = p;
00182     emit positionUpdated(p);
00183 }
00184 
00185 void MediaPlayerState::setVideoGamma( int v ){
00186     if ( videoGamma  == v ) {
00187         return;
00188     }
00189     videoGamma = v;
00190     emit videoGammaChanged( v );
00191 }
00192 
00193 void MediaPlayerState::setLength( long l ) {
00194     if ( curLength  == l ) {
00195         return;
00196     }
00197     curLength = l;
00198     emit lengthChanged(l);
00199 }
00200 
00201 void MediaPlayerState::setDisplayType( DisplayType displayType )
00202 {
00203     if ( m_displayType == displayType )
00204         return;
00205 
00206     m_displayType = displayType;
00207     emit displayTypeChanged( m_displayType );
00208 }
00209 
00210 void MediaPlayerState::setPrev(){
00211     emit prev();
00212 }
00213 
00214 void MediaPlayerState::setNext() {
00215     emit next();
00216 }
00217 
00218 void MediaPlayerState::setList() {
00219     setPlaying( FALSE );
00220     paused = false;
00221     setDisplayType( MediaSelection );
00222 }
00223 
00224 void MediaPlayerState::setVideo() {
00225     setDisplayType( Video );
00226 }
00227 
00228 void MediaPlayerState::setAudio() {
00229     setDisplayType( Audio );
00230 }
00231 
00232 void MediaPlayerState::toggleFullscreen() {
00233     setFullscreen( !fullscreen );
00234 }
00235 
00236 void MediaPlayerState::toggleScaled() {
00237     setScaled( !scaled);
00238 }
00239 
00240 void MediaPlayerState::toggleLooping() {
00241     setLooping( !looping);
00242 }
00243 
00244 void MediaPlayerState::toggleShuffled() {
00245     setShuffled( !shuffled);
00246 }
00247 
00248 void MediaPlayerState::togglePaused() {
00249     setPaused( !paused);
00250 }
00251 
00252 void MediaPlayerState::togglePlaying() {
00253     setPlaying( !playing);
00254 }
00255 
00256 void MediaPlayerState::toggleBlank() {
00257     setBlanked( !blanked);
00258 }
00259 
00260 
00261 
00262 
00263 
00264 

Generated on Sat Nov 5 16:15:38 2005 for OPIE by  doxygen 1.4.2