summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 23:33:37 (UTC)
committer simon <simon>2002-12-02 23:33:37 (UTC)
commitc3c95ff297355f7024c15134bbc1d15d340bf8fd (patch) (side-by-side diff)
treead5ed1eef8ad82d53aef634bfa4b247210200c20
parent22e232bdb4bae5e28013a4d14bfda3c068827557 (diff)
downloadopie-c3c95ff297355f7024c15134bbc1d15d340bf8fd.zip
opie-c3c95ff297355f7024c15134bbc1d15d340bf8fd.tar.gz
opie-c3c95ff297355f7024c15134bbc1d15d340bf8fd.tar.bz2
- I better be a good boy and delete what I allocate :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 8acc488..06b1a04 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,190 +1,192 @@
#include <qpe/qpeapplication.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qcopenvelope_qws.h>
#include <qfileinfo.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qwidgetstack.h>
#include <qfile.h>
#include "mediaplayer.h"
#include "playlistwidget.h"
#include "audiowidget.h"
#include "videowidget.h"
#include "volumecontrol.h"
#include "mediaplayerstate.h"
// for setBacklight()
#include <linux/fb.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#define FBIOBLANK 0x4611
MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
: QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
audioUI = 0;
videoUI = 0;
xineControl = 0;
recreateAudioAndVideoWidgets();
fd=-1;fl=-1;
playList.setCaption( tr( "OpiePlayer: Initializating" ) );
qApp->processEvents();
// QPEApplication::grabKeyboard(); // EVIL
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( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
volControl = new VolumeControl;
Config cfg( "OpiePlayer" );
cfg.setGroup("PlayList");
QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
}
MediaPlayer::~MediaPlayer() {
delete xineControl;
+ delete audioUI;
+ delete videoUI;
delete volControl;
}
void MediaPlayer::pauseCheck( bool b ) {
if ( b && !mediaPlayerState.isPlaying() ) {
mediaPlayerState.setPaused( FALSE );
}
}
void MediaPlayer::play() {
mediaPlayerState.setPlaying( FALSE );
mediaPlayerState.setPlaying( TRUE );
}
void MediaPlayer::setPlaying( bool play ) {
if ( !play ) {
return;
}
if ( mediaPlayerState.isPaused() ) {
mediaPlayerState.setPaused( FALSE );
return;
}
QString tickerText, time, fileName;
if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
//if playing in file list.. play in a different way
// random and looping settings enabled causes problems here,
// since there is no selected file in the playlist, but a selected file in the file list,
// so we remember and shutoff
l = mediaPlayerState.isLooping();
if(l) {
mediaPlayerState.setLooping( false );
}
r = mediaPlayerState.isShuffled();
mediaPlayerState.setShuffled( false );
}
PlayListWidget::Entry playListEntry = playList.currentEntry();
fileName = playListEntry.name;
xineControl->play( playListEntry.file );
long seconds = mediaPlayerState.length();
time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
if( fileName.left(4) == "http" ) {
fileName = QFileInfo( fileName ).baseName();
if ( xineControl->getMetaInfo().isEmpty() ) {
tickerText = tr( " File: " ) + fileName;
} else {
tickerText = xineControl->getMetaInfo();
}
} else {
if ( xineControl->getMetaInfo().isEmpty() ) {
tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
} else {
tickerText = xineControl->getMetaInfo() + " Length: " + time + " ";
}
}
audioUI->setTickerText( tickerText );
}
void MediaPlayer::prev() {
if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
if ( playList.prev() ) {
play();
} else if ( mediaPlayerState.isLooping() ) {
if ( playList.last() ) {
play();
}
} else {
mediaPlayerState.setList();
}
}
}
void MediaPlayer::next() {
if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
if ( playList.next() ) {
play();
} else if ( mediaPlayerState.isLooping() ) {
if ( playList.first() ) {
play();
}
} else {
mediaPlayerState.setList();
}
} else { //if playing from file list, let's just stop
qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
mediaPlayerState.setPlaying(false);
mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
if(l) mediaPlayerState.setLooping(l);
if(r) mediaPlayerState.setShuffled(r);
}
qApp->processEvents();
}
void MediaPlayer::startDecreasingVolume() {
volumeDirection = -1;
startTimer( 100 );
volControl->decVol(2);
}
void MediaPlayer::startIncreasingVolume() {
volumeDirection = +1;
startTimer( 100 );
volControl->incVol(2);
}
bool drawnOnScreenDisplay = FALSE;
unsigned int onScreenDisplayVolume = 0;
const int yoff = 110;
void MediaPlayer::stopChangingVolume() {
killTimers();
// Get rid of the on-screen display stuff
drawnOnScreenDisplay = FALSE;
onScreenDisplayVolume = 0;
int w=0;
int h=0;
if( !xineControl->hasVideo() ) {
w = audioUI->width();