summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayer.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index a9c74c4..8acc488 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -21,28 +21,26 @@
21// for setBacklight() 21// for setBacklight()
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <sys/file.h> 23#include <sys/file.h>
24#include <sys/ioctl.h> 24#include <sys/ioctl.h>
25 25
26 26
27extern VideoWidget *videoUI;
28extern PlayListWidget *playList;
29 27
30 28
31#define FBIOBLANK 0x4611 29#define FBIOBLANK 0x4611
32 30
33MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 31MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
34 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { 32 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
35 33
36 audioUI = 0; 34 audioUI = 0;
37 videoUI = 0; 35 videoUI = 0;
38 xineControl = 0; 36 xineControl = 0;
39 recreateAudioAndVideoWidgets(); 37 recreateAudioAndVideoWidgets();
40 38
41 fd=-1;fl=-1; 39 fd=-1;fl=-1;
42 playList->setCaption( tr( "OpiePlayer: Initializating" ) ); 40 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
43 41
44 qApp->processEvents(); 42 qApp->processEvents();
45 // QPEApplication::grabKeyboard(); // EVIL 43 // QPEApplication::grabKeyboard(); // EVIL
46 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 44 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
47 45
48 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 46 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
@@ -54,13 +52,13 @@ MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent,
54 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 52 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
55 53
56 volControl = new VolumeControl; 54 volControl = new VolumeControl;
57 Config cfg( "OpiePlayer" ); 55 Config cfg( "OpiePlayer" );
58 cfg.setGroup("PlayList"); 56 cfg.setGroup("PlayList");
59 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 57 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
60 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 58 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
61} 59}
62 60
63MediaPlayer::~MediaPlayer() { 61MediaPlayer::~MediaPlayer() {
64 delete xineControl; 62 delete xineControl;
65 delete volControl; 63 delete volControl;
66} 64}
@@ -84,26 +82,26 @@ void MediaPlayer::setPlaying( bool play ) {
84 if ( mediaPlayerState.isPaused() ) { 82 if ( mediaPlayerState.isPaused() ) {
85 mediaPlayerState.setPaused( FALSE ); 83 mediaPlayerState.setPaused( FALSE );
86 return; 84 return;
87 } 85 }
88 86
89 QString tickerText, time, fileName; 87 QString tickerText, time, fileName;
90 if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { 88 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
91 //if playing in file list.. play in a different way 89 //if playing in file list.. play in a different way
92 // random and looping settings enabled causes problems here, 90 // random and looping settings enabled causes problems here,
93 // since there is no selected file in the playlist, but a selected file in the file list, 91 // since there is no selected file in the playlist, but a selected file in the file list,
94 // so we remember and shutoff 92 // so we remember and shutoff
95 l = mediaPlayerState.isLooping(); 93 l = mediaPlayerState.isLooping();
96 if(l) { 94 if(l) {
97 mediaPlayerState.setLooping( false ); 95 mediaPlayerState.setLooping( false );
98 } 96 }
99 r = mediaPlayerState.isShuffled(); 97 r = mediaPlayerState.isShuffled();
100 mediaPlayerState.setShuffled( false ); 98 mediaPlayerState.setShuffled( false );
101 } 99 }
102 100
103 PlayListWidget::Entry playListEntry = playList->currentEntry(); 101 PlayListWidget::Entry playListEntry = playList.currentEntry();
104 fileName = playListEntry.name; 102 fileName = playListEntry.name;
105 xineControl->play( playListEntry.file ); 103 xineControl->play( playListEntry.file );
106 104
107 long seconds = mediaPlayerState.length(); 105 long seconds = mediaPlayerState.length();
108 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
109 107
@@ -123,33 +121,33 @@ void MediaPlayer::setPlaying( bool play ) {
123 } 121 }
124 audioUI->setTickerText( tickerText ); 122 audioUI->setTickerText( tickerText );
125} 123}
126 124
127 125
128void MediaPlayer::prev() { 126void MediaPlayer::prev() {
129 if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 127 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
130 if ( playList->prev() ) { 128 if ( playList.prev() ) {
131 play(); 129 play();
132 } else if ( mediaPlayerState.isLooping() ) { 130 } else if ( mediaPlayerState.isLooping() ) {
133 if ( playList->last() ) { 131 if ( playList.last() ) {
134 play(); 132 play();
135 } 133 }
136 } else { 134 } else {
137 mediaPlayerState.setList(); 135 mediaPlayerState.setList();
138 } 136 }
139 } 137 }
140} 138}
141 139
142 140
143void MediaPlayer::next() { 141void MediaPlayer::next() {
144 142
145 if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 143 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
146 if ( playList->next() ) { 144 if ( playList.next() ) {
147 play(); 145 play();
148 } else if ( mediaPlayerState.isLooping() ) { 146 } else if ( mediaPlayerState.isLooping() ) {
149 if ( playList->first() ) { 147 if ( playList.first() ) {
150 play(); 148 play();
151 } 149 }
152 } else { 150 } else {
153 mediaPlayerState.setList(); 151 mediaPlayerState.setList();
154 } 152 }
155 } else { //if playing from file list, let's just stop 153 } else { //if playing from file list, let's just stop
@@ -336,25 +334,25 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
336 } 334 }
337} 335}
338 336
339void MediaPlayer::cleanUp() {// this happens on closing 337void MediaPlayer::cleanUp() {// this happens on closing
340 Config cfg( "OpiePlayer" ); 338 Config cfg( "OpiePlayer" );
341 mediaPlayerState.writeConfig( cfg ); 339 mediaPlayerState.writeConfig( cfg );
342 playList->writeDefaultPlaylist( ); 340 playList.writeDefaultPlaylist( );
343 341
344// QPEApplication::grabKeyboard(); 342// QPEApplication::grabKeyboard();
345// QPEApplication::ungrabKeyboard(); 343// QPEApplication::ungrabKeyboard();
346} 344}
347 345
348void MediaPlayer::recreateAudioAndVideoWidgets() 346void MediaPlayer::recreateAudioAndVideoWidgets()
349{ 347{
350 delete xineControl; 348 delete xineControl;
351 delete audioUI; 349 delete audioUI;
352 delete videoUI; 350 delete videoUI;
353 audioUI = new AudioWidget( mediaPlayerState, 0, "audioUI" ); 351 audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
354 videoUI = new VideoWidget( mediaPlayerState, 0, "videoUI" ); 352 videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
355 353
356 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 354 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
357 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 355 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
358 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 356 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
359 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 357 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
360 358