author | simon <simon> | 2002-12-02 20:36:40 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 20:36:40 (UTC) |
commit | 0090a335a7162f4b0d34f78850ebf9a8bd544c01 (patch) (unidiff) | |
tree | aedbe7cbf4f30bb72dd4ded98f128227694de4b9 | |
parent | 6cd1494f86f2f60614c9b9a7b959666dec2500ee (diff) | |
download | opie-0090a335a7162f4b0d34f78850ebf9a8bd544c01.zip opie-0090a335a7162f4b0d34f78850ebf9a8bd544c01.tar.gz opie-0090a335a7162f4b0d34f78850ebf9a8bd544c01.tar.bz2 |
- removed last traces of mediaPlayerState singleton. yay :)
-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 33 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 5 |
4 files changed, 21 insertions, 21 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index fd47ea5..7d11ca0 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp | |||
@@ -1,34 +1,32 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include "mediaplayerstate.h" | 3 | #include "mediaplayerstate.h" |
4 | #include "playlistwidget.h" | 4 | #include "playlistwidget.h" |
5 | #include "audiowidget.h" | 5 | #include "audiowidget.h" |
6 | #include "videowidget.h" | 6 | #include "videowidget.h" |
7 | #include "mediaplayer.h" | 7 | #include "mediaplayer.h" |
8 | 8 | ||
9 | MediaPlayerState *mediaPlayerState; | ||
10 | PlayListWidget *playList; | 9 | PlayListWidget *playList; |
11 | AudioWidget *audioUI; | 10 | AudioWidget *audioUI; |
12 | VideoWidget *videoUI; | 11 | VideoWidget *videoUI; |
13 | 12 | ||
14 | int main(int argc, char **argv) { | 13 | int main(int argc, char **argv) { |
15 | QPEApplication a(argc,argv); | 14 | QPEApplication a(argc,argv); |
16 | 15 | ||
17 | MediaPlayerState st( 0, "mediaPlayerState" ); | 16 | MediaPlayerState st( 0, "mediaPlayerState" ); |
18 | mediaPlayerState = &st; | ||
19 | PlayListWidget pl( st, 0, "playList" ); | 17 | PlayListWidget pl( st, 0, "playList" ); |
20 | playList = &pl; | 18 | playList = &pl; |
21 | pl.showMaximized(); | 19 | pl.showMaximized(); |
22 | AudioWidget aw( st, 0, "audioUI" ); | 20 | AudioWidget aw( st, 0, "audioUI" ); |
23 | audioUI = &aw; | 21 | audioUI = &aw; |
24 | VideoWidget vw( st, 0, "videoUI" ); | 22 | VideoWidget vw( st, 0, "videoUI" ); |
25 | videoUI = &vw; | 23 | videoUI = &vw; |
26 | a.processEvents(); | 24 | a.processEvents(); |
27 | MediaPlayer mp( st, 0, "mediaPlayer" ); | 25 | MediaPlayer mp( st, 0, "mediaPlayer" ); |
28 | 26 | ||
29 | a.showMainDocumentWidget(&pl); | 27 | a.showMainDocumentWidget(&pl); |
30 | 28 | ||
31 | return a.exec(); | 29 | return a.exec(); |
32 | } | 30 | } |
33 | 31 | ||
34 | 32 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 424259b..eccb5d9 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,353 +1,353 @@ | |||
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 | ||
27 | extern AudioWidget *audioUI; | 27 | extern AudioWidget *audioUI; |
28 | extern VideoWidget *videoUI; | 28 | extern VideoWidget *videoUI; |
29 | extern PlayListWidget *playList; | 29 | extern PlayListWidget *playList; |
30 | 30 | ||
31 | 31 | ||
32 | #define FBIOBLANK 0x4611 | 32 | #define FBIOBLANK 0x4611 |
33 | 33 | ||
34 | MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 34 | MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
35 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { | 35 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { |
36 | 36 | ||
37 | fd=-1;fl=-1; | 37 | fd=-1;fl=-1; |
38 | playList->setCaption( tr( "OpiePlayer: Initializating" ) ); | 38 | playList->setCaption( tr( "OpiePlayer: Initializating" ) ); |
39 | 39 | ||
40 | qApp->processEvents(); | 40 | qApp->processEvents(); |
41 | // QPEApplication::grabKeyboard(); // EVIL | 41 | // QPEApplication::grabKeyboard(); // EVIL |
42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 42 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
43 | 43 | ||
44 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 44 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
45 | 45 | ||
46 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
47 | 47 | ||
48 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 48 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
49 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 49 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
50 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 50 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
51 | 51 | ||
52 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 52 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
53 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 53 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
54 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 54 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
55 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 55 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
56 | 56 | ||
57 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 57 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
58 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 58 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
59 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 59 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
60 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 60 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
61 | 61 | ||
62 | volControl = new VolumeControl; | 62 | volControl = new VolumeControl; |
63 | xineControl = new XineControl(); | 63 | xineControl = new XineControl( mediaPlayerState ); |
64 | Config cfg( "OpiePlayer" ); | 64 | Config cfg( "OpiePlayer" ); |
65 | cfg.setGroup("PlayList"); | 65 | cfg.setGroup("PlayList"); |
66 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 66 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
67 | playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 67 | playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
68 | } | 68 | } |
69 | 69 | ||
70 | MediaPlayer::~MediaPlayer() { | 70 | MediaPlayer::~MediaPlayer() { |
71 | delete xineControl; | 71 | delete xineControl; |
72 | delete volControl; | 72 | delete volControl; |
73 | } | 73 | } |
74 | 74 | ||
75 | void MediaPlayer::pauseCheck( bool b ) { | 75 | void MediaPlayer::pauseCheck( bool b ) { |
76 | if ( b && !mediaPlayerState.isPlaying() ) { | 76 | if ( b && !mediaPlayerState.isPlaying() ) { |
77 | mediaPlayerState.setPaused( FALSE ); | 77 | mediaPlayerState.setPaused( FALSE ); |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | void MediaPlayer::play() { | 81 | void MediaPlayer::play() { |
82 | mediaPlayerState.setPlaying( FALSE ); | 82 | mediaPlayerState.setPlaying( FALSE ); |
83 | mediaPlayerState.setPlaying( TRUE ); | 83 | mediaPlayerState.setPlaying( TRUE ); |
84 | } | 84 | } |
85 | 85 | ||
86 | void MediaPlayer::setPlaying( bool play ) { | 86 | void MediaPlayer::setPlaying( bool play ) { |
87 | if ( !play ) { | 87 | if ( !play ) { |
88 | return; | 88 | return; |
89 | } | 89 | } |
90 | 90 | ||
91 | if ( mediaPlayerState.isPaused() ) { | 91 | if ( mediaPlayerState.isPaused() ) { |
92 | mediaPlayerState.setPaused( FALSE ); | 92 | mediaPlayerState.setPaused( FALSE ); |
93 | return; | 93 | return; |
94 | } | 94 | } |
95 | 95 | ||
96 | QString tickerText, time, fileName; | 96 | QString tickerText, time, fileName; |
97 | if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { | 97 | if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { |
98 | //if playing in file list.. play in a different way | 98 | //if playing in file list.. play in a different way |
99 | // random and looping settings enabled causes problems here, | 99 | // random and looping settings enabled causes problems here, |
100 | // since there is no selected file in the playlist, but a selected file in the file list, | 100 | // since there is no selected file in the playlist, but a selected file in the file list, |
101 | // so we remember and shutoff | 101 | // so we remember and shutoff |
102 | l = mediaPlayerState.isLooping(); | 102 | l = mediaPlayerState.isLooping(); |
103 | if(l) { | 103 | if(l) { |
104 | mediaPlayerState.setLooping( false ); | 104 | mediaPlayerState.setLooping( false ); |
105 | } | 105 | } |
106 | r = mediaPlayerState.isShuffled(); | 106 | r = mediaPlayerState.isShuffled(); |
107 | mediaPlayerState.setShuffled( false ); | 107 | mediaPlayerState.setShuffled( false ); |
108 | } | 108 | } |
109 | 109 | ||
110 | PlayListWidget::Entry playListEntry = playList->currentEntry(); | 110 | PlayListWidget::Entry playListEntry = playList->currentEntry(); |
111 | fileName = playListEntry.name; | 111 | fileName = playListEntry.name; |
112 | xineControl->play( playListEntry.file ); | 112 | xineControl->play( playListEntry.file ); |
113 | 113 | ||
114 | long seconds = mediaPlayerState.length(); | 114 | long seconds = mediaPlayerState.length(); |
115 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 115 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
116 | 116 | ||
117 | if( fileName.left(4) == "http" ) { | 117 | if( fileName.left(4) == "http" ) { |
118 | fileName = QFileInfo( fileName ).baseName(); | 118 | fileName = QFileInfo( fileName ).baseName(); |
119 | if ( xineControl->getMetaInfo().isEmpty() ) { | 119 | if ( xineControl->getMetaInfo().isEmpty() ) { |
120 | tickerText = tr( " File: " ) + fileName; | 120 | tickerText = tr( " File: " ) + fileName; |
121 | } else { | 121 | } else { |
122 | tickerText = xineControl->getMetaInfo(); | 122 | tickerText = xineControl->getMetaInfo(); |
123 | } | 123 | } |
124 | } else { | 124 | } else { |
125 | if ( xineControl->getMetaInfo().isEmpty() ) { | 125 | if ( xineControl->getMetaInfo().isEmpty() ) { |
126 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 126 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
127 | } else { | 127 | } else { |
128 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 128 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | audioUI->setTickerText( tickerText ); | 131 | audioUI->setTickerText( tickerText ); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | void MediaPlayer::prev() { | 135 | void MediaPlayer::prev() { |
136 | if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 136 | if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
137 | if ( playList->prev() ) { | 137 | if ( playList->prev() ) { |
138 | play(); | 138 | play(); |
139 | } else if ( mediaPlayerState.isLooping() ) { | 139 | } else if ( mediaPlayerState.isLooping() ) { |
140 | if ( playList->last() ) { | 140 | if ( playList->last() ) { |
141 | play(); | 141 | play(); |
142 | } | 142 | } |
143 | } else { | 143 | } else { |
144 | mediaPlayerState.setList(); | 144 | mediaPlayerState.setList(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } | 147 | } |
148 | 148 | ||
149 | 149 | ||
150 | void MediaPlayer::next() { | 150 | void MediaPlayer::next() { |
151 | 151 | ||
152 | if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 152 | if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
153 | if ( playList->next() ) { | 153 | if ( playList->next() ) { |
154 | play(); | 154 | play(); |
155 | } else if ( mediaPlayerState.isLooping() ) { | 155 | } else if ( mediaPlayerState.isLooping() ) { |
156 | if ( playList->first() ) { | 156 | if ( playList->first() ) { |
157 | play(); | 157 | play(); |
158 | } | 158 | } |
159 | } else { | 159 | } else { |
160 | mediaPlayerState.setList(); | 160 | mediaPlayerState.setList(); |
161 | } | 161 | } |
162 | } else { //if playing from file list, let's just stop | 162 | } else { //if playing from file list, let's just stop |
163 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 163 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
164 | mediaPlayerState.setPlaying(false); | 164 | mediaPlayerState.setPlaying(false); |
165 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 165 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
166 | if(l) mediaPlayerState.setLooping(l); | 166 | if(l) mediaPlayerState.setLooping(l); |
167 | if(r) mediaPlayerState.setShuffled(r); | 167 | if(r) mediaPlayerState.setShuffled(r); |
168 | } | 168 | } |
169 | qApp->processEvents(); | 169 | qApp->processEvents(); |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void MediaPlayer::startDecreasingVolume() { | 173 | void MediaPlayer::startDecreasingVolume() { |
174 | volumeDirection = -1; | 174 | volumeDirection = -1; |
175 | startTimer( 100 ); | 175 | startTimer( 100 ); |
176 | volControl->decVol(2); | 176 | volControl->decVol(2); |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | void MediaPlayer::startIncreasingVolume() { | 180 | void MediaPlayer::startIncreasingVolume() { |
181 | volumeDirection = +1; | 181 | volumeDirection = +1; |
182 | startTimer( 100 ); | 182 | startTimer( 100 ); |
183 | volControl->incVol(2); | 183 | volControl->incVol(2); |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | bool drawnOnScreenDisplay = FALSE; | 187 | bool drawnOnScreenDisplay = FALSE; |
188 | unsigned int onScreenDisplayVolume = 0; | 188 | unsigned int onScreenDisplayVolume = 0; |
189 | const int yoff = 110; | 189 | const int yoff = 110; |
190 | 190 | ||
191 | void MediaPlayer::stopChangingVolume() { | 191 | void MediaPlayer::stopChangingVolume() { |
192 | killTimers(); | 192 | killTimers(); |
193 | // Get rid of the on-screen display stuff | 193 | // Get rid of the on-screen display stuff |
194 | drawnOnScreenDisplay = FALSE; | 194 | drawnOnScreenDisplay = FALSE; |
195 | onScreenDisplayVolume = 0; | 195 | onScreenDisplayVolume = 0; |
196 | int w=0; | 196 | int w=0; |
197 | int h=0; | 197 | int h=0; |
198 | if( !xineControl->hasVideo() ) { | 198 | if( !xineControl->hasVideo() ) { |
199 | w = audioUI->width(); | 199 | w = audioUI->width(); |
200 | h = audioUI->height(); | 200 | h = audioUI->height(); |
201 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 201 | audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
202 | } else { | 202 | } else { |
203 | w = videoUI->width(); | 203 | w = videoUI->width(); |
204 | h = videoUI->height(); | 204 | h = videoUI->height(); |
205 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 205 | videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | 209 | ||
210 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 210 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
211 | if ( volumeDirection == +1 ) { | 211 | if ( volumeDirection == +1 ) { |
212 | volControl->incVol( 2 ); | 212 | volControl->incVol( 2 ); |
213 | } else if ( volumeDirection == -1 ) { | 213 | } else if ( volumeDirection == -1 ) { |
214 | volControl->decVol( 2 ); | 214 | volControl->decVol( 2 ); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
218 | // TODO FIXME | 218 | // TODO FIXME |
219 | // huh?? | 219 | // huh?? |
220 | unsigned int v= 0; | 220 | unsigned int v= 0; |
221 | v = volControl->volume(); | 221 | v = volControl->volume(); |
222 | v = v / 10; | 222 | v = v / 10; |
223 | 223 | ||
224 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 224 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | 227 | ||
228 | int w=0; int h=0; | 228 | int w=0; int h=0; |
229 | if( !xineControl->hasVideo() ) { | 229 | if( !xineControl->hasVideo() ) { |
230 | w = audioUI->width(); | 230 | w = audioUI->width(); |
231 | h = audioUI->height(); | 231 | h = audioUI->height(); |
232 | 232 | ||
233 | if ( drawnOnScreenDisplay ) { | 233 | if ( drawnOnScreenDisplay ) { |
234 | if ( onScreenDisplayVolume > v ) { | 234 | if ( onScreenDisplayVolume > v ) { |
235 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 235 | audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | drawnOnScreenDisplay = TRUE; | 238 | drawnOnScreenDisplay = TRUE; |
239 | onScreenDisplayVolume = v; | 239 | onScreenDisplayVolume = v; |
240 | QPainter p( audioUI ); | 240 | QPainter p( audioUI ); |
241 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 241 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
242 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 242 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
243 | 243 | ||
244 | QFont f; | 244 | QFont f; |
245 | f.setPixelSize( 20 ); | 245 | f.setPixelSize( 20 ); |
246 | f.setBold( TRUE ); | 246 | f.setBold( TRUE ); |
247 | p.setFont( f ); | 247 | p.setFont( f ); |
248 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 248 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
249 | 249 | ||
250 | for ( unsigned int i = 0; i < 10; i++ ) { | 250 | for ( unsigned int i = 0; i < 10; i++ ) { |
251 | if ( v > i ) { | 251 | if ( v > i ) { |
252 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 252 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
253 | } else { | 253 | } else { |
254 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 254 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } else { | 257 | } else { |
258 | w = videoUI->width(); | 258 | w = videoUI->width(); |
259 | h = videoUI->height(); | 259 | h = videoUI->height(); |
260 | 260 | ||
261 | if ( drawnOnScreenDisplay ) { | 261 | if ( drawnOnScreenDisplay ) { |
262 | if ( onScreenDisplayVolume > v ) { | 262 | if ( onScreenDisplayVolume > v ) { |
263 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 263 | videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | drawnOnScreenDisplay = TRUE; | 266 | drawnOnScreenDisplay = TRUE; |
267 | onScreenDisplayVolume = v; | 267 | onScreenDisplayVolume = v; |
268 | QPainter p( videoUI ); | 268 | QPainter p( videoUI ); |
269 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 269 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
270 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 270 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
271 | 271 | ||
272 | QFont f; | 272 | QFont f; |
273 | f.setPixelSize( 20 ); | 273 | f.setPixelSize( 20 ); |
274 | f.setBold( TRUE ); | 274 | f.setBold( TRUE ); |
275 | p.setFont( f ); | 275 | p.setFont( f ); |
276 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 276 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
277 | 277 | ||
278 | for ( unsigned int i = 0; i < 10; i++ ) { | 278 | for ( unsigned int i = 0; i < 10; i++ ) { |
279 | if ( v > i ) { | 279 | if ( v > i ) { |
280 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 280 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
281 | } else { | 281 | } else { |
282 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 282 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
283 | } | 283 | } |
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void MediaPlayer::blank( bool b ) { | 289 | void MediaPlayer::blank( bool b ) { |
290 | fd=open("/dev/fb0",O_RDWR); | 290 | fd=open("/dev/fb0",O_RDWR); |
291 | #ifdef QT_QWS_EBX | 291 | #ifdef QT_QWS_EBX |
292 | fl= open( "/dev/fl", O_RDWR ); | 292 | fl= open( "/dev/fl", O_RDWR ); |
293 | #endif | 293 | #endif |
294 | if (fd != -1) { | 294 | if (fd != -1) { |
295 | if ( b ) { | 295 | if ( b ) { |
296 | qDebug("do blanking"); | 296 | qDebug("do blanking"); |
297 | #ifdef QT_QWS_EBX | 297 | #ifdef QT_QWS_EBX |
298 | ioctl( fd, FBIOBLANK, 1 ); | 298 | ioctl( fd, FBIOBLANK, 1 ); |
299 | if(fl !=-1) { | 299 | if(fl !=-1) { |
300 | ioctl( fl, 2 ); | 300 | ioctl( fl, 2 ); |
301 | ::close(fl); | 301 | ::close(fl); |
302 | } | 302 | } |
303 | #else | 303 | #else |
304 | ioctl( fd, FBIOBLANK, 3 ); | 304 | ioctl( fd, FBIOBLANK, 3 ); |
305 | #endif | 305 | #endif |
306 | isBlanked = TRUE; | 306 | isBlanked = TRUE; |
307 | } else { | 307 | } else { |
308 | qDebug("do unblanking"); | 308 | qDebug("do unblanking"); |
309 | ioctl( fd, FBIOBLANK, 0); | 309 | ioctl( fd, FBIOBLANK, 0); |
310 | #ifdef QT_QWS_EBX | 310 | #ifdef QT_QWS_EBX |
311 | if(fl != -1) { | 311 | if(fl != -1) { |
312 | ioctl( fl, 1); | 312 | ioctl( fl, 1); |
313 | ::close(fl); | 313 | ::close(fl); |
314 | } | 314 | } |
315 | #endif | 315 | #endif |
316 | isBlanked = FALSE; | 316 | isBlanked = FALSE; |
317 | } | 317 | } |
318 | close( fd ); | 318 | close( fd ); |
319 | } else { | 319 | } else { |
320 | qDebug("<< /dev/fb0 could not be opened >>"); | 320 | qDebug("<< /dev/fb0 could not be opened >>"); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 324 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
325 | switch ( e->key() ) { | 325 | switch ( e->key() ) { |
326 | ////////////////////////////// Zaurus keys | 326 | ////////////////////////////// Zaurus keys |
327 | case Key_Home: | 327 | case Key_Home: |
328 | break; | 328 | break; |
329 | case Key_F9: //activity | 329 | case Key_F9: //activity |
330 | break; | 330 | break; |
331 | case Key_F10: //contacts | 331 | case Key_F10: //contacts |
332 | break; | 332 | break; |
333 | case Key_F11: //menu | 333 | case Key_F11: //menu |
334 | break; | 334 | break; |
335 | case Key_F12: //home | 335 | case Key_F12: //home |
336 | qDebug("Blank here"); | 336 | qDebug("Blank here"); |
337 | // mediaPlayerState->toggleBlank(); | 337 | // mediaPlayerState->toggleBlank(); |
338 | break; | 338 | break; |
339 | case Key_F13: //mail | 339 | case Key_F13: //mail |
340 | qDebug("Blank here"); | 340 | qDebug("Blank here"); |
341 | // mediaPlayerState->toggleBlank(); | 341 | // mediaPlayerState->toggleBlank(); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void MediaPlayer::cleanUp() {// this happens on closing | 346 | void MediaPlayer::cleanUp() {// this happens on closing |
347 | Config cfg( "OpiePlayer" ); | 347 | Config cfg( "OpiePlayer" ); |
348 | mediaPlayerState.writeConfig( cfg ); | 348 | mediaPlayerState.writeConfig( cfg ); |
349 | playList->writeDefaultPlaylist( ); | 349 | playList->writeDefaultPlaylist( ); |
350 | 350 | ||
351 | // QPEApplication::grabKeyboard(); | 351 | // QPEApplication::grabKeyboard(); |
352 | // QPEApplication::ungrabKeyboard(); | 352 | // QPEApplication::ungrabKeyboard(); |
353 | } | 353 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index e7d5a7b..071ef7c 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,259 +1,258 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include "xinecontrol.h" | 39 | #include "xinecontrol.h" |
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | #include "videowidget.h" | 41 | #include "videowidget.h" |
42 | 42 | ||
43 | extern MediaPlayerState *mediaPlayerState; | ||
44 | extern VideoWidget *videoUI; | 43 | extern VideoWidget *videoUI; |
45 | XineControl::XineControl( QObject *parent, const char *name ) | 44 | XineControl::XineControl( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
46 | : QObject( parent, name ) { | 45 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) { |
47 | 46 | ||
48 | libXine = new XINE::Lib( videoUI->vidWidget() ); | 47 | libXine = new XINE::Lib( videoUI->vidWidget() ); |
49 | 48 | ||
50 | connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); | 49 | connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); | 50 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); |
52 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 51 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); |
53 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 52 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
54 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
55 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 54 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
56 | connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 55 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 56 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
58 | 57 | ||
59 | disabledSuspendScreenSaver = FALSE; | 58 | disabledSuspendScreenSaver = FALSE; |
60 | } | 59 | } |
61 | 60 | ||
62 | XineControl::~XineControl() { | 61 | XineControl::~XineControl() { |
63 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 62 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
64 | if ( disabledSuspendScreenSaver ) { | 63 | if ( disabledSuspendScreenSaver ) { |
65 | disabledSuspendScreenSaver = FALSE; | 64 | disabledSuspendScreenSaver = FALSE; |
66 | // Re-enable the suspend mode | 65 | // Re-enable the suspend mode |
67 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 66 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
68 | } | 67 | } |
69 | #endif | 68 | #endif |
70 | delete libXine; | 69 | delete libXine; |
71 | } | 70 | } |
72 | 71 | ||
73 | void XineControl::play( const QString& fileName ) { | 72 | void XineControl::play( const QString& fileName ) { |
74 | hasVideoChannel = FALSE; | 73 | hasVideoChannel = FALSE; |
75 | hasAudioChannel = FALSE; | 74 | hasAudioChannel = FALSE; |
76 | m_fileName = fileName; | 75 | m_fileName = fileName; |
77 | 76 | ||
78 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 77 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
79 | 78 | ||
80 | if ( !libXine->play( fileName, 0, 0 ) ) { | 79 | if ( !libXine->play( fileName, 0, 0 ) ) { |
81 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 80 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
82 | // toggle stop so the the play button is reset | 81 | // toggle stop so the the play button is reset |
83 | mediaPlayerState->setPlaying( false ); | 82 | mediaPlayerState.setPlaying( false ); |
84 | return; | 83 | return; |
85 | } | 84 | } |
86 | mediaPlayerState->setPlaying( true ); | 85 | mediaPlayerState.setPlaying( true ); |
87 | 86 | ||
88 | MediaPlayerState::DisplayType displayType; | 87 | MediaPlayerState::DisplayType displayType; |
89 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); | 88 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); |
90 | if ( !libXine->hasVideo() ) { | 89 | if ( !libXine->hasVideo() ) { |
91 | displayType = MediaPlayerState::Audio; | 90 | displayType = MediaPlayerState::Audio; |
92 | qDebug("HAS AUDIO"); | 91 | qDebug("HAS AUDIO"); |
93 | libXine->setShowVideo( false ); | 92 | libXine->setShowVideo( false ); |
94 | hasAudioChannel = TRUE; | 93 | hasAudioChannel = TRUE; |
95 | } else { | 94 | } else { |
96 | displayType = MediaPlayerState::Video; | 95 | displayType = MediaPlayerState::Video; |
97 | qDebug("HAS VIDEO"); | 96 | qDebug("HAS VIDEO"); |
98 | libXine->setShowVideo( true ); | 97 | libXine->setShowVideo( true ); |
99 | hasVideoChannel = TRUE; | 98 | hasVideoChannel = TRUE; |
100 | } | 99 | } |
101 | // determine if slider is shown | 100 | // determine if slider is shown |
102 | mediaPlayerState->setIsSeekable( libXine->isSeekable() ); | 101 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
103 | 102 | ||
104 | // which gui (video / audio) | 103 | // which gui (video / audio) |
105 | mediaPlayerState->setDisplayType( displayType ); | 104 | mediaPlayerState.setDisplayType( displayType ); |
106 | 105 | ||
107 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 106 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
108 | if ( !disabledSuspendScreenSaver ) { | 107 | if ( !disabledSuspendScreenSaver ) { |
109 | disabledSuspendScreenSaver = TRUE; | 108 | disabledSuspendScreenSaver = TRUE; |
110 | // Stop the screen from blanking and power saving state | 109 | // Stop the screen from blanking and power saving state |
111 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 110 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
112 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 111 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
113 | } | 112 | } |
114 | #endif | 113 | #endif |
115 | 114 | ||
116 | length(); | 115 | length(); |
117 | position(); | 116 | position(); |
118 | } | 117 | } |
119 | 118 | ||
120 | void XineControl::nextMedia() { | 119 | void XineControl::nextMedia() { |
121 | mediaPlayerState->setNext(); | 120 | mediaPlayerState.setNext(); |
122 | } | 121 | } |
123 | 122 | ||
124 | void XineControl::setGamma( int value ) { | 123 | void XineControl::setGamma( int value ) { |
125 | libXine->setGamma( value ); | 124 | libXine->setGamma( value ); |
126 | } | 125 | } |
127 | 126 | ||
128 | void XineControl::stop( bool isSet ) { | 127 | void XineControl::stop( bool isSet ) { |
129 | if ( !isSet ) { | 128 | if ( !isSet ) { |
130 | libXine->stop(); | 129 | libXine->stop(); |
131 | 130 | ||
132 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 131 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
133 | if ( disabledSuspendScreenSaver ) { | 132 | if ( disabledSuspendScreenSaver ) { |
134 | disabledSuspendScreenSaver = FALSE; | 133 | disabledSuspendScreenSaver = FALSE; |
135 | // Re-enable the suspend mode | 134 | // Re-enable the suspend mode |
136 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 135 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
137 | } | 136 | } |
138 | #endif | 137 | #endif |
139 | } | 138 | } |
140 | } | 139 | } |
141 | 140 | ||
142 | /** | 141 | /** |
143 | * Pause playback | 142 | * Pause playback |
144 | * @isSet | 143 | * @isSet |
145 | */ | 144 | */ |
146 | void XineControl::pause( bool isSet) { | 145 | void XineControl::pause( bool isSet) { |
147 | if ( isSet ) { | 146 | if ( isSet ) { |
148 | libXine->pause(); | 147 | libXine->pause(); |
149 | } else { | 148 | } else { |
150 | libXine->play( m_fileName, 0, m_currentTime ); | 149 | libXine->play( m_fileName, 0, m_currentTime ); |
151 | } | 150 | } |
152 | } | 151 | } |
153 | 152 | ||
154 | 153 | ||
155 | /** | 154 | /** |
156 | * get current time in playback | 155 | * get current time in playback |
157 | */ | 156 | */ |
158 | long XineControl::currentTime() { | 157 | long XineControl::currentTime() { |
159 | // todo: jede sekunde überprüfen | 158 | // todo: jede sekunde überprüfen |
160 | m_currentTime = libXine->currentTime(); | 159 | m_currentTime = libXine->currentTime(); |
161 | return m_currentTime; | 160 | return m_currentTime; |
162 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 161 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
163 | } | 162 | } |
164 | 163 | ||
165 | /** | 164 | /** |
166 | * Set the length of the media file | 165 | * Set the length of the media file |
167 | */ | 166 | */ |
168 | void XineControl::length() { | 167 | void XineControl::length() { |
169 | m_length = libXine->length(); | 168 | m_length = libXine->length(); |
170 | mediaPlayerState->setLength( m_length ); | 169 | mediaPlayerState.setLength( m_length ); |
171 | } | 170 | } |
172 | 171 | ||
173 | 172 | ||
174 | /** | 173 | /** |
175 | * Reports the position the xine backend is at right now | 174 | * Reports the position the xine backend is at right now |
176 | * @return long the postion in seconds | 175 | * @return long the postion in seconds |
177 | */ | 176 | */ |
178 | long XineControl::position() { | 177 | long XineControl::position() { |
179 | m_position = ( currentTime() ); | 178 | m_position = ( currentTime() ); |
180 | mediaPlayerState->updatePosition( m_position ); | 179 | mediaPlayerState.updatePosition( m_position ); |
181 | long emitPos = (long)m_position; | 180 | long emitPos = (long)m_position; |
182 | emit positionChanged( emitPos ); | 181 | emit positionChanged( emitPos ); |
183 | if( mediaPlayerState->isPlaying() ) { | 182 | if( mediaPlayerState.isPlaying() ) { |
184 | // needs to be stopped the media is stopped | 183 | // needs to be stopped the media is stopped |
185 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 184 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
186 | } | 185 | } |
187 | // qDebug("POSITION : %d", m_position); | 186 | // qDebug("POSITION : %d", m_position); |
188 | return m_position; | 187 | return m_position; |
189 | } | 188 | } |
190 | 189 | ||
191 | /** | 190 | /** |
192 | * Set videoplayback to fullscreen | 191 | * Set videoplayback to fullscreen |
193 | * @param isSet | 192 | * @param isSet |
194 | */ | 193 | */ |
195 | void XineControl::setFullscreen( bool isSet ) { | 194 | void XineControl::setFullscreen( bool isSet ) { |
196 | libXine->showVideoFullScreen( isSet ); | 195 | libXine->showVideoFullScreen( isSet ); |
197 | } | 196 | } |
198 | 197 | ||
199 | 198 | ||
200 | QString XineControl::getMetaInfo() { | 199 | QString XineControl::getMetaInfo() { |
201 | 200 | ||
202 | QString returnString; | 201 | QString returnString; |
203 | 202 | ||
204 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 203 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
205 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 204 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
206 | } | 205 | } |
207 | 206 | ||
208 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 207 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
209 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 208 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
210 | } | 209 | } |
211 | 210 | ||
212 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 211 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
213 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 212 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
214 | } | 213 | } |
215 | 214 | ||
216 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 215 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
217 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 216 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
218 | } | 217 | } |
219 | 218 | ||
220 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 219 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
221 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 220 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
222 | } | 221 | } |
223 | 222 | ||
224 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 223 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
225 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 224 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
226 | } | 225 | } |
227 | return returnString; | 226 | return returnString; |
228 | } | 227 | } |
229 | 228 | ||
230 | QString XineControl::getErrorCode() { | 229 | QString XineControl::getErrorCode() { |
231 | 230 | ||
232 | int errorCode = libXine->error(); | 231 | int errorCode = libXine->error(); |
233 | 232 | ||
234 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); | 233 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); |
235 | 234 | ||
236 | if ( errorCode == 1 ) { | 235 | if ( errorCode == 1 ) { |
237 | return tr( "No input plugin found for this media type" ); | 236 | return tr( "No input plugin found for this media type" ); |
238 | } else if ( errorCode == 2 ) { | 237 | } else if ( errorCode == 2 ) { |
239 | return tr( "No demux plugin found for this media type" ); | 238 | return tr( "No demux plugin found for this media type" ); |
240 | } else if ( errorCode == 3 ) { | 239 | } else if ( errorCode == 3 ) { |
241 | return tr( "Demuxing failed for this media type" ); | 240 | return tr( "Demuxing failed for this media type" ); |
242 | } else if ( errorCode == 4 ) { | 241 | } else if ( errorCode == 4 ) { |
243 | return tr( "Malformed MRL" ); | 242 | return tr( "Malformed MRL" ); |
244 | } else { | 243 | } else { |
245 | return tr( "Some other error" ); | 244 | return tr( "Some other error" ); |
246 | } | 245 | } |
247 | } | 246 | } |
248 | 247 | ||
249 | /** | 248 | /** |
250 | * Seek to a position in the track | 249 | * Seek to a position in the track |
251 | * @param second the second to jump to | 250 | * @param second the second to jump to |
252 | */ | 251 | */ |
253 | void XineControl::seekTo( long second ) { | 252 | void XineControl::seekTo( long second ) { |
254 | libXine->seekTo( (int)second ); | 253 | libXine->seekTo( (int)second ); |
255 | } | 254 | } |
256 | 255 | ||
257 | void XineControl::videoResized ( const QSize &s ) { | 256 | void XineControl::videoResized ( const QSize &s ) { |
258 | libXine->resize( s ); | 257 | libXine->resize( s ); |
259 | } | 258 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index b1300a8..00486f2 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,116 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | 39 | ||
40 | #include "mediaplayerstate.h" | ||
41 | |||
40 | class XineControl : public QObject { | 42 | class XineControl : public QObject { |
41 | Q_OBJECT | 43 | Q_OBJECT |
42 | public: | 44 | public: |
43 | XineControl( QObject *parent = 0, const char *name =0 ); | 45 | XineControl( MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 ); |
44 | ~XineControl(); | 46 | ~XineControl(); |
45 | 47 | ||
46 | bool hasVideo() const { return hasVideoChannel; } | 48 | bool hasVideo() const { return hasVideoChannel; } |
47 | bool hasAudio() const { return hasAudioChannel; } | 49 | bool hasAudio() const { return hasAudioChannel; } |
48 | 50 | ||
49 | public slots: | 51 | public slots: |
50 | void play( const QString& fileName ); | 52 | void play( const QString& fileName ); |
51 | void stop( bool ); | 53 | void stop( bool ); |
52 | 54 | ||
53 | /** | 55 | /** |
54 | * Pause the media stream | 56 | * Pause the media stream |
55 | * @param if pause or not | 57 | * @param if pause or not |
56 | */ | 58 | */ |
57 | void pause( bool ); | 59 | void pause( bool ); |
58 | 60 | ||
59 | /** | 61 | /** |
60 | * Set videos fullscreen | 62 | * Set videos fullscreen |
61 | * @param yes or no | 63 | * @param yes or no |
62 | */ | 64 | */ |
63 | void setFullscreen( bool ); | 65 | void setFullscreen( bool ); |
64 | 66 | ||
65 | /** | 67 | /** |
66 | * | 68 | * |
67 | */ | 69 | */ |
68 | long currentTime(); | 70 | long currentTime(); |
69 | void seekTo( long ); | 71 | void seekTo( long ); |
70 | // get length of media file and set it | 72 | // get length of media file and set it |
71 | void length(); | 73 | void length(); |
72 | long position(); | 74 | long position(); |
73 | 75 | ||
74 | /** | 76 | /** |
75 | * Proceed to the next media file in playlist | 77 | * Proceed to the next media file in playlist |
76 | */ | 78 | */ |
77 | void nextMedia(); | 79 | void nextMedia(); |
78 | 80 | ||
79 | /** | 81 | /** |
80 | * Get as much info about the stream from xine as possible | 82 | * Get as much info about the stream from xine as possible |
81 | */ | 83 | */ |
82 | QString getMetaInfo(); | 84 | QString getMetaInfo(); |
83 | 85 | ||
84 | /** | 86 | /** |
85 | * get the error code and "translate" it for the user | 87 | * get the error code and "translate" it for the user |
86 | * | 88 | * |
87 | */ | 89 | */ |
88 | QString getErrorCode(); | 90 | QString getErrorCode(); |
89 | 91 | ||
90 | 92 | ||
91 | void videoResized ( const QSize &s ); | 93 | void videoResized ( const QSize &s ); |
92 | 94 | ||
93 | /** | 95 | /** |
94 | * Set the gamma value of the video output | 96 | * Set the gamma value of the video output |
95 | * @param int value between -100 and 100, 0 is original | 97 | * @param int value between -100 and 100, 0 is original |
96 | */ | 98 | */ |
97 | void setGamma( int ); | 99 | void setGamma( int ); |
98 | 100 | ||
99 | 101 | ||
100 | private: | 102 | private: |
101 | XINE::Lib *libXine; | 103 | XINE::Lib *libXine; |
102 | long m_currentTime; | 104 | long m_currentTime; |
103 | long m_position; | 105 | long m_position; |
104 | int m_length; | 106 | int m_length; |
105 | QString m_fileName; | 107 | QString m_fileName; |
106 | bool disabledSuspendScreenSaver : 1; | 108 | bool disabledSuspendScreenSaver : 1; |
107 | bool hasVideoChannel : 1; | 109 | bool hasVideoChannel : 1; |
108 | bool hasAudioChannel : 1; | 110 | bool hasAudioChannel : 1; |
111 | MediaPlayerState &mediaPlayerState; | ||
109 | 112 | ||
110 | signals: | 113 | signals: |
111 | void positionChanged( long ); | 114 | void positionChanged( long ); |
112 | 115 | ||
113 | }; | 116 | }; |
114 | 117 | ||
115 | 118 | ||
116 | #endif | 119 | #endif |