summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 8b0f501..1f19b30 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,161 +1,164 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 6#include <qfileinfo.h>
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qfile.h> 11#include <qfile.h>
12 12
13#include "mediaplayer.h" 13#include "mediaplayer.h"
14#include "playlistwidget.h" 14#include "playlistwidget.h"
15#include "audiowidget.h" 15#include "audiowidget.h"
16#include "videowidget.h" 16#include "videowidget.h"
17#include "volumecontrol.h" 17#include "volumecontrol.h"
18 18
19#include "mediaplayerstate.h" 19#include "mediaplayerstate.h"
20 20
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 AudioWidget *audioUI; 27extern AudioWidget *audioUI;
28extern VideoWidget *videoUI; 28extern VideoWidget *videoUI;
29extern PlayListWidget *playList; 29extern PlayListWidget *playList;
30extern MediaPlayerState *mediaPlayerState; 30extern MediaPlayerState *mediaPlayerState;
31 31
32 32
33#define FBIOBLANK 0x4611 33#define FBIOBLANK 0x4611
34 34
35MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 35MediaPlayer::MediaPlayer( QObject *parent, const char *name )
36 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 36 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
37 37
38 fd=-1;fl=-1; 38 fd=-1;fl=-1;
39 playList->setCaption( tr( "OpiePlayer: Initializating" ) ); 39 playList->setCaption( tr( "OpiePlayer: Initializating" ) );
40 40
41 qApp->processEvents(); 41 qApp->processEvents();
42 // QPEApplication::grabKeyboard(); // EVIL 42 // QPEApplication::grabKeyboard(); // EVIL
43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 43 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
44 44
45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
46 46
47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
48 48
49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 49 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 50 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 51 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
52 52
53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 53 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 54 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
57 57
58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 58 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 59 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 61 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
62 62
63 volControl = new VolumeControl; 63 volControl = new VolumeControl;
64 xineControl = new XineControl(); 64 xineControl = new XineControl();
65 playList->setCaption(tr("OpiePlayer")); 65 Config cfg( "OpiePlayer" );
66 cfg.setGroup("PlayList");
67 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
68 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
66} 69}
67 70
68MediaPlayer::~MediaPlayer() { 71MediaPlayer::~MediaPlayer() {
69 delete xineControl; 72 delete xineControl;
70 delete volControl; 73 delete volControl;
71} 74}
72 75
73void MediaPlayer::pauseCheck( bool b ) { 76void MediaPlayer::pauseCheck( bool b ) {
74 if ( b && !mediaPlayerState->playing() ) { 77 if ( b && !mediaPlayerState->playing() ) {
75 mediaPlayerState->setPaused( FALSE ); 78 mediaPlayerState->setPaused( FALSE );
76 } 79 }
77} 80}
78 81
79void MediaPlayer::play() { 82void MediaPlayer::play() {
80 mediaPlayerState->setPlaying( FALSE ); 83 mediaPlayerState->setPlaying( FALSE );
81 mediaPlayerState->setPlaying( TRUE ); 84 mediaPlayerState->setPlaying( TRUE );
82} 85}
83 86
84void MediaPlayer::setPlaying( bool play ) { 87void MediaPlayer::setPlaying( bool play ) {
85 if ( !play ) { 88 if ( !play ) {
86 return; 89 return;
87 } 90 }
88 91
89 if ( mediaPlayerState->paused() ) { 92 if ( mediaPlayerState->paused() ) {
90 mediaPlayerState->setPaused( FALSE ); 93 mediaPlayerState->setPaused( FALSE );
91 return; 94 return;
92 } 95 }
93 96
94 QString tickerText, time, fileName; 97 QString tickerText, time, fileName;
95 if( playList->whichList() == 0 ) { //check for filelist 98 if( playList->whichList() == 0 ) { //check for filelist
96 const DocLnk *playListCurrent = playList->current(); 99 const DocLnk *playListCurrent = playList->current();
97 if ( playListCurrent != NULL ) { 100 if ( playListCurrent != NULL ) {
98 currentFile = playListCurrent; 101 currentFile = playListCurrent;
99 } 102 }
100 xineControl->play( currentFile->file() ); 103 xineControl->play( currentFile->file() );
101 fileName = currentFile->name(); 104 fileName = currentFile->name();
102 long seconds = mediaPlayerState->length();// 105 long seconds = mediaPlayerState->length();//
103 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
104 //qDebug(time); 107 //qDebug(time);
105 108
106 } else { 109 } else {
107 //if playing in file list.. play in a different way 110 //if playing in file list.. play in a different way
108 // random and looping settings enabled causes problems here, 111 // random and looping settings enabled causes problems here,
109 // since there is no selected file in the playlist, but a selected file in the file list, 112 // since there is no selected file in the playlist, but a selected file in the file list,
110 // so we remember and shutoff 113 // so we remember and shutoff
111 l = mediaPlayerState->looping(); 114 l = mediaPlayerState->looping();
112 if(l) { 115 if(l) {
113 mediaPlayerState->setLooping( false ); 116 mediaPlayerState->setLooping( false );
114 } 117 }
115 r = mediaPlayerState->shuffled(); 118 r = mediaPlayerState->shuffled();
116 mediaPlayerState->setShuffled( false ); 119 mediaPlayerState->setShuffled( false );
117 120
118 fileName = playList->currentFileListPathName(); 121 fileName = playList->currentFileListPathName();
119 xineControl->play( fileName ); 122 xineControl->play( fileName );
120 long seconds = mediaPlayerState->length(); 123 long seconds = mediaPlayerState->length();
121 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 124 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
122 //qDebug(time); 125 //qDebug(time);
123 if( fileName.left(4) != "http" ) { 126 if( fileName.left(4) != "http" ) {
124 fileName = QFileInfo( fileName ).baseName(); 127 fileName = QFileInfo( fileName ).baseName();
125 } 128 }
126 129
127 } 130 }
128 131
129 if( fileName.left(4) == "http" ) { 132 if( fileName.left(4) == "http" ) {
130 if ( xineControl->getMetaInfo().isEmpty() ) { 133 if ( xineControl->getMetaInfo().isEmpty() ) {
131 tickerText = tr( " File: " ) + fileName; 134 tickerText = tr( " File: " ) + fileName;
132 } else { 135 } else {
133 tickerText = xineControl->getMetaInfo(); 136 tickerText = xineControl->getMetaInfo();
134 } 137 }
135 } else { 138 } else {
136 if ( xineControl->getMetaInfo().isEmpty() ) { 139 if ( xineControl->getMetaInfo().isEmpty() ) {
137 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 140 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
138 } else { 141 } else {
139 tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; 142 tickerText = xineControl->getMetaInfo() + " Length: " + time + " ";
140 } 143 }
141 } 144 }
142 audioUI->setTickerText( tickerText ); 145 audioUI->setTickerText( tickerText );
143} 146}
144 147
145 148
146void MediaPlayer::prev() { 149void MediaPlayer::prev() {
147 if( playList->whichList() == 0 ) { //if using the playlist 150 if( playList->whichList() == 0 ) { //if using the playlist
148 if ( playList->prev() ) { 151 if ( playList->prev() ) {
149 play(); 152 play();
150 } else if ( mediaPlayerState->looping() ) { 153 } else if ( mediaPlayerState->looping() ) {
151 if ( playList->last() ) { 154 if ( playList->last() ) {
152 play(); 155 play();
153 } 156 }
154 } else { 157 } else {
155 mediaPlayerState->setList(); 158 mediaPlayerState->setList();
156 } 159 }
157 } 160 }
158} 161}
159 162
160 163
161void MediaPlayer::next() { 164void MediaPlayer::next() {