author | mickeyl <mickeyl> | 2004-04-04 17:38:26 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-04 17:38:26 (UTC) |
commit | 4588425855268ce88a80ddbac7e1c3d4b87b03f4 (patch) (unidiff) | |
tree | cc2ba17458cd68592093e6c1bb216df3582cb6f5 | |
parent | ea3708cbc40ebc5f1db70546f0a93e8a23ba967c (diff) | |
download | opie-4588425855268ce88a80ddbac7e1c3d4b87b03f4.zip opie-4588425855268ce88a80ddbac7e1c3d4b87b03f4.tar.gz opie-4588425855268ce88a80ddbac7e1c3d4b87b03f4.tar.bz2 |
use odebug classes
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 9 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 12 |
7 files changed, 51 insertions, 30 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 36def67..95a0f45 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,325 +1,328 @@ | |||
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 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library 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 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library 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 "audiowidget.h" | 35 | #include "audiowidget.h" |
36 | 36 | ||
37 | /* OPIE */ | ||
38 | #include <opie2/odebug.h> | ||
37 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
38 | 40 | using namespace Opie::Core; | |
39 | using namespace Opie::Ui; | 41 | using namespace Opie::Ui; |
42 | |||
40 | namespace | 43 | namespace |
41 | { | 44 | { |
42 | 45 | ||
43 | const int xo = -2; // movable x offset | 46 | const int xo = -2; // movable x offset |
44 | const int yo = 22; // movable y offset | 47 | const int yo = 22; // movable y offset |
45 | 48 | ||
46 | const MediaWidget::SkinButtonInfo skinInfo[] = | 49 | const MediaWidget::SkinButtonInfo skinInfo[] = |
47 | { | 50 | { |
48 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, | 51 | { MediaWidget::Play, "play", MediaWidget::ToggleButton }, |
49 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, | 52 | { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, |
50 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, | 53 | { MediaWidget::Next, "next", MediaWidget::NormalButton }, |
51 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, | 54 | { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, |
52 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, | 55 | { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, |
53 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, | 56 | { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, |
54 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, | 57 | { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, |
55 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, | 58 | { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, |
56 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, | 59 | { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, |
57 | { MediaWidget::Back, "back", MediaWidget::NormalButton } | 60 | { MediaWidget::Back, "back", MediaWidget::NormalButton } |
58 | }; | 61 | }; |
59 | 62 | ||
60 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); | 63 | const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); |
61 | 64 | ||
62 | void changeTextColor( QWidget * w) { | 65 | void changeTextColor( QWidget * w) { |
63 | QPalette p = w->palette(); | 66 | QPalette p = w->palette(); |
64 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 67 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
65 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 68 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
66 | w->setPalette( p ); | 69 | w->setPalette( p ); |
67 | } | 70 | } |
68 | 71 | ||
69 | } | 72 | } |
70 | 73 | ||
71 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 74 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
72 | 75 | ||
73 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 76 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
74 | audioSliderBeingMoved( false ) | 77 | audioSliderBeingMoved( false ) |
75 | { | 78 | { |
76 | setCaption( tr("OpiePlayer") ); | 79 | setCaption( tr("OpiePlayer") ); |
77 | 80 | ||
78 | loadSkin(); | 81 | loadSkin(); |
79 | 82 | ||
80 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 83 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
81 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); | 84 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled(bool) ), this, SLOT( setSeekable(bool) ) ); |
82 | 85 | ||
83 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 86 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
84 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 87 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
85 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 88 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
86 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 89 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
87 | 90 | ||
88 | // Intialise state | 91 | // Intialise state |
89 | setLength( mediaPlayerState.length() ); | 92 | setLength( mediaPlayerState.length() ); |
90 | setPosition( mediaPlayerState.position() ); | 93 | setPosition( mediaPlayerState.position() ); |
91 | setLooping( mediaPlayerState.isFullscreen() ); | 94 | setLooping( mediaPlayerState.isFullscreen() ); |
92 | // setPaused( mediaPlayerState->paused() ); | 95 | // setPaused( mediaPlayerState->paused() ); |
93 | setPlaying( mediaPlayerState.isPlaying() ); | 96 | setPlaying( mediaPlayerState.isPlaying() ); |
94 | } | 97 | } |
95 | 98 | ||
96 | AudioWidget::~AudioWidget() { | 99 | AudioWidget::~AudioWidget() { |
97 | 100 | ||
98 | // mediaPlayerState->setPlaying(false); | 101 | // mediaPlayerState->setPlaying(false); |
99 | } | 102 | } |
100 | 103 | ||
101 | MediaWidget::GUIInfo AudioWidget::guiInfo() | 104 | MediaWidget::GUIInfo AudioWidget::guiInfo() |
102 | { | 105 | { |
103 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); | 106 | return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount ); |
104 | } | 107 | } |
105 | 108 | ||
106 | void AudioWidget::resizeEvent( QResizeEvent *e ) { | 109 | void AudioWidget::resizeEvent( QResizeEvent *e ) { |
107 | int h = height(); | 110 | int h = height(); |
108 | int w = width(); | 111 | int w = width(); |
109 | 112 | ||
110 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 113 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
111 | slider.setFixedWidth( w - 110 ); | 114 | slider.setFixedWidth( w - 110 ); |
112 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 115 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
113 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 116 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
114 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 117 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
115 | 118 | ||
116 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; | 119 | upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; |
117 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; | 120 | upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; |
118 | 121 | ||
119 | MediaWidget::resizeEvent( e ); | 122 | MediaWidget::resizeEvent( e ); |
120 | } | 123 | } |
121 | 124 | ||
122 | void AudioWidget::sliderPressed() { | 125 | void AudioWidget::sliderPressed() { |
123 | audioSliderBeingMoved = TRUE; | 126 | audioSliderBeingMoved = TRUE; |
124 | } | 127 | } |
125 | 128 | ||
126 | 129 | ||
127 | void AudioWidget::sliderReleased() { | 130 | void AudioWidget::sliderReleased() { |
128 | audioSliderBeingMoved = FALSE; | 131 | audioSliderBeingMoved = FALSE; |
129 | if ( slider.width() == 0 ) | 132 | if ( slider.width() == 0 ) |
130 | return; | 133 | return; |
131 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 134 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
132 | mediaPlayerState.setPosition( val ); | 135 | mediaPlayerState.setPosition( val ); |
133 | } | 136 | } |
134 | 137 | ||
135 | void AudioWidget::setPosition( long i ) { | 138 | void AudioWidget::setPosition( long i ) { |
136 | // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<set position " << i << "" << oendl; | 139 | // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<set position " << i << "" << oendl; |
137 | updateSlider( i, mediaPlayerState.length() ); | 140 | updateSlider( i, mediaPlayerState.length() ); |
138 | } | 141 | } |
139 | 142 | ||
140 | 143 | ||
141 | void AudioWidget::setLength( long max ) { | 144 | void AudioWidget::setLength( long max ) { |
142 | updateSlider( mediaPlayerState.position(), max ); | 145 | updateSlider( mediaPlayerState.position(), max ); |
143 | } | 146 | } |
144 | 147 | ||
145 | 148 | ||
146 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 149 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
147 | if ( mediaType == MediaPlayerState::Audio ) { | 150 | if ( mediaType == MediaPlayerState::Audio ) { |
148 | // startTimer( 150 ); | 151 | // startTimer( 150 ); |
149 | QPEApplication::showWidget( this ); | 152 | QPEApplication::showWidget( this ); |
150 | return; | 153 | return; |
151 | } | 154 | } |
152 | 155 | ||
153 | killTimers(); | 156 | killTimers(); |
154 | hide(); | 157 | hide(); |
155 | } | 158 | } |
156 | 159 | ||
157 | void AudioWidget::loadSkin() | 160 | void AudioWidget::loadSkin() |
158 | { | 161 | { |
159 | loadDefaultSkin( guiInfo() ); | 162 | loadDefaultSkin( guiInfo() ); |
160 | 163 | ||
161 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 164 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
162 | // changeTextColor( &songInfo ); | 165 | // changeTextColor( &songInfo ); |
163 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 166 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
164 | // songInfo.setFrameStyle( QFrame::NoFrame); | 167 | // songInfo.setFrameStyle( QFrame::NoFrame); |
165 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 168 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
166 | // songInfo.setForegroundColor(Qt::white); | 169 | // songInfo.setForegroundColor(Qt::white); |
167 | 170 | ||
168 | slider.setFixedHeight( 20 ); | 171 | slider.setFixedHeight( 20 ); |
169 | slider.setMinValue( 0 ); | 172 | slider.setMinValue( 0 ); |
170 | slider.setMaxValue( 1 ); | 173 | slider.setMaxValue( 1 ); |
171 | slider.setFocusPolicy( QWidget::NoFocus ); | 174 | slider.setFocusPolicy( QWidget::NoFocus ); |
172 | slider.setBackgroundPixmap( backgroundPixmap ); | 175 | slider.setBackgroundPixmap( backgroundPixmap ); |
173 | 176 | ||
174 | // Config cofg("qpe"); | 177 | // Config cofg("qpe"); |
175 | // cofg.setGroup("Appearance"); | 178 | // cofg.setGroup("Appearance"); |
176 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 179 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
177 | 180 | ||
178 | time.setFocusPolicy( QWidget::NoFocus ); | 181 | time.setFocusPolicy( QWidget::NoFocus ); |
179 | time.setAlignment( Qt::AlignCenter ); | 182 | time.setAlignment( Qt::AlignCenter ); |
180 | 183 | ||
181 | // time.setFrame(FALSE); | 184 | // time.setFrame(FALSE); |
182 | // changeTextColor( &time ); | 185 | // changeTextColor( &time ); |
183 | 186 | ||
184 | resizeEvent( 0 ); | 187 | resizeEvent( 0 ); |
185 | } | 188 | } |
186 | 189 | ||
187 | void AudioWidget::setSeekable( bool isSeekable ) { | 190 | void AudioWidget::setSeekable( bool isSeekable ) { |
188 | 191 | ||
189 | if ( !isSeekable ) { | 192 | if ( !isSeekable ) { |
190 | odebug << "<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>" << oendl; | 193 | odebug << "<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>" << oendl; |
191 | if( !slider.isHidden()) { | 194 | if( !slider.isHidden()) { |
192 | slider.hide(); | 195 | slider.hide(); |
193 | } | 196 | } |
194 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 197 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
195 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 198 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
196 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 199 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
197 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 200 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
198 | } else { | 201 | } else { |
199 | // this stops the slider from being moved, thus | 202 | // this stops the slider from being moved, thus |
200 | // does not stop stream when it reaches the end | 203 | // does not stop stream when it reaches the end |
201 | slider.show(); | 204 | slider.show(); |
202 | odebug << " CONNECT SET POSTION " << oendl; | 205 | odebug << " CONNECT SET POSTION " << oendl; |
203 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 206 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
204 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 207 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
205 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 208 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
206 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 209 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
207 | } | 210 | } |
208 | } | 211 | } |
209 | 212 | ||
210 | 213 | ||
211 | static QString timeAsString( long length ) { | 214 | static QString timeAsString( long length ) { |
212 | int minutes = length / 60; | 215 | int minutes = length / 60; |
213 | int seconds = length % 60; | 216 | int seconds = length % 60; |
214 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 217 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
215 | } | 218 | } |
216 | 219 | ||
217 | void AudioWidget::updateSlider( long i, long max ) { | 220 | void AudioWidget::updateSlider( long i, long max ) { |
218 | 221 | ||
219 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 222 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
220 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 223 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
221 | 224 | ||
222 | if ( max == 0 ) { | 225 | if ( max == 0 ) { |
223 | return; | 226 | return; |
224 | } | 227 | } |
225 | // Will flicker too much if we don't do this | 228 | // Will flicker too much if we don't do this |
226 | // Scale to something reasonable | 229 | // Scale to something reasonable |
227 | int width = slider.width(); | 230 | int width = slider.width(); |
228 | int val = int((double)i * width / max); | 231 | int val = int((double)i * width / max); |
229 | if ( !audioSliderBeingMoved ) { | 232 | if ( !audioSliderBeingMoved ) { |
230 | if ( slider.value() != val ) { | 233 | if ( slider.value() != val ) { |
231 | slider.setValue( val ); | 234 | slider.setValue( val ); |
232 | } | 235 | } |
233 | 236 | ||
234 | if ( slider.maxValue() != width ) { | 237 | if ( slider.maxValue() != width ) { |
235 | slider.setMaxValue( width ); | 238 | slider.setMaxValue( width ); |
236 | } | 239 | } |
237 | } | 240 | } |
238 | } | 241 | } |
239 | 242 | ||
240 | void AudioWidget::skipFor() { | 243 | void AudioWidget::skipFor() { |
241 | skipDirection = +1; | 244 | skipDirection = +1; |
242 | startTimer( 50 ); | 245 | startTimer( 50 ); |
243 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 246 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
244 | } | 247 | } |
245 | 248 | ||
246 | void AudioWidget::skipBack() { | 249 | void AudioWidget::skipBack() { |
247 | skipDirection = -1; | 250 | skipDirection = -1; |
248 | startTimer( 50 ); | 251 | startTimer( 50 ); |
249 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 252 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
250 | } | 253 | } |
251 | 254 | ||
252 | 255 | ||
253 | 256 | ||
254 | void AudioWidget::stopSkip() { | 257 | void AudioWidget::stopSkip() { |
255 | killTimers(); | 258 | killTimers(); |
256 | } | 259 | } |
257 | 260 | ||
258 | 261 | ||
259 | void AudioWidget::timerEvent( QTimerEvent * ) { | 262 | void AudioWidget::timerEvent( QTimerEvent * ) { |
260 | if ( skipDirection == +1 ) { | 263 | if ( skipDirection == +1 ) { |
261 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 264 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
262 | } else if ( skipDirection == -1 ) { | 265 | } else if ( skipDirection == -1 ) { |
263 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 266 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
264 | } | 267 | } |
265 | } | 268 | } |
266 | 269 | ||
267 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 270 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
268 | switch ( e->key() ) { | 271 | switch ( e->key() ) { |
269 | ////////////////////////////// Zaurus keys | 272 | ////////////////////////////// Zaurus keys |
270 | case Key_Home: | 273 | case Key_Home: |
271 | break; | 274 | break; |
272 | case Key_F9: //activity | 275 | case Key_F9: //activity |
273 | hide(); | 276 | hide(); |
274 | // odebug << "Audio F9" << oendl; | 277 | // odebug << "Audio F9" << oendl; |
275 | e->accept(); | 278 | e->accept(); |
276 | break; | 279 | break; |
277 | case Key_F10: //contacts | 280 | case Key_F10: //contacts |
278 | break; | 281 | break; |
279 | case Key_F11: //menu | 282 | case Key_F11: //menu |
280 | mediaPlayerState.toggleBlank(); | 283 | mediaPlayerState.toggleBlank(); |
281 | e->accept(); | 284 | e->accept(); |
282 | break; | 285 | break; |
283 | case Key_F12: //home | 286 | case Key_F12: //home |
284 | break; | 287 | break; |
285 | case Key_F13: //mail | 288 | case Key_F13: //mail |
286 | mediaPlayerState.toggleBlank(); | 289 | mediaPlayerState.toggleBlank(); |
287 | e->accept(); | 290 | e->accept(); |
288 | break; | 291 | break; |
289 | case Key_Space: { | 292 | case Key_Space: { |
290 | e->accept(); | 293 | e->accept(); |
291 | mediaPlayerState.togglePaused(); | 294 | mediaPlayerState.togglePaused(); |
292 | } | 295 | } |
293 | break; | 296 | break; |
294 | case Key_Down: | 297 | case Key_Down: |
295 | // toggleButton(6); | 298 | // toggleButton(6); |
296 | emit lessClicked(); | 299 | emit lessClicked(); |
297 | emit lessReleased(); | 300 | emit lessReleased(); |
298 | // toggleButton(6); | 301 | // toggleButton(6); |
299 | e->accept(); | 302 | e->accept(); |
300 | break; | 303 | break; |
301 | case Key_Up: | 304 | case Key_Up: |
302 | // toggleButton(5); | 305 | // toggleButton(5); |
303 | emit moreClicked(); | 306 | emit moreClicked(); |
304 | emit moreReleased(); | 307 | emit moreReleased(); |
305 | // toggleButton(5); | 308 | // toggleButton(5); |
306 | e->accept(); | 309 | e->accept(); |
307 | break; | 310 | break; |
308 | case Key_Right: | 311 | case Key_Right: |
309 | // toggleButton(3); | 312 | // toggleButton(3); |
310 | mediaPlayerState.setNext(); | 313 | mediaPlayerState.setNext(); |
311 | // toggleButton(3); | 314 | // toggleButton(3); |
312 | e->accept(); | 315 | e->accept(); |
313 | break; | 316 | break; |
314 | case Key_Left: | 317 | case Key_Left: |
315 | // toggleButton(4); | 318 | // toggleButton(4); |
316 | mediaPlayerState.setPrev(); | 319 | mediaPlayerState.setPrev(); |
317 | // toggleButton(4); | 320 | // toggleButton(4); |
318 | e->accept(); | 321 | e->accept(); |
319 | break; | 322 | break; |
320 | case Key_Escape: { | 323 | case Key_Escape: { |
321 | } | 324 | } |
322 | break; | 325 | break; |
323 | 326 | ||
324 | }; | 327 | }; |
325 | } | 328 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 5c24dbe..1ab5c96 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,432 +1,434 @@ | |||
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 LJP <> | 5 | Copyright (c) 2002 LJP <> |
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 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library 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 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library 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 | #include "xinevideowidget.h" | ||
35 | #include "frame.h" | ||
36 | #include "lib.h" | ||
34 | 37 | ||
35 | #include <qtextstream.h> | 38 | /* OPIE */ |
39 | #include <opie2/odebug.h> | ||
40 | using namespace Opie::Core; | ||
36 | 41 | ||
42 | /* QT */ | ||
43 | #include <qtextstream.h> | ||
37 | #include <qdir.h> | 44 | #include <qdir.h> |
38 | |||
39 | #include <qgfx_qws.h> | 45 | #include <qgfx_qws.h> |
40 | 46 | ||
47 | /* STD */ | ||
41 | #include <assert.h> | 48 | #include <assert.h> |
42 | 49 | ||
43 | #include "xinevideowidget.h" | ||
44 | #include "frame.h" | ||
45 | #include "lib.h" | ||
46 | |||
47 | |||
48 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 50 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
49 | int width, int height,int bytes ); | 51 | int width, int height,int bytes ); |
50 | 52 | ||
51 | extern "C" { | 53 | extern "C" { |
52 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 54 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
53 | int null_is_showing_video( const xine_vo_driver_t* self ); | 55 | int null_is_showing_video( const xine_vo_driver_t* self ); |
54 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 56 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
55 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 57 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
56 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 58 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
57 | int null_is_scaling( const xine_vo_driver_t* self ); | 59 | int null_is_scaling( const xine_vo_driver_t* self ); |
58 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 60 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
59 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 61 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
60 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 62 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
61 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 63 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
62 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 64 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
63 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 65 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
64 | 66 | ||
65 | void null_preload_decoders( xine_stream_t *stream ); | 67 | void null_preload_decoders( xine_stream_t *stream ); |
66 | } | 68 | } |
67 | 69 | ||
68 | using namespace XINE; | 70 | using namespace XINE; |
69 | 71 | ||
70 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) | 72 | Lib::Lib( InitializationMode initMode, XineVideoWidget* widget ) |
71 | { | 73 | { |
72 | m_initialized = false; | 74 | m_initialized = false; |
73 | m_duringInitialization = false; | 75 | m_duringInitialization = false; |
74 | m_video = false; | 76 | m_video = false; |
75 | m_wid = widget; | 77 | m_wid = widget; |
76 | printf("Lib"); | 78 | printf("Lib"); |
77 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 79 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
78 | // get the configuration | 80 | // get the configuration |
79 | 81 | ||
80 | // not really OO, should be an extra class, later | 82 | // not really OO, should be an extra class, later |
81 | if ( !QFile::exists(configPath) ) { | 83 | if ( !QFile::exists(configPath) ) { |
82 | QFile f(configPath); | 84 | QFile f(configPath); |
83 | f.open(IO_WriteOnly); | 85 | f.open(IO_WriteOnly); |
84 | QTextStream ts( &f ); | 86 | QTextStream ts( &f ); |
85 | ts << "misc.memcpy_method:glibc\n"; | 87 | ts << "misc.memcpy_method:glibc\n"; |
86 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; | 88 | ts << "# uncomment if you experience double speed audio \n #audio.oss_sync_method:softsync\n"; |
87 | ts << "codec.ffmpeg_pp_quality:3\n"; | 89 | ts << "codec.ffmpeg_pp_quality:3\n"; |
88 | ts << "audio.num_buffers:50\n"; | 90 | ts << "audio.num_buffers:50\n"; |
89 | ts << "audio.size_buffers:4096\n"; | 91 | ts << "audio.size_buffers:4096\n"; |
90 | ts << "video.num_buffers:20\n"; | 92 | ts << "video.num_buffers:20\n"; |
91 | ts << "video.size_buffers:4096\n"; | 93 | ts << "video.size_buffers:4096\n"; |
92 | ts << "audio.out_num_audio_buf:16\n"; | 94 | ts << "audio.out_num_audio_buf:16\n"; |
93 | ts << "audio.out_size_audio_buf:8096\n"; | 95 | ts << "audio.out_size_audio_buf:8096\n"; |
94 | ts << "audio.out_size_zero_buf:1024\n"; | 96 | ts << "audio.out_size_zero_buf:1024\n"; |
95 | ts << "audio.passthrough_offset:0\n"; | 97 | ts << "audio.passthrough_offset:0\n"; |
96 | f.close(); | 98 | f.close(); |
97 | } | 99 | } |
98 | 100 | ||
99 | if ( initMode == InitializeImmediately ) { | 101 | if ( initMode == InitializeImmediately ) { |
100 | initialize(); | 102 | initialize(); |
101 | m_initialized = true; | 103 | m_initialized = true; |
102 | } | 104 | } |
103 | else | 105 | else |
104 | start(); | 106 | start(); |
105 | } | 107 | } |
106 | 108 | ||
107 | void Lib::run() | 109 | void Lib::run() |
108 | { | 110 | { |
109 | odebug << "Lib::run() started" << oendl; | 111 | odebug << "Lib::run() started" << oendl; |
110 | initialize(); | 112 | initialize(); |
111 | m_initialized = true; | 113 | m_initialized = true; |
112 | odebug << "Lib::run() finished" << oendl; | 114 | odebug << "Lib::run() finished" << oendl; |
113 | } | 115 | } |
114 | 116 | ||
115 | void Lib::initialize() | 117 | void Lib::initialize() |
116 | { | 118 | { |
117 | m_duringInitialization = true; | 119 | m_duringInitialization = true; |
118 | m_xine = xine_new( ); | 120 | m_xine = xine_new( ); |
119 | 121 | ||
120 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; | 122 | QString configPath = QDir::homeDirPath() + "/Settings/opiexine.cf"; |
121 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); | 123 | xine_config_load( m_xine, QFile::encodeName( configPath ) ); |
122 | 124 | ||
123 | xine_init( m_xine ); | 125 | xine_init( m_xine ); |
124 | 126 | ||
125 | // allocate oss for sound | 127 | // allocate oss for sound |
126 | // and fb for framebuffer | 128 | // and fb for framebuffer |
127 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 129 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
128 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 130 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
129 | 131 | ||
130 | 132 | ||
131 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 133 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
132 | 134 | ||
133 | 135 | ||
134 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 136 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
135 | 137 | ||
136 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 138 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
137 | 139 | ||
138 | if (m_wid != 0 ) { | 140 | if (m_wid != 0 ) { |
139 | printf( "!0\n" ); | 141 | printf( "!0\n" ); |
140 | setWidget( m_wid ); | 142 | setWidget( m_wid ); |
141 | } | 143 | } |
142 | 144 | ||
143 | m_queue = xine_event_new_queue (m_stream); | 145 | m_queue = xine_event_new_queue (m_stream); |
144 | 146 | ||
145 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 147 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
146 | 148 | ||
147 | ::null_preload_decoders( m_stream ); | 149 | ::null_preload_decoders( m_stream ); |
148 | 150 | ||
149 | m_duringInitialization = false; | 151 | m_duringInitialization = false; |
150 | } | 152 | } |
151 | 153 | ||
152 | Lib::~Lib() { | 154 | Lib::~Lib() { |
153 | assert( isRunning() == false ); | 155 | assert( isRunning() == false ); |
154 | assert( m_initialized ); | 156 | assert( m_initialized ); |
155 | 157 | ||
156 | // free( m_config ); | 158 | // free( m_config ); |
157 | 159 | ||
158 | xine_close( m_stream ); | 160 | xine_close( m_stream ); |
159 | 161 | ||
160 | xine_event_dispose_queue( m_queue ); | 162 | xine_event_dispose_queue( m_queue ); |
161 | 163 | ||
162 | xine_dispose( m_stream ); | 164 | xine_dispose( m_stream ); |
163 | 165 | ||
164 | xine_exit( m_xine ); | 166 | xine_exit( m_xine ); |
165 | /* FIXME either free or delete but valgrind bitches against both */ | 167 | /* FIXME either free or delete but valgrind bitches against both */ |
166 | //free( m_videoOutput ); | 168 | //free( m_videoOutput ); |
167 | //delete m_audioOutput; | 169 | //delete m_audioOutput; |
168 | } | 170 | } |
169 | 171 | ||
170 | void Lib::resize ( const QSize &s ) { | 172 | void Lib::resize ( const QSize &s ) { |
171 | assert( m_initialized || m_duringInitialization ); | 173 | assert( m_initialized || m_duringInitialization ); |
172 | 174 | ||
173 | if ( s. width ( ) && s. height ( ) ) { | 175 | if ( s. width ( ) && s. height ( ) ) { |
174 | ::null_set_gui_width( m_videoOutput, s. width() ); | 176 | ::null_set_gui_width( m_videoOutput, s. width() ); |
175 | ::null_set_gui_height( m_videoOutput, s. height() ); | 177 | ::null_set_gui_height( m_videoOutput, s. height() ); |
176 | } | 178 | } |
177 | } | 179 | } |
178 | 180 | ||
179 | int Lib::majorVersion() { | 181 | int Lib::majorVersion() { |
180 | int major, minor, sub; | 182 | int major, minor, sub; |
181 | xine_get_version ( &major, &minor, &sub ); | 183 | xine_get_version ( &major, &minor, &sub ); |
182 | return major; | 184 | return major; |
183 | } | 185 | } |
184 | 186 | ||
185 | int Lib::minorVersion() { | 187 | int Lib::minorVersion() { |
186 | int major, minor, sub; | 188 | int major, minor, sub; |
187 | xine_get_version ( &major, &minor, &sub ); | 189 | xine_get_version ( &major, &minor, &sub ); |
188 | return minor; | 190 | return minor; |
189 | } | 191 | } |
190 | 192 | ||
191 | int Lib::subVersion() { | 193 | int Lib::subVersion() { |
192 | int major, minor, sub; | 194 | int major, minor, sub; |
193 | xine_get_version ( &major, &minor, &sub ); | 195 | xine_get_version ( &major, &minor, &sub ); |
194 | return sub; | 196 | return sub; |
195 | } | 197 | } |
196 | 198 | ||
197 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 199 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
198 | assert( m_initialized ); | 200 | assert( m_initialized ); |
199 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream | 201 | // FIXME actually a hack imho. Should not be needed to dispose the whole stream |
200 | // but without we get wrong media length reads from libxine for the second media | 202 | // but without we get wrong media length reads from libxine for the second media |
201 | //xine_dispose ( m_stream ); | 203 | //xine_dispose ( m_stream ); |
202 | 204 | ||
203 | QString str = fileName.stripWhiteSpace(); | 205 | QString str = fileName.stripWhiteSpace(); |
204 | 206 | ||
205 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 207 | //m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
206 | //m_queue = xine_event_new_queue (m_stream); | 208 | //m_queue = xine_event_new_queue (m_stream); |
207 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 209 | //xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
208 | 210 | ||
209 | if ( !xine_open( m_stream, str.utf8().data() ) ) { | 211 | if ( !xine_open( m_stream, str.utf8().data() ) ) { |
210 | return 0; | 212 | return 0; |
211 | } | 213 | } |
212 | return xine_play( m_stream, startPos, start_time); | 214 | return xine_play( m_stream, startPos, start_time); |
213 | } | 215 | } |
214 | 216 | ||
215 | void Lib::stop() { | 217 | void Lib::stop() { |
216 | assert( m_initialized ); | 218 | assert( m_initialized ); |
217 | 219 | ||
218 | odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; | 220 | odebug << "<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>" << oendl; |
219 | xine_stop( m_stream ); | 221 | xine_stop( m_stream ); |
220 | } | 222 | } |
221 | 223 | ||
222 | void Lib::pause( bool toggle ) { | 224 | void Lib::pause( bool toggle ) { |
223 | assert( m_initialized ); | 225 | assert( m_initialized ); |
224 | 226 | ||
225 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); | 227 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
226 | } | 228 | } |
227 | 229 | ||
228 | int Lib::speed() const { | 230 | int Lib::speed() const { |
229 | assert( m_initialized ); | 231 | assert( m_initialized ); |
230 | 232 | ||
231 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 233 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
232 | } | 234 | } |
233 | 235 | ||
234 | void Lib::setSpeed( int speed ) { | 236 | void Lib::setSpeed( int speed ) { |
235 | assert( m_initialized ); | 237 | assert( m_initialized ); |
236 | 238 | ||
237 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 239 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
238 | } | 240 | } |
239 | 241 | ||
240 | int Lib::status() const { | 242 | int Lib::status() const { |
241 | assert( m_initialized ); | 243 | assert( m_initialized ); |
242 | 244 | ||
243 | return xine_get_status( m_stream ); | 245 | return xine_get_status( m_stream ); |
244 | } | 246 | } |
245 | 247 | ||
246 | int Lib::currentPosition() const { | 248 | int Lib::currentPosition() const { |
247 | assert( m_initialized ); | 249 | assert( m_initialized ); |
248 | 250 | ||
249 | int pos, time, length; | 251 | int pos, time, length; |
250 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 252 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
251 | return pos; | 253 | return pos; |
252 | } | 254 | } |
253 | 255 | ||
254 | int Lib::currentTime() const { | 256 | int Lib::currentTime() const { |
255 | assert( m_initialized ); | 257 | assert( m_initialized ); |
256 | 258 | ||
257 | int pos, time, length; | 259 | int pos, time, length; |
258 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 260 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
259 | if ( time > 0 ) { | 261 | if ( time > 0 ) { |
260 | return time/1000; | 262 | return time/1000; |
261 | } else { | 263 | } else { |
262 | return 0; | 264 | return 0; |
263 | } | 265 | } |
264 | } | 266 | } |
265 | 267 | ||
266 | int Lib::length() const { | 268 | int Lib::length() const { |
267 | assert( m_initialized ); | 269 | assert( m_initialized ); |
268 | 270 | ||
269 | int pos, time, length; | 271 | int pos, time, length; |
270 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ | 272 | /* dilb: patch to solve the wrong stream length reported to the GUI*/ |
271 | int iRetVal=0, iTestLoop=0; | 273 | int iRetVal=0, iTestLoop=0; |
272 | 274 | ||
273 | do | 275 | do |
274 | { | 276 | { |
275 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); | 277 | iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); |
276 | if (iRetVal) | 278 | if (iRetVal) |
277 | {/* if the function didn't return 0, then pos, time and length are valid.*/ | 279 | {/* if the function didn't return 0, then pos, time and length are valid.*/ |
278 | return length/1000; | 280 | return length/1000; |
279 | } | 281 | } |
280 | /*don't poll too much*/ | 282 | /*don't poll too much*/ |
281 | usleep(100000); | 283 | usleep(100000); |
282 | iTestLoop++; | 284 | iTestLoop++; |
283 | } | 285 | } |
284 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any | 286 | while ( iTestLoop < 10 ); /* if after 1s, we still don't have any |
285 | valid stream, then return -1 (this value could be used to make the stream | 287 | valid stream, then return -1 (this value could be used to make the stream |
286 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ | 288 | unseekable, but it should never occur!! Mr. Murphy ? :) ) */ |
287 | 289 | ||
288 | return -1; | 290 | return -1; |
289 | } | 291 | } |
290 | 292 | ||
291 | bool Lib::isSeekable() const { | 293 | bool Lib::isSeekable() const { |
292 | assert( m_initialized ); | 294 | assert( m_initialized ); |
293 | 295 | ||
294 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 296 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
295 | } | 297 | } |
296 | 298 | ||
297 | void Lib::seekTo( int time ) { | 299 | void Lib::seekTo( int time ) { |
298 | assert( m_initialized ); | 300 | assert( m_initialized ); |
299 | 301 | ||
300 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 302 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
301 | // since its now milliseconds we need *1000 | 303 | // since its now milliseconds we need *1000 |
302 | xine_play( m_stream, 0, time*1000 ); | 304 | xine_play( m_stream, 0, time*1000 ); |
303 | } | 305 | } |
304 | 306 | ||
305 | 307 | ||
306 | Frame Lib::currentFrame() const { | 308 | Frame Lib::currentFrame() const { |
307 | assert( m_initialized ); | 309 | assert( m_initialized ); |
308 | 310 | ||
309 | Frame frame; | 311 | Frame frame; |
310 | return frame; | 312 | return frame; |
311 | }; | 313 | }; |
312 | 314 | ||
313 | QString Lib::metaInfo( int number) const { | 315 | QString Lib::metaInfo( int number) const { |
314 | assert( m_initialized ); | 316 | assert( m_initialized ); |
315 | 317 | ||
316 | return xine_get_meta_info( m_stream, number ); | 318 | return xine_get_meta_info( m_stream, number ); |
317 | } | 319 | } |
318 | 320 | ||
319 | int Lib::error() const { | 321 | int Lib::error() const { |
320 | assert( m_initialized ); | 322 | assert( m_initialized ); |
321 | 323 | ||
322 | return xine_get_error( m_stream ); | 324 | return xine_get_error( m_stream ); |
323 | }; | 325 | }; |
324 | 326 | ||
325 | void Lib::ensureInitialized() | 327 | void Lib::ensureInitialized() |
326 | { | 328 | { |
327 | if ( m_initialized ) | 329 | if ( m_initialized ) |
328 | return; | 330 | return; |
329 | 331 | ||
330 | odebug << "waiting for initialization thread to finish" << oendl; | 332 | odebug << "waiting for initialization thread to finish" << oendl; |
331 | wait(); | 333 | wait(); |
332 | odebug << "initialization thread finished!" << oendl; | 334 | odebug << "initialization thread finished!" << oendl; |
333 | } | 335 | } |
334 | 336 | ||
335 | void Lib::setWidget( XineVideoWidget *widget ) | 337 | void Lib::setWidget( XineVideoWidget *widget ) |
336 | { | 338 | { |
337 | m_wid = widget; | 339 | m_wid = widget; |
338 | resize ( m_wid-> size ( ) ); | 340 | resize ( m_wid-> size ( ) ); |
339 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 341 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
340 | m_wid->repaint(); | 342 | m_wid->repaint(); |
341 | } | 343 | } |
342 | 344 | ||
343 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 345 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
344 | { | 346 | { |
345 | assert( sendType == ThreadUtil::Channel::OneWay ); | 347 | assert( sendType == ThreadUtil::Channel::OneWay ); |
346 | handleXineEvent( msg->type() ); | 348 | handleXineEvent( msg->type() ); |
347 | delete msg; | 349 | delete msg; |
348 | } | 350 | } |
349 | 351 | ||
350 | void Lib::handleXineEvent( const xine_event_t* t ) { | 352 | void Lib::handleXineEvent( const xine_event_t* t ) { |
351 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 353 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
352 | } | 354 | } |
353 | 355 | ||
354 | void Lib::handleXineEvent( int type ) { | 356 | void Lib::handleXineEvent( int type ) { |
355 | assert( m_initialized ); | 357 | assert( m_initialized ); |
356 | 358 | ||
357 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 359 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
358 | emit stopped(); | 360 | emit stopped(); |
359 | } | 361 | } |
360 | } | 362 | } |
361 | 363 | ||
362 | 364 | ||
363 | void Lib::setShowVideo( bool video ) { | 365 | void Lib::setShowVideo( bool video ) { |
364 | assert( m_initialized ); | 366 | assert( m_initialized ); |
365 | 367 | ||
366 | m_video = video; | 368 | m_video = video; |
367 | ::null_set_show_video( m_videoOutput, video ); | 369 | ::null_set_show_video( m_videoOutput, video ); |
368 | } | 370 | } |
369 | 371 | ||
370 | bool Lib::isShowingVideo() const { | 372 | bool Lib::isShowingVideo() const { |
371 | assert( m_initialized ); | 373 | assert( m_initialized ); |
372 | 374 | ||
373 | return ::null_is_showing_video( m_videoOutput ); | 375 | return ::null_is_showing_video( m_videoOutput ); |
374 | } | 376 | } |
375 | 377 | ||
376 | bool Lib::hasVideo() const { | 378 | bool Lib::hasVideo() const { |
377 | assert( m_initialized ); | 379 | assert( m_initialized ); |
378 | 380 | ||
379 | return xine_get_stream_info( m_stream, 18 ); | 381 | return xine_get_stream_info( m_stream, 18 ); |
380 | } | 382 | } |
381 | 383 | ||
382 | void Lib::showVideoFullScreen( bool fullScreen ) { | 384 | void Lib::showVideoFullScreen( bool fullScreen ) { |
383 | assert( m_initialized ); | 385 | assert( m_initialized ); |
384 | 386 | ||
385 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 387 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
386 | } | 388 | } |
387 | 389 | ||
388 | bool Lib::isVideoFullScreen() const { | 390 | bool Lib::isVideoFullScreen() const { |
389 | assert( m_initialized ); | 391 | assert( m_initialized ); |
390 | 392 | ||
391 | return ::null_is_fullscreen( m_videoOutput ); | 393 | return ::null_is_fullscreen( m_videoOutput ); |
392 | } | 394 | } |
393 | 395 | ||
394 | void Lib::setScaling( bool scale ) { | 396 | void Lib::setScaling( bool scale ) { |
395 | assert( m_initialized ); | 397 | assert( m_initialized ); |
396 | 398 | ||
397 | ::null_set_scaling( m_videoOutput, scale ); | 399 | ::null_set_scaling( m_videoOutput, scale ); |
398 | } | 400 | } |
399 | 401 | ||
400 | void Lib::setGamma( int value ) { | 402 | void Lib::setGamma( int value ) { |
401 | assert( m_initialized ); | 403 | assert( m_initialized ); |
402 | 404 | ||
403 | ::null_set_videoGamma( m_videoOutput, value ); | 405 | ::null_set_videoGamma( m_videoOutput, value ); |
404 | } | 406 | } |
405 | 407 | ||
406 | bool Lib::isScaling() const { | 408 | bool Lib::isScaling() const { |
407 | assert( m_initialized ); | 409 | assert( m_initialized ); |
408 | 410 | ||
409 | return ::null_is_scaling( m_videoOutput ); | 411 | return ::null_is_scaling( m_videoOutput ); |
410 | } | 412 | } |
411 | 413 | ||
412 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 414 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
413 | ( (Lib*)user_data)->handleXineEvent( t ); | 415 | ( (Lib*)user_data)->handleXineEvent( t ); |
414 | } | 416 | } |
415 | 417 | ||
416 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 418 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
417 | int width, int height, int bytes ) { | 419 | int width, int height, int bytes ) { |
418 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 420 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
419 | } | 421 | } |
420 | 422 | ||
421 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 423 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
422 | assert( m_initialized ); | 424 | assert( m_initialized ); |
423 | 425 | ||
424 | if ( !m_video ) { | 426 | if ( !m_video ) { |
425 | owarn << "not showing video now" << oendl; | 427 | owarn << "not showing video now" << oendl; |
426 | return; | 428 | return; |
427 | } | 429 | } |
428 | 430 | ||
429 | assert( m_wid ); | 431 | assert( m_wid ); |
430 | 432 | ||
431 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 433 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
432 | } | 434 | } |
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 7e38fc7..7b4bfd9 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,401 +1,403 @@ | |||
1 | #include <qpe/qpeapplication.h> | ||
2 | #include <qpe/config.h> | ||
3 | #include <qfileinfo.h> | ||
4 | |||
5 | #include "mediaplayer.h" | 1 | #include "mediaplayer.h" |
6 | #include "audiowidget.h" | 2 | #include "audiowidget.h" |
7 | #include "videowidget.h" | 3 | #include "videowidget.h" |
8 | #include "volumecontrol.h" | 4 | #include "volumecontrol.h" |
9 | 5 | ||
6 | /* OPIE */ | ||
7 | #include <opie2/odebug.h> | ||
8 | #include <qpe/qpeapplication.h> | ||
9 | #include <qpe/config.h> | ||
10 | |||
11 | /* QT */ | ||
12 | #include <qfileinfo.h> | ||
10 | 13 | ||
11 | // for setBacklight() | 14 | /* STD */ |
12 | #include <linux/fb.h> | 15 | #include <linux/fb.h> |
13 | #include <sys/file.h> | 16 | #include <sys/file.h> |
14 | #include <sys/ioctl.h> | 17 | #include <sys/ioctl.h> |
15 | 18 | ||
16 | 19 | #define FBIOBLANK 0x4611 | |
17 | #define FBIOBLANK 0x4611 | ||
18 | 20 | ||
19 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 21 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
20 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 22 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
21 | 23 | ||
22 | m_audioUI = 0; | 24 | m_audioUI = 0; |
23 | m_videoUI = 0; | 25 | m_videoUI = 0; |
24 | m_xineControl = 0; | 26 | m_xineControl = 0; |
25 | xine = new XINE::Lib( XINE::Lib::InitializeInThread ); | 27 | xine = new XINE::Lib( XINE::Lib::InitializeInThread ); |
26 | 28 | ||
27 | fd=-1;fl=-1; | 29 | fd=-1;fl=-1; |
28 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 30 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
29 | 31 | ||
30 | qApp->processEvents(); | 32 | qApp->processEvents(); |
31 | // QPEApplication::grabKeyboard(); // EVIL | 33 | // QPEApplication::grabKeyboard(); // EVIL |
32 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 34 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
33 | 35 | ||
34 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 36 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
35 | 37 | ||
36 | // What is pauseCheck good for? (Simon) | 38 | // What is pauseCheck good for? (Simon) |
37 | // connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); | 39 | // connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pauseCheck(bool) ) ); |
38 | 40 | ||
39 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 41 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
40 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 42 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
41 | connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); | 43 | connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); |
42 | 44 | ||
43 | volControl = new VolumeControl; | 45 | volControl = new VolumeControl; |
44 | Config cfg( "OpiePlayer" ); | 46 | Config cfg( "OpiePlayer" ); |
45 | cfg.setGroup("PlayList"); | 47 | cfg.setGroup("PlayList"); |
46 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 48 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
47 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 49 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
48 | 50 | ||
49 | m_skinLoader = new SkinLoader; | 51 | m_skinLoader = new SkinLoader; |
50 | m_skinLoader->schedule( AudioWidget::guiInfo() ); | 52 | m_skinLoader->schedule( AudioWidget::guiInfo() ); |
51 | m_skinLoader->schedule( VideoWidget::guiInfo() ); | 53 | m_skinLoader->schedule( VideoWidget::guiInfo() ); |
52 | m_skinLoader->start(); | 54 | m_skinLoader->start(); |
53 | } | 55 | } |
54 | 56 | ||
55 | MediaPlayer::~MediaPlayer() { | 57 | MediaPlayer::~MediaPlayer() { |
56 | // this shold never happen, but one never knows... | 58 | // this shold never happen, but one never knows... |
57 | if ( xine ) { | 59 | if ( xine ) { |
58 | xine->ensureInitialized(); | 60 | xine->ensureInitialized(); |
59 | delete xine; | 61 | delete xine; |
60 | } | 62 | } |
61 | delete m_xineControl; | 63 | delete m_xineControl; |
62 | delete m_audioUI; | 64 | delete m_audioUI; |
63 | delete m_videoUI; | 65 | delete m_videoUI; |
64 | delete volControl; | 66 | delete volControl; |
65 | } | 67 | } |
66 | 68 | ||
67 | void MediaPlayer::pauseCheck( bool b ) { | 69 | void MediaPlayer::pauseCheck( bool b ) { |
68 | if ( b && !mediaPlayerState.isPlaying() ) { | 70 | if ( b && !mediaPlayerState.isPlaying() ) { |
69 | mediaPlayerState.setPaused( FALSE ); | 71 | mediaPlayerState.setPaused( FALSE ); |
70 | } | 72 | } |
71 | } | 73 | } |
72 | 74 | ||
73 | void MediaPlayer::play() { | 75 | void MediaPlayer::play() { |
74 | mediaPlayerState.setPlaying( FALSE ); | 76 | mediaPlayerState.setPlaying( FALSE ); |
75 | mediaPlayerState.setPlaying( TRUE ); | 77 | mediaPlayerState.setPlaying( TRUE ); |
76 | } | 78 | } |
77 | 79 | ||
78 | void MediaPlayer::setPlaying( bool play ) { | 80 | void MediaPlayer::setPlaying( bool play ) { |
79 | if ( !play ) { | 81 | if ( !play ) { |
80 | return; | 82 | return; |
81 | } | 83 | } |
82 | 84 | ||
83 | if ( mediaPlayerState.isPaused() ) { | 85 | if ( mediaPlayerState.isPaused() ) { |
84 | mediaPlayerState.setPaused( FALSE ); | 86 | mediaPlayerState.setPaused( FALSE ); |
85 | return; | 87 | return; |
86 | } | 88 | } |
87 | 89 | ||
88 | QString tickerText, time, fileName; | 90 | QString tickerText, time, fileName; |
89 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 91 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
90 | //if playing in file list.. play in a different way | 92 | //if playing in file list.. play in a different way |
91 | // random and looping settings enabled causes problems here, | 93 | // random and looping settings enabled causes problems here, |
92 | // since there is no selected file in the playlist, but a selected file in the file list, | 94 | // since there is no selected file in the playlist, but a selected file in the file list, |
93 | // so we remember and shutoff | 95 | // so we remember and shutoff |
94 | l = mediaPlayerState.isLooping(); | 96 | l = mediaPlayerState.isLooping(); |
95 | if(l) { | 97 | if(l) { |
96 | mediaPlayerState.setLooping( false ); | 98 | mediaPlayerState.setLooping( false ); |
97 | } | 99 | } |
98 | r = mediaPlayerState.isShuffled(); | 100 | r = mediaPlayerState.isShuffled(); |
99 | mediaPlayerState.setShuffled( false ); | 101 | mediaPlayerState.setShuffled( false ); |
100 | } | 102 | } |
101 | 103 | ||
102 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 104 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
103 | fileName = playListEntry.name; | 105 | fileName = playListEntry.name; |
104 | xineControl()->play( playListEntry.file ); | 106 | xineControl()->play( playListEntry.file ); |
105 | 107 | ||
106 | long seconds = mediaPlayerState.length(); | 108 | long seconds = mediaPlayerState.length(); |
107 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 109 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
108 | 110 | ||
109 | if( fileName.left(4) == "http" ) { | 111 | if( fileName.left(4) == "http" ) { |
110 | fileName = QFileInfo( fileName ).baseName(); | 112 | fileName = QFileInfo( fileName ).baseName(); |
111 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 113 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
112 | tickerText = tr( " File: " ) + fileName; | 114 | tickerText = tr( " File: " ) + fileName; |
113 | } else { | 115 | } else { |
114 | tickerText = xineControl()->getMetaInfo(); | 116 | tickerText = xineControl()->getMetaInfo(); |
115 | } | 117 | } |
116 | } else { | 118 | } else { |
117 | if ( xineControl()->getMetaInfo().isEmpty() ) { | 119 | if ( xineControl()->getMetaInfo().isEmpty() ) { |
118 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 120 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
119 | } else { | 121 | } else { |
120 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; | 122 | tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; |
121 | } | 123 | } |
122 | } | 124 | } |
123 | audioUI()->setTickerText( tickerText ); | 125 | audioUI()->setTickerText( tickerText ); |
124 | } | 126 | } |
125 | 127 | ||
126 | 128 | ||
127 | void MediaPlayer::prev() { | 129 | void MediaPlayer::prev() { |
128 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 130 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
129 | if ( playList.prev() ) { | 131 | if ( playList.prev() ) { |
130 | play(); | 132 | play(); |
131 | } else if ( mediaPlayerState.isLooping() ) { | 133 | } else if ( mediaPlayerState.isLooping() ) { |
132 | if ( playList.last() ) { | 134 | if ( playList.last() ) { |
133 | play(); | 135 | play(); |
134 | } | 136 | } |
135 | } else { | 137 | } else { |
136 | mediaPlayerState.setList(); | 138 | mediaPlayerState.setList(); |
137 | } | 139 | } |
138 | } | 140 | } |
139 | } | 141 | } |
140 | 142 | ||
141 | 143 | ||
142 | void MediaPlayer::next() { | 144 | void MediaPlayer::next() { |
143 | 145 | ||
144 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 146 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
145 | if ( playList.next() ) { | 147 | if ( playList.next() ) { |
146 | play(); | 148 | play(); |
147 | } else if ( mediaPlayerState.isLooping() ) { | 149 | } else if ( mediaPlayerState.isLooping() ) { |
148 | if ( playList.first() ) { | 150 | if ( playList.first() ) { |
149 | play(); | 151 | play(); |
150 | } | 152 | } |
151 | } else { | 153 | } else { |
152 | mediaPlayerState.setList(); | 154 | mediaPlayerState.setList(); |
153 | } | 155 | } |
154 | } else { //if playing from file list, let's just stop | 156 | } else { //if playing from file list, let's just stop |
155 | odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; | 157 | odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; |
156 | mediaPlayerState.setPlaying(false); | 158 | mediaPlayerState.setPlaying(false); |
157 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 159 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
158 | if(l) mediaPlayerState.setLooping(l); | 160 | if(l) mediaPlayerState.setLooping(l); |
159 | if(r) mediaPlayerState.setShuffled(r); | 161 | if(r) mediaPlayerState.setShuffled(r); |
160 | } | 162 | } |
161 | qApp->processEvents(); | 163 | qApp->processEvents(); |
162 | } | 164 | } |
163 | 165 | ||
164 | 166 | ||
165 | void MediaPlayer::startDecreasingVolume() { | 167 | void MediaPlayer::startDecreasingVolume() { |
166 | volumeDirection = -1; | 168 | volumeDirection = -1; |
167 | startTimer( 100 ); | 169 | startTimer( 100 ); |
168 | volControl->decVol(2); | 170 | volControl->decVol(2); |
169 | } | 171 | } |
170 | 172 | ||
171 | 173 | ||
172 | void MediaPlayer::startIncreasingVolume() { | 174 | void MediaPlayer::startIncreasingVolume() { |
173 | volumeDirection = +1; | 175 | volumeDirection = +1; |
174 | startTimer( 100 ); | 176 | startTimer( 100 ); |
175 | volControl->incVol(2); | 177 | volControl->incVol(2); |
176 | } | 178 | } |
177 | 179 | ||
178 | 180 | ||
179 | bool drawnOnScreenDisplay = FALSE; | 181 | bool drawnOnScreenDisplay = FALSE; |
180 | unsigned int onScreenDisplayVolume = 0; | 182 | unsigned int onScreenDisplayVolume = 0; |
181 | const int yoff = 110; | 183 | const int yoff = 110; |
182 | 184 | ||
183 | void MediaPlayer::stopChangingVolume() { | 185 | void MediaPlayer::stopChangingVolume() { |
184 | killTimers(); | 186 | killTimers(); |
185 | // Get rid of the on-screen display stuff | 187 | // Get rid of the on-screen display stuff |
186 | drawnOnScreenDisplay = FALSE; | 188 | drawnOnScreenDisplay = FALSE; |
187 | onScreenDisplayVolume = 0; | 189 | onScreenDisplayVolume = 0; |
188 | int w=0; | 190 | int w=0; |
189 | int h=0; | 191 | int h=0; |
190 | if( !xineControl()->hasVideo() ) { | 192 | if( !xineControl()->hasVideo() ) { |
191 | w = audioUI()->width(); | 193 | w = audioUI()->width(); |
192 | h = audioUI()->height(); | 194 | h = audioUI()->height(); |
193 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 195 | audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
194 | } else { | 196 | } else { |
195 | w = videoUI()->width(); | 197 | w = videoUI()->width(); |
196 | h = videoUI()->height(); | 198 | h = videoUI()->height(); |
197 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); | 199 | videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); |
198 | } | 200 | } |
199 | } | 201 | } |
200 | 202 | ||
201 | 203 | ||
202 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 204 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
203 | if ( volumeDirection == +1 ) { | 205 | if ( volumeDirection == +1 ) { |
204 | volControl->incVol( 2 ); | 206 | volControl->incVol( 2 ); |
205 | } else if ( volumeDirection == -1 ) { | 207 | } else if ( volumeDirection == -1 ) { |
206 | volControl->decVol( 2 ); | 208 | volControl->decVol( 2 ); |
207 | } | 209 | } |
208 | 210 | ||
209 | 211 | ||
210 | // TODO FIXME | 212 | // TODO FIXME |
211 | // huh?? | 213 | // huh?? |
212 | unsigned int v= 0; | 214 | unsigned int v= 0; |
213 | v = volControl->volume(); | 215 | v = volControl->volume(); |
214 | v = v / 10; | 216 | v = v / 10; |
215 | 217 | ||
216 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | 218 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { |
217 | return; | 219 | return; |
218 | } | 220 | } |
219 | 221 | ||
220 | int w=0; int h=0; | 222 | int w=0; int h=0; |
221 | if( !xineControl()->hasVideo() ) { | 223 | if( !xineControl()->hasVideo() ) { |
222 | w = audioUI()->width(); | 224 | w = audioUI()->width(); |
223 | h = audioUI()->height(); | 225 | h = audioUI()->height(); |
224 | 226 | ||
225 | if ( drawnOnScreenDisplay ) { | 227 | if ( drawnOnScreenDisplay ) { |
226 | if ( onScreenDisplayVolume > v ) { | 228 | if ( onScreenDisplayVolume > v ) { |
227 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 229 | audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
228 | } | 230 | } |
229 | } | 231 | } |
230 | drawnOnScreenDisplay = TRUE; | 232 | drawnOnScreenDisplay = TRUE; |
231 | onScreenDisplayVolume = v; | 233 | onScreenDisplayVolume = v; |
232 | QPainter p( audioUI() ); | 234 | QPainter p( audioUI() ); |
233 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 235 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
234 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 236 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
235 | 237 | ||
236 | QFont f; | 238 | QFont f; |
237 | f.setPixelSize( 20 ); | 239 | f.setPixelSize( 20 ); |
238 | f.setBold( TRUE ); | 240 | f.setBold( TRUE ); |
239 | p.setFont( f ); | 241 | p.setFont( f ); |
240 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | 242 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); |
241 | 243 | ||
242 | for ( unsigned int i = 0; i < 10; i++ ) { | 244 | for ( unsigned int i = 0; i < 10; i++ ) { |
243 | if ( v > i ) { | 245 | if ( v > i ) { |
244 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
245 | } else { | 247 | } else { |
246 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 248 | p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
247 | } | 249 | } |
248 | } | 250 | } |
249 | } else { | 251 | } else { |
250 | w = videoUI()->width(); | 252 | w = videoUI()->width(); |
251 | h = videoUI()->height(); | 253 | h = videoUI()->height(); |
252 | 254 | ||
253 | if ( drawnOnScreenDisplay ) { | 255 | if ( drawnOnScreenDisplay ) { |
254 | if ( onScreenDisplayVolume > v ) { | 256 | if ( onScreenDisplayVolume > v ) { |
255 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); | 257 | videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); |
256 | } | 258 | } |
257 | } | 259 | } |
258 | drawnOnScreenDisplay = TRUE; | 260 | drawnOnScreenDisplay = TRUE; |
259 | onScreenDisplayVolume = v; | 261 | onScreenDisplayVolume = v; |
260 | QPainter p( videoUI() ); | 262 | QPainter p( videoUI() ); |
261 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | 263 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); |
262 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | 264 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); |
263 | 265 | ||
264 | QFont f; | 266 | QFont f; |
265 | f.setPixelSize( 20 ); | 267 | f.setPixelSize( 20 ); |
266 | f.setBold( TRUE ); | 268 | f.setBold( TRUE ); |
267 | p.setFont( f ); | 269 | p.setFont( f ); |
268 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); | 270 | p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); |
269 | 271 | ||
270 | for ( unsigned int i = 0; i < 10; i++ ) { | 272 | for ( unsigned int i = 0; i < 10; i++ ) { |
271 | if ( v > i ) { | 273 | if ( v > i ) { |
272 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | 274 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); |
273 | } else { | 275 | } else { |
274 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | 276 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); |
275 | } | 277 | } |
276 | } | 278 | } |
277 | } | 279 | } |
278 | } | 280 | } |
279 | 281 | ||
280 | 282 | ||
281 | void MediaPlayer::blank( bool b ) { | 283 | void MediaPlayer::blank( bool b ) { |
282 | fd=open("/dev/fb0",O_RDWR); | 284 | fd=open("/dev/fb0",O_RDWR); |
283 | #ifdef QT_QWS_SL5XXX | 285 | #ifdef QT_QWS_SL5XXX |
284 | fl= open( "/dev/fl", O_RDWR ); | 286 | fl= open( "/dev/fl", O_RDWR ); |
285 | #endif | 287 | #endif |
286 | if (fd != -1) { | 288 | if (fd != -1) { |
287 | if ( b ) { | 289 | if ( b ) { |
288 | odebug << "do blanking" << oendl; | 290 | odebug << "do blanking" << oendl; |
289 | #ifdef QT_QWS_SL5XXX | 291 | #ifdef QT_QWS_SL5XXX |
290 | ioctl( fd, FBIOBLANK, 1 ); | 292 | ioctl( fd, FBIOBLANK, 1 ); |
291 | if(fl !=-1) { | 293 | if(fl !=-1) { |
292 | ioctl( fl, 2 ); | 294 | ioctl( fl, 2 ); |
293 | ::close(fl); | 295 | ::close(fl); |
294 | } | 296 | } |
295 | #else | 297 | #else |
296 | ioctl( fd, FBIOBLANK, 3 ); | 298 | ioctl( fd, FBIOBLANK, 3 ); |
297 | #endif | 299 | #endif |
298 | isBlanked = TRUE; | 300 | isBlanked = TRUE; |
299 | } else { | 301 | } else { |
300 | odebug << "do unblanking" << oendl; | 302 | odebug << "do unblanking" << oendl; |
301 | ioctl( fd, FBIOBLANK, 0); | 303 | ioctl( fd, FBIOBLANK, 0); |
302 | #ifdef QT_QWS_SL5XXX | 304 | #ifdef QT_QWS_SL5XXX |
303 | if(fl != -1) { | 305 | if(fl != -1) { |
304 | ioctl( fl, 1); | 306 | ioctl( fl, 1); |
305 | ::close(fl); | 307 | ::close(fl); |
306 | } | 308 | } |
307 | #endif | 309 | #endif |
308 | isBlanked = FALSE; | 310 | isBlanked = FALSE; |
309 | } | 311 | } |
310 | close( fd ); | 312 | close( fd ); |
311 | } else { | 313 | } else { |
312 | odebug << "<< /dev/fb0 could not be opened >>" << oendl; | 314 | odebug << "<< /dev/fb0 could not be opened >>" << oendl; |
313 | } | 315 | } |
314 | } | 316 | } |
315 | 317 | ||
316 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 318 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
317 | switch ( e->key() ) { | 319 | switch ( e->key() ) { |
318 | ////////////////////////////// Zaurus keys | 320 | ////////////////////////////// Zaurus keys |
319 | case Key_Home: | 321 | case Key_Home: |
320 | break; | 322 | break; |
321 | case Key_F9: //activity | 323 | case Key_F9: //activity |
322 | break; | 324 | break; |
323 | case Key_F10: //contacts | 325 | case Key_F10: //contacts |
324 | break; | 326 | break; |
325 | case Key_F11: //menu | 327 | case Key_F11: //menu |
326 | break; | 328 | break; |
327 | case Key_F12: //home | 329 | case Key_F12: //home |
328 | odebug << "Blank here" << oendl; | 330 | odebug << "Blank here" << oendl; |
329 | // mediaPlayerState->toggleBlank(); | 331 | // mediaPlayerState->toggleBlank(); |
330 | break; | 332 | break; |
331 | case Key_F13: //mail | 333 | case Key_F13: //mail |
332 | odebug << "Blank here" << oendl; | 334 | odebug << "Blank here" << oendl; |
333 | // mediaPlayerState->toggleBlank(); | 335 | // mediaPlayerState->toggleBlank(); |
334 | break; | 336 | break; |
335 | } | 337 | } |
336 | } | 338 | } |
337 | 339 | ||
338 | void MediaPlayer::cleanUp() {// this happens on closing | 340 | void MediaPlayer::cleanUp() {// this happens on closing |
339 | Config cfg( "OpiePlayer" ); | 341 | Config cfg( "OpiePlayer" ); |
340 | mediaPlayerState.writeConfig( cfg ); | 342 | mediaPlayerState.writeConfig( cfg ); |
341 | playList.writeDefaultPlaylist( ); | 343 | playList.writeDefaultPlaylist( ); |
342 | 344 | ||
343 | // QPEApplication::grabKeyboard(); | 345 | // QPEApplication::grabKeyboard(); |
344 | // QPEApplication::ungrabKeyboard(); | 346 | // QPEApplication::ungrabKeyboard(); |
345 | } | 347 | } |
346 | 348 | ||
347 | void MediaPlayer::recreateAudioAndVideoWidgets() const | 349 | void MediaPlayer::recreateAudioAndVideoWidgets() const |
348 | { | 350 | { |
349 | delete m_skinLoader; | 351 | delete m_skinLoader; |
350 | 352 | ||
351 | delete m_xineControl; | 353 | delete m_xineControl; |
352 | delete m_audioUI; | 354 | delete m_audioUI; |
353 | delete m_videoUI; | 355 | delete m_videoUI; |
354 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 356 | m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
355 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 357 | m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
356 | 358 | ||
357 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 359 | connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 360 | connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 361 | connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 362 | connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
361 | 363 | ||
362 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 364 | connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
363 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 365 | connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
364 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 366 | connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 367 | connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
366 | 368 | ||
367 | if ( !xine ) | 369 | if ( !xine ) |
368 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); | 370 | xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); |
369 | 371 | ||
370 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); | 372 | m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); |
371 | 373 | ||
372 | xine = 0; | 374 | xine = 0; |
373 | } | 375 | } |
374 | 376 | ||
375 | AudioWidget *MediaPlayer::audioUI() const | 377 | AudioWidget *MediaPlayer::audioUI() const |
376 | { | 378 | { |
377 | if ( !m_audioUI ) | 379 | if ( !m_audioUI ) |
378 | recreateAudioAndVideoWidgets(); | 380 | recreateAudioAndVideoWidgets(); |
379 | return m_audioUI; | 381 | return m_audioUI; |
380 | } | 382 | } |
381 | 383 | ||
382 | VideoWidget *MediaPlayer::videoUI() const | 384 | VideoWidget *MediaPlayer::videoUI() const |
383 | { | 385 | { |
384 | if ( !m_videoUI ) | 386 | if ( !m_videoUI ) |
385 | recreateAudioAndVideoWidgets(); | 387 | recreateAudioAndVideoWidgets(); |
386 | return m_videoUI; | 388 | return m_videoUI; |
387 | } | 389 | } |
388 | 390 | ||
389 | XineControl *MediaPlayer::xineControl() const | 391 | XineControl *MediaPlayer::xineControl() const |
390 | { | 392 | { |
391 | if ( !m_xineControl ) | 393 | if ( !m_xineControl ) |
392 | recreateAudioAndVideoWidgets(); | 394 | recreateAudioAndVideoWidgets(); |
393 | return m_xineControl; | 395 | return m_xineControl; |
394 | } | 396 | } |
395 | 397 | ||
396 | void MediaPlayer::reloadSkins() | 398 | void MediaPlayer::reloadSkins() |
397 | { | 399 | { |
398 | audioUI()->loadSkin(); | 400 | audioUI()->loadSkin(); |
399 | videoUI()->loadSkin(); | 401 | videoUI()->loadSkin(); |
400 | } | 402 | } |
401 | 403 | ||
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 95dbab5..790fa09 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -1,150 +1,152 @@ | |||
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 L. Potter <ljp@llornkcor.com> | 4 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; General Public License for more | 20 | ..}^=.= = ; General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = General Public License along with | 24 | -_. . . )=. = General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "om3u.h" | 32 | #include "om3u.h" |
33 | 33 | ||
34 | 34 | /* OPIE */ | |
35 | #include <opie2/odebug.h> | ||
36 | using namespace Opie::Core; | ||
35 | 37 | ||
36 | //extern PlayListWidget *playList; | 38 | //extern PlayListWidget *playList; |
37 | 39 | ||
38 | Om3u::Om3u( const QString &filePath, int mode) | 40 | Om3u::Om3u( const QString &filePath, int mode) |
39 | : QStringList (){ | 41 | : QStringList (){ |
40 | odebug << "<<<<<<<new m3u "+filePath << oendl; | 42 | odebug << "<<<<<<<new m3u "+filePath << oendl; |
41 | f.setName(filePath); | 43 | f.setName(filePath); |
42 | f.open(mode); | 44 | f.open(mode); |
43 | } | 45 | } |
44 | 46 | ||
45 | Om3u::~Om3u(){} | 47 | Om3u::~Om3u(){} |
46 | 48 | ||
47 | void Om3u::readM3u() { | 49 | void Om3u::readM3u() { |
48 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; | 50 | // odebug << "<<<<<<reading m3u "+f.name() << oendl; |
49 | QTextStream t(&f); | 51 | QTextStream t(&f); |
50 | t.setEncoding(QTextStream::UnicodeUTF8); | 52 | t.setEncoding(QTextStream::UnicodeUTF8); |
51 | QString s; | 53 | QString s; |
52 | while ( !t.atEnd() ) { | 54 | while ( !t.atEnd() ) { |
53 | s=t.readLine(); | 55 | s=t.readLine(); |
54 | // odebug << s << oendl; | 56 | // odebug << s << oendl; |
55 | if( s.find( "#", 0, TRUE) == -1 ) { | 57 | if( s.find( "#", 0, TRUE) == -1 ) { |
56 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 58 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
57 | s = s.right( s.length() -2 ); | 59 | s = s.right( s.length() -2 ); |
58 | QFileInfo f( s ); | 60 | QFileInfo f( s ); |
59 | QString name = f.baseName(); | 61 | QString name = f.baseName(); |
60 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 62 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
61 | s=s.replace( QRegExp( "\\" ), "/" ); | 63 | s=s.replace( QRegExp( "\\" ), "/" ); |
62 | append(s); | 64 | append(s); |
63 | // odebug << s << oendl; | 65 | // odebug << s << oendl; |
64 | } else { // is url | 66 | } else { // is url |
65 | QString name; | 67 | QString name; |
66 | name = s; | 68 | name = s; |
67 | append(name); | 69 | append(name); |
68 | } | 70 | } |
69 | } | 71 | } |
70 | } | 72 | } |
71 | } | 73 | } |
72 | 74 | ||
73 | void Om3u::readPls() { //it's a pls file | 75 | void Om3u::readPls() { //it's a pls file |
74 | QTextStream t( &f ); | 76 | QTextStream t( &f ); |
75 | t.setEncoding(QTextStream::UnicodeUTF8); | 77 | t.setEncoding(QTextStream::UnicodeUTF8); |
76 | QString s; | 78 | QString s; |
77 | while ( !t.atEnd() ) { | 79 | while ( !t.atEnd() ) { |
78 | s = t.readLine(); | 80 | s = t.readLine(); |
79 | if( s.left(4) == "File" ) { | 81 | if( s.left(4) == "File" ) { |
80 | s = s.right( s.length() - s.find("=",0,true)-1 ); | 82 | s = s.right( s.length() - s.find("=",0,true)-1 ); |
81 | s = s.stripWhiteSpace(); | 83 | s = s.stripWhiteSpace(); |
82 | s.replace( QRegExp( "%20" )," "); | 84 | s.replace( QRegExp( "%20" )," "); |
83 | // odebug << "adding " + s + " to playlist" << oendl; | 85 | // odebug << "adding " + s + " to playlist" << oendl; |
84 | // numberofentries=2 | 86 | // numberofentries=2 |
85 | // File1=http | 87 | // File1=http |
86 | // Title | 88 | // Title |
87 | // Length | 89 | // Length |
88 | // Version | 90 | // Version |
89 | // File2=http | 91 | // File2=http |
90 | s = s.replace( QRegExp( "\\" ), "/" ); | 92 | s = s.replace( QRegExp( "\\" ), "/" ); |
91 | QFileInfo f( s ); | 93 | QFileInfo f( s ); |
92 | QString name = f.baseName(); | 94 | QString name = f.baseName(); |
93 | if( name.left( 4 ) == "http" ) { | 95 | if( name.left( 4 ) == "http" ) { |
94 | name = s.right( s.length() - 7); | 96 | name = s.right( s.length() - 7); |
95 | } else { | 97 | } else { |
96 | name = s; | 98 | name = s; |
97 | } | 99 | } |
98 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 100 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
99 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 101 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
100 | append(s); | 102 | append(s); |
101 | else { //if its a url | 103 | else { //if its a url |
102 | // if( name.right( 1 ).find( '/' ) == -1) { | 104 | // if( name.right( 1 ).find( '/' ) == -1) { |
103 | // s += "/"; | 105 | // s += "/"; |
104 | // } | 106 | // } |
105 | append(s); | 107 | append(s); |
106 | } | 108 | } |
107 | } | 109 | } |
108 | } | 110 | } |
109 | } | 111 | } |
110 | 112 | ||
111 | void Om3u::write() { //writes list to m3u file | 113 | void Om3u::write() { //writes list to m3u file |
112 | QString list; | 114 | QString list; |
113 | QTextStream t(&f); | 115 | QTextStream t(&f); |
114 | t.setEncoding(QTextStream::UnicodeUTF8); | 116 | t.setEncoding(QTextStream::UnicodeUTF8); |
115 | if(count()>0) { | 117 | if(count()>0) { |
116 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 118 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
117 | // odebug << *it << oendl; | 119 | // odebug << *it << oendl; |
118 | t << *it << "\n"; | 120 | t << *it << "\n"; |
119 | } | 121 | } |
120 | } | 122 | } |
121 | // f.close(); | 123 | // f.close(); |
122 | } | 124 | } |
123 | 125 | ||
124 | void Om3u::add(const QString &filePath) { //adds to m3u file | 126 | void Om3u::add(const QString &filePath) { //adds to m3u file |
125 | append(filePath); | 127 | append(filePath); |
126 | } | 128 | } |
127 | 129 | ||
128 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 130 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
129 | QString list, currentFile; | 131 | QString list, currentFile; |
130 | if(count()>0) { | 132 | if(count()>0) { |
131 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 133 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
132 | currentFile=*it; | 134 | currentFile=*it; |
133 | // odebug << *it << oendl; | 135 | // odebug << *it << oendl; |
134 | 136 | ||
135 | if( filePath != currentFile) | 137 | if( filePath != currentFile) |
136 | list += currentFile+"\n"; | 138 | list += currentFile+"\n"; |
137 | } | 139 | } |
138 | f.writeBlock( list, list.length() ); | 140 | f.writeBlock( list, list.length() ); |
139 | } | 141 | } |
140 | } | 142 | } |
141 | 143 | ||
142 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file | 144 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file |
143 | f.close(); | 145 | f.close(); |
144 | f.remove(); | 146 | f.remove(); |
145 | 147 | ||
146 | } | 148 | } |
147 | 149 | ||
148 | void Om3u::close() { //closes m3u file | 150 | void Om3u::close() { //closes m3u file |
149 | f.close(); | 151 | f.close(); |
150 | } | 152 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 3499837..678ebdf 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp | |||
@@ -1,206 +1,211 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "playlistselection.h" | ||
20 | 21 | ||
21 | #include <qheader.h> | 22 | /* OPIE */ |
23 | #include <opie2/odebug.h> | ||
24 | using namespace Opie::Core; | ||
22 | 25 | ||
23 | #include "playlistselection.h" | 26 | /* QT */ |
27 | #include <qheader.h> | ||
24 | 28 | ||
29 | /* STD */ | ||
25 | #include <stdlib.h> | 30 | #include <stdlib.h> |
26 | 31 | ||
27 | class PlayListSelectionItem : public QListViewItem { | 32 | class PlayListSelectionItem : public QListViewItem { |
28 | public: | 33 | public: |
29 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
30 | setText( 0, f->name() ); | 35 | setText( 0, f->name() ); |
31 | setPixmap( 0, f->pixmap() ); | 36 | setPixmap( 0, f->pixmap() ); |
32 | } | 37 | } |
33 | 38 | ||
34 | ~PlayListSelectionItem() { | 39 | ~PlayListSelectionItem() { |
35 | }; | 40 | }; |
36 | 41 | ||
37 | const DocLnk *file() const { return fl; } | 42 | const DocLnk *file() const { return fl; } |
38 | 43 | ||
39 | private: | 44 | private: |
40 | const DocLnk *fl; | 45 | const DocLnk *fl; |
41 | }; | 46 | }; |
42 | 47 | ||
43 | 48 | ||
44 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
45 | : QListView( parent, name ) | 50 | : QListView( parent, name ) |
46 | { | 51 | { |
47 | // odebug << "starting playlistselector" << oendl; | 52 | // odebug << "starting playlistselector" << oendl; |
48 | // #ifdef USE_PLAYLIST_BACKGROUND | 53 | // #ifdef USE_PLAYLIST_BACKGROUND |
49 | // setStaticBackground( TRUE ); | 54 | // setStaticBackground( TRUE ); |
50 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 55 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
51 | 56 | ||
52 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 57 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
53 | // #endif | 58 | // #endif |
54 | // addColumn("Title",236); | 59 | // addColumn("Title",236); |
55 | // setAllColumnsShowFocus( TRUE ); | 60 | // setAllColumnsShowFocus( TRUE ); |
56 | addColumn( tr( "Playlist Selection" ) ); | 61 | addColumn( tr( "Playlist Selection" ) ); |
57 | header()->hide(); | 62 | header()->hide(); |
58 | setSorting( -1, FALSE ); | 63 | setSorting( -1, FALSE ); |
59 | } | 64 | } |
60 | 65 | ||
61 | 66 | ||
62 | PlayListSelection::~PlayListSelection() { | 67 | PlayListSelection::~PlayListSelection() { |
63 | } | 68 | } |
64 | 69 | ||
65 | 70 | ||
66 | // #ifdef USE_PLAYLIST_BACKGROUND | 71 | // #ifdef USE_PLAYLIST_BACKGROUND |
67 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 72 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
68 | // odebug << "drawBackground" << oendl; | 73 | // odebug << "drawBackground" << oendl; |
69 | p->fillRect( r, QBrush( white ) ); | 74 | p->fillRect( r, QBrush( white ) ); |
70 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 75 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
71 | // if ( !logo.isNull() ) | 76 | // if ( !logo.isNull() ) |
72 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 77 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
73 | } | 78 | } |
74 | // #endif | 79 | // #endif |
75 | 80 | ||
76 | 81 | ||
77 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 82 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
78 | if ( event->state() == QMouseEvent::LeftButton ) { | 83 | if ( event->state() == QMouseEvent::LeftButton ) { |
79 | QListViewItem *currentItem = selectedItem(); | 84 | QListViewItem *currentItem = selectedItem(); |
80 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 85 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
81 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 86 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
82 | moveSelectedUp(); | 87 | moveSelectedUp(); |
83 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 88 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
84 | moveSelectedDown(); | 89 | moveSelectedDown(); |
85 | } | 90 | } |
86 | } | 91 | } |
87 | 92 | ||
88 | 93 | ||
89 | const DocLnk *PlayListSelection::current() { | 94 | const DocLnk *PlayListSelection::current() { |
90 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 95 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
91 | if ( item ) | 96 | if ( item ) |
92 | return item->file(); | 97 | return item->file(); |
93 | return NULL; | 98 | return NULL; |
94 | } | 99 | } |
95 | 100 | ||
96 | 101 | ||
97 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 102 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
98 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 103 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
99 | QListViewItem *current = selectedItem(); | 104 | QListViewItem *current = selectedItem(); |
100 | if ( current ) | 105 | if ( current ) |
101 | item->moveItem( current ); | 106 | item->moveItem( current ); |
102 | setSelected( item, TRUE ); | 107 | setSelected( item, TRUE ); |
103 | ensureItemVisible( selectedItem() ); | 108 | ensureItemVisible( selectedItem() ); |
104 | } | 109 | } |
105 | 110 | ||
106 | 111 | ||
107 | void PlayListSelection::removeSelected() { | 112 | void PlayListSelection::removeSelected() { |
108 | QListViewItem *item = selectedItem(); | 113 | QListViewItem *item = selectedItem(); |
109 | delete item; | 114 | delete item; |
110 | setSelected( currentItem(), TRUE ); | 115 | setSelected( currentItem(), TRUE ); |
111 | ensureItemVisible( selectedItem() ); | 116 | ensureItemVisible( selectedItem() ); |
112 | } | 117 | } |
113 | 118 | ||
114 | 119 | ||
115 | void PlayListSelection::moveSelectedUp() { | 120 | void PlayListSelection::moveSelectedUp() { |
116 | QListViewItem *item = selectedItem(); | 121 | QListViewItem *item = selectedItem(); |
117 | if ( item && item->itemAbove() ) | 122 | if ( item && item->itemAbove() ) |
118 | item->itemAbove()->moveItem( item ); | 123 | item->itemAbove()->moveItem( item ); |
119 | ensureItemVisible( selectedItem() ); | 124 | ensureItemVisible( selectedItem() ); |
120 | } | 125 | } |
121 | 126 | ||
122 | 127 | ||
123 | void PlayListSelection::moveSelectedDown() { | 128 | void PlayListSelection::moveSelectedDown() { |
124 | QListViewItem *item = selectedItem(); | 129 | QListViewItem *item = selectedItem(); |
125 | if ( item && item->itemBelow() ) | 130 | if ( item && item->itemBelow() ) |
126 | item->moveItem( item->itemBelow() ); | 131 | item->moveItem( item->itemBelow() ); |
127 | ensureItemVisible( selectedItem() ); | 132 | ensureItemVisible( selectedItem() ); |
128 | } | 133 | } |
129 | 134 | ||
130 | 135 | ||
131 | bool PlayListSelection::prev() { | 136 | bool PlayListSelection::prev() { |
132 | QListViewItem *item = selectedItem(); | 137 | QListViewItem *item = selectedItem(); |
133 | if ( item && item->itemAbove() ) | 138 | if ( item && item->itemAbove() ) |
134 | setSelected( item->itemAbove(), TRUE ); | 139 | setSelected( item->itemAbove(), TRUE ); |
135 | else | 140 | else |
136 | return FALSE; | 141 | return FALSE; |
137 | ensureItemVisible( selectedItem() ); | 142 | ensureItemVisible( selectedItem() ); |
138 | return TRUE; | 143 | return TRUE; |
139 | } | 144 | } |
140 | 145 | ||
141 | bool PlayListSelection::next() { | 146 | bool PlayListSelection::next() { |
142 | QListViewItem *item = selectedItem(); | 147 | QListViewItem *item = selectedItem(); |
143 | if ( item && item->itemBelow() ) | 148 | if ( item && item->itemBelow() ) |
144 | setSelected( item->itemBelow(), TRUE ); | 149 | setSelected( item->itemBelow(), TRUE ); |
145 | else | 150 | else |
146 | return FALSE; | 151 | return FALSE; |
147 | ensureItemVisible( selectedItem() ); | 152 | ensureItemVisible( selectedItem() ); |
148 | return TRUE; | 153 | return TRUE; |
149 | } | 154 | } |
150 | 155 | ||
151 | 156 | ||
152 | bool PlayListSelection::first() { | 157 | bool PlayListSelection::first() { |
153 | QListViewItem *item = firstChild(); | 158 | QListViewItem *item = firstChild(); |
154 | if ( item ) | 159 | if ( item ) |
155 | setSelected( item, TRUE ); | 160 | setSelected( item, TRUE ); |
156 | else | 161 | else |
157 | return FALSE; | 162 | return FALSE; |
158 | ensureItemVisible( selectedItem() ); | 163 | ensureItemVisible( selectedItem() ); |
159 | return TRUE; | 164 | return TRUE; |
160 | } | 165 | } |
161 | 166 | ||
162 | 167 | ||
163 | bool PlayListSelection::last() { | 168 | bool PlayListSelection::last() { |
164 | QListViewItem *prevItem = NULL; | 169 | QListViewItem *prevItem = NULL; |
165 | QListViewItem *item = firstChild(); | 170 | QListViewItem *item = firstChild(); |
166 | while ( ( item = item->nextSibling() ) ) | 171 | while ( ( item = item->nextSibling() ) ) |
167 | prevItem = item; | 172 | prevItem = item; |
168 | if ( prevItem ) | 173 | if ( prevItem ) |
169 | setSelected( prevItem, TRUE ); | 174 | setSelected( prevItem, TRUE ); |
170 | else | 175 | else |
171 | return FALSE; | 176 | return FALSE; |
172 | ensureItemVisible( selectedItem() ); | 177 | ensureItemVisible( selectedItem() ); |
173 | return TRUE; | 178 | return TRUE; |
174 | } | 179 | } |
175 | 180 | ||
176 | void PlayListSelection::unSelect() | 181 | void PlayListSelection::unSelect() |
177 | { | 182 | { |
178 | //QListViewItem *item = selectedItem(); | 183 | //QListViewItem *item = selectedItem(); |
179 | setSelected( currentItem(), FALSE); | 184 | setSelected( currentItem(), FALSE); |
180 | } | 185 | } |
181 | 186 | ||
182 | void PlayListSelection::writeCurrent( Config& cfg ) { | 187 | void PlayListSelection::writeCurrent( Config& cfg ) { |
183 | cfg.setGroup("PlayList"); | 188 | cfg.setGroup("PlayList"); |
184 | QListViewItem *item = selectedItem(); | 189 | QListViewItem *item = selectedItem(); |
185 | if ( item ) | 190 | if ( item ) |
186 | cfg.writeEntry("current", item->text(0) ); | 191 | cfg.writeEntry("current", item->text(0) ); |
187 | odebug << item->text(0) << oendl; | 192 | odebug << item->text(0) << oendl; |
188 | 193 | ||
189 | } | 194 | } |
190 | 195 | ||
191 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 196 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
192 | 197 | ||
193 | unSelect(); | 198 | unSelect(); |
194 | QListViewItemIterator it( this ); | 199 | QListViewItemIterator it( this ); |
195 | for ( ; it.current(); ++it ) { | 200 | for ( ; it.current(); ++it ) { |
196 | // odebug << it.current()->text(0) << oendl; | 201 | // odebug << it.current()->text(0) << oendl; |
197 | if( strk == it.current()->text(0)) { | 202 | if( strk == it.current()->text(0)) { |
198 | // odebug << "We have a match "+strk << oendl; | 203 | // odebug << "We have a match "+strk << oendl; |
199 | setSelected( it.current(), TRUE); | 204 | setSelected( it.current(), TRUE); |
200 | ensureItemVisible( it.current() ); | 205 | ensureItemVisible( it.current() ); |
201 | return; | 206 | return; |
202 | } | 207 | } |
203 | } | 208 | } |
204 | // setSelected( item, TRUE ); | 209 | // setSelected( item, TRUE ); |
205 | // ensureItemVisible( selectedItem() ); | 210 | // ensureItemVisible( selectedItem() ); |
206 | } | 211 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 956d206..6a15134 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1043 +1,1046 @@ | |||
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,2003 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002,2003 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 | #include <qtoolbar.h> | ||
35 | |||
36 | #include <opie2/ofiledialog.h> | ||
37 | |||
38 | #include <qmessagebox.h> | ||
39 | |||
40 | #include "playlistselection.h" | 34 | #include "playlistselection.h" |
41 | #include "playlistwidget.h" | 35 | #include "playlistwidget.h" |
42 | #include "mediaplayer.h" | 36 | #include "mediaplayer.h" |
43 | #include "inputDialog.h" | 37 | #include "inputDialog.h" |
44 | #include "om3u.h" | 38 | #include "om3u.h" |
45 | #include "playlistfileview.h" | 39 | #include "playlistfileview.h" |
46 | 40 | ||
47 | //only needed for the random play | 41 | /* OPIE */ |
42 | #include <opie2/odebug.h> | ||
43 | #include <opie2/ofiledialog.h> | ||
44 | using namespace Opie::Core; | ||
45 | using namespace Opie::Ui; | ||
46 | |||
47 | /* QT */ | ||
48 | #include <qmessagebox.h> | ||
49 | #include <qtoolbar.h> | ||
50 | |||
51 | /* STD */ | ||
48 | #include <assert.h> | 52 | #include <assert.h> |
49 | 53 | ||
50 | using namespace Opie::Ui; | ||
51 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
52 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
53 | { | 56 | { |
54 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 57 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
55 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 58 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
56 | 59 | ||
57 | 60 | ||
58 | 61 | ||
59 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
60 | "opieplayer2/add_to_playlist", | 63 | "opieplayer2/add_to_playlist", |
61 | this , SLOT(addSelected() ) ); | 64 | this , SLOT(addSelected() ) ); |
62 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
63 | "opieplayer2/remove_from_playlist", | 66 | "opieplayer2/remove_from_playlist", |
64 | this , SLOT(removeSelected() ) ); | 67 | this , SLOT(removeSelected() ) ); |
65 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
66 | this , SLOT( btnPlay(bool) ), TRUE ); | 69 | this , SLOT( btnPlay(bool) ), TRUE ); |
67 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 70 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
68 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); | 71 | mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); |
69 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 72 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
70 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); | 73 | mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); |
71 | 74 | ||
72 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 75 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
73 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 76 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
74 | this, SLOT( addAllMusicToList() ) ); | 77 | this, SLOT( addAllMusicToList() ) ); |
75 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 78 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
76 | this, SLOT( addAllVideoToList() ) ); | 79 | this, SLOT( addAllVideoToList() ) ); |
77 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 80 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
78 | this, SLOT( addAllToList() ) ); | 81 | this, SLOT( addAllToList() ) ); |
79 | pmPlayList->insertSeparator(-1); | 82 | pmPlayList->insertSeparator(-1); |
80 | (void)new MenuItem( pmPlayList, tr( "Add File" ), | 83 | (void)new MenuItem( pmPlayList, tr( "Add File" ), |
81 | this,SLOT( openFile() ) ); | 84 | this,SLOT( openFile() ) ); |
82 | (void)new MenuItem( pmPlayList, tr("Add URL"), | 85 | (void)new MenuItem( pmPlayList, tr("Add URL"), |
83 | this,SLOT( openURL() ) ); | 86 | this,SLOT( openURL() ) ); |
84 | pmPlayList->insertSeparator(-1); | 87 | pmPlayList->insertSeparator(-1); |
85 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
86 | this, SLOT(writem3u() ) ); | 89 | this, SLOT(writem3u() ) ); |
87 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
88 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
89 | audioView, SLOT( scanFiles() ) ); | 92 | audioView, SLOT( scanFiles() ) ); |
90 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
91 | videoView, SLOT( scanFiles() ) ); | 94 | videoView, SLOT( scanFiles() ) ); |
92 | 95 | ||
93 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 96 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
94 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 97 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
95 | 98 | ||
96 | Config cfg( "OpiePlayer" ); | 99 | Config cfg( "OpiePlayer" ); |
97 | bool b= cfg.readBoolEntry("FullScreen", 0); | 100 | bool b= cfg.readBoolEntry("FullScreen", 0); |
98 | mediaPlayerState->setFullscreen( b ); | 101 | mediaPlayerState->setFullscreen( b ); |
99 | pmView->setItemChecked( -16, b ); | 102 | pmView->setItemChecked( -16, b ); |
100 | 103 | ||
101 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 104 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
102 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 105 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
103 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 106 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
104 | d->selectedFiles, SLOT(removeSelected() ) ); | 107 | d->selectedFiles, SLOT(removeSelected() ) ); |
105 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 108 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
106 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 109 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
107 | QVBox *stretch2 = new QVBox( vbox1 ); | 110 | QVBox *stretch2 = new QVBox( vbox1 ); |
108 | 111 | ||
109 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 112 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
110 | SLOT( deletePlaylist() ) ); | 113 | SLOT( deletePlaylist() ) ); |
111 | connect( pmView, SIGNAL( activated(int) ), | 114 | connect( pmView, SIGNAL( activated(int) ), |
112 | this, SLOT( pmViewActivated(int) ) ); | 115 | this, SLOT( pmViewActivated(int) ) ); |
113 | connect( skinsMenu, SIGNAL( activated(int) ) , | 116 | connect( skinsMenu, SIGNAL( activated(int) ) , |
114 | this, SLOT( skinsMenuActivated(int) ) ); | 117 | this, SLOT( skinsMenuActivated(int) ) ); |
115 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 118 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
116 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 119 | this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
117 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 120 | connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
118 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 121 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
119 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), | 122 | connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), |
120 | this,SLOT( playIt(QListViewItem*) ) ); | 123 | this,SLOT( playIt(QListViewItem*) ) ); |
121 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), | 124 | connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), |
122 | this, SLOT( addToSelection(QListViewItem*) ) ); | 125 | this, SLOT( addToSelection(QListViewItem*) ) ); |
123 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), | 126 | connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), |
124 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); | 127 | this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); |
125 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), | 128 | connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), |
126 | this,SLOT( playIt(QListViewItem*) ) ); | 129 | this,SLOT( playIt(QListViewItem*) ) ); |
127 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), | 130 | connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), |
128 | this, SLOT( addToSelection(QListViewItem*) ) ); | 131 | this, SLOT( addToSelection(QListViewItem*) ) ); |
129 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), | 132 | connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), |
130 | this, SLOT( loadList(const DocLnk&) ) ); | 133 | this, SLOT( loadList(const DocLnk&) ) ); |
131 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 134 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
132 | this, SLOT( tabChanged(QWidget*) ) ); | 135 | this, SLOT( tabChanged(QWidget*) ) ); |
133 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), | 136 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), |
134 | d->tbPlay, SLOT( setOn(bool) ) ); | 137 | d->tbPlay, SLOT( setOn(bool) ) ); |
135 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), | 138 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), |
136 | d->tbLoop, SLOT( setOn(bool) ) ); | 139 | d->tbLoop, SLOT( setOn(bool) ) ); |
137 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), | 140 | connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), |
138 | d->tbShuffle, SLOT( setOn(bool) ) ); | 141 | d->tbShuffle, SLOT( setOn(bool) ) ); |
139 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), | 142 | connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), |
140 | this, SLOT( playIt(QListViewItem*) ) ); | 143 | this, SLOT( playIt(QListViewItem*) ) ); |
141 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), | 144 | connect ( gammaSlider, SIGNAL( valueChanged(int) ), |
142 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); | 145 | mediaPlayerState, SLOT( setVideoGamma(int) ) ); |
143 | 146 | ||
144 | connect( this, SIGNAL(skinSelected() ), | 147 | connect( this, SIGNAL(skinSelected() ), |
145 | m_mp, SLOT( reloadSkins() ) ); | 148 | m_mp, SLOT( reloadSkins() ) ); |
146 | 149 | ||
147 | // see which skins are installed | 150 | // see which skins are installed |
148 | populateSkinsMenu(); | 151 | populateSkinsMenu(); |
149 | initializeStates(); | 152 | initializeStates(); |
150 | 153 | ||
151 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); | 154 | channel = new QCopChannel( "QPE/Application/opieplayer2", this ); |
152 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 155 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
153 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 156 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
154 | 157 | ||
155 | 158 | ||
156 | cfg.setGroup("PlayList"); | 159 | cfg.setGroup("PlayList"); |
157 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
158 | loadList(DocLnk( currentPlaylist ) ); | 161 | loadList(DocLnk( currentPlaylist ) ); |
159 | 162 | ||
160 | tabWidget->showPage( playListTab ); | 163 | tabWidget->showPage( playListTab ); |
161 | } | 164 | } |
162 | 165 | ||
163 | 166 | ||
164 | PlayListWidget::~PlayListWidget() { | 167 | PlayListWidget::~PlayListWidget() { |
165 | delete d; | 168 | delete d; |
166 | delete m_mp; | 169 | delete m_mp; |
167 | } | 170 | } |
168 | 171 | ||
169 | 172 | ||
170 | void PlayListWidget::initializeStates() { | 173 | void PlayListWidget::initializeStates() { |
171 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 174 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
172 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 175 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
173 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 176 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
174 | d->playListFrame->show(); | 177 | d->playListFrame->show(); |
175 | } | 178 | } |
176 | 179 | ||
177 | void PlayListWidget::writeDefaultPlaylist() { | 180 | void PlayListWidget::writeDefaultPlaylist() { |
178 | 181 | ||
179 | Config config( "OpiePlayer" ); | 182 | Config config( "OpiePlayer" ); |
180 | config.setGroup( "PlayList" ); | 183 | config.setGroup( "PlayList" ); |
181 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
182 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
183 | if( currentString == filename) { | 186 | if( currentString == filename) { |
184 | Om3u *m3uList; | 187 | Om3u *m3uList; |
185 | // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; | 188 | // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; |
186 | if( d->selectedFiles->first() ) { | 189 | if( d->selectedFiles->first() ) { |
187 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
188 | do { | 191 | do { |
189 | // odebug << d->selectedFiles->current()->file() << oendl; | 192 | // odebug << d->selectedFiles->current()->file() << oendl; |
190 | m3uList->add( d->selectedFiles->current()->file() ); | 193 | m3uList->add( d->selectedFiles->current()->file() ); |
191 | } | 194 | } |
192 | while ( d->selectedFiles->next() ); | 195 | while ( d->selectedFiles->next() ); |
193 | 196 | ||
194 | m3uList->write(); | 197 | m3uList->write(); |
195 | m3uList->close(); | 198 | m3uList->close(); |
196 | delete m3uList; | 199 | delete m3uList; |
197 | 200 | ||
198 | } | 201 | } |
199 | } | 202 | } |
200 | } | 203 | } |
201 | 204 | ||
202 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 205 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
203 | d->setDocumentUsed = FALSE; | 206 | d->setDocumentUsed = FALSE; |
204 | if( QFileInfo( lnk.file() ).exists() || | 207 | if( QFileInfo( lnk.file() ).exists() || |
205 | lnk.file().left(4) == "http" ) { | 208 | lnk.file().left(4) == "http" ) { |
206 | d->selectedFiles->addToSelection( lnk ); | 209 | d->selectedFiles->addToSelection( lnk ); |
207 | } | 210 | } |
208 | // writeCurrentM3u(); | 211 | // writeCurrentM3u(); |
209 | } | 212 | } |
210 | 213 | ||
211 | 214 | ||
212 | void PlayListWidget::clearList() { | 215 | void PlayListWidget::clearList() { |
213 | while ( first() ) { | 216 | while ( first() ) { |
214 | d->selectedFiles->removeSelected(); | 217 | d->selectedFiles->removeSelected(); |
215 | } | 218 | } |
216 | Config cfg( "OpiePlayer" ); | 219 | Config cfg( "OpiePlayer" ); |
217 | cfg.setGroup("PlayList"); | 220 | cfg.setGroup("PlayList"); |
218 | cfg.writeEntry("CurrentPlaylist","default"); | 221 | cfg.writeEntry("CurrentPlaylist","default"); |
219 | setCaption("OpiePlayer"); | 222 | setCaption("OpiePlayer"); |
220 | } | 223 | } |
221 | 224 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 226 | switch (mouse) { |
224 | case LeftButton: | 227 | case LeftButton: |
225 | break; | 228 | break; |
226 | case RightButton: | 229 | case RightButton: |
227 | { | 230 | { |
228 | QPopupMenu m; | 231 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 234 | m.exec( QCursor::pos() ); |
232 | } | 235 | } |
233 | break; | 236 | break; |
234 | } | 237 | } |
235 | } | 238 | } |
236 | 239 | ||
237 | 240 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 242 | switch (mouse) { |
240 | case LeftButton: | 243 | case LeftButton: |
241 | break; | 244 | break; |
242 | case RightButton: | 245 | case RightButton: |
243 | { | 246 | { |
244 | QPopupMenu m; | 247 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 250 | m.exec( QCursor::pos() ); |
248 | } | 251 | } |
249 | break; | 252 | break; |
250 | } | 253 | } |
251 | } | 254 | } |
252 | 255 | ||
253 | 256 | ||
254 | void PlayListWidget::addAllToList() { | 257 | void PlayListWidget::addAllToList() { |
255 | 258 | ||
256 | 259 | ||
257 | audioView->populateView(); | 260 | audioView->populateView(); |
258 | 261 | ||
259 | QListViewItemIterator audioIt( audioView ); | 262 | QListViewItemIterator audioIt( audioView ); |
260 | DocLnk lnk; | 263 | DocLnk lnk; |
261 | QString filename; | 264 | QString filename; |
262 | // iterate through all items of the listview | 265 | // iterate through all items of the listview |
263 | for ( ; audioIt.current(); ++audioIt ) { | 266 | for ( ; audioIt.current(); ++audioIt ) { |
264 | filename = audioIt.current()->text(3); | 267 | filename = audioIt.current()->text(3); |
265 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 268 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
266 | lnk.setFile( filename ); //sets file name | 269 | lnk.setFile( filename ); //sets file name |
267 | d->selectedFiles->addToSelection( lnk); | 270 | d->selectedFiles->addToSelection( lnk); |
268 | } | 271 | } |
269 | 272 | ||
270 | videoView->populateView(); | 273 | videoView->populateView(); |
271 | 274 | ||
272 | QListViewItemIterator videoIt( videoView ); | 275 | QListViewItemIterator videoIt( videoView ); |
273 | for ( ; videoIt.current(); ++videoIt ) { | 276 | for ( ; videoIt.current(); ++videoIt ) { |
274 | filename = videoIt.current()->text(3); | 277 | filename = videoIt.current()->text(3); |
275 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 278 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
276 | lnk.setFile( filename ); //sets file name | 279 | lnk.setFile( filename ); //sets file name |
277 | d->selectedFiles->addToSelection( lnk); | 280 | d->selectedFiles->addToSelection( lnk); |
278 | } | 281 | } |
279 | 282 | ||
280 | tabWidget->setCurrentPage(0); | 283 | tabWidget->setCurrentPage(0); |
281 | 284 | ||
282 | writeCurrentM3u(); | 285 | writeCurrentM3u(); |
283 | d->selectedFiles->first(); | 286 | d->selectedFiles->first(); |
284 | } | 287 | } |
285 | 288 | ||
286 | 289 | ||
287 | void PlayListWidget::addAllMusicToList() { | 290 | void PlayListWidget::addAllMusicToList() { |
288 | 291 | ||
289 | audioView->populateView(); | 292 | audioView->populateView(); |
290 | 293 | ||
291 | QListViewItemIterator audioIt( audioView ); | 294 | QListViewItemIterator audioIt( audioView ); |
292 | DocLnk lnk; | 295 | DocLnk lnk; |
293 | QString filename; | 296 | QString filename; |
294 | // iterate through all items of the listview | 297 | // iterate through all items of the listview |
295 | for ( ; audioIt.current(); ++audioIt ) { | 298 | for ( ; audioIt.current(); ++audioIt ) { |
296 | filename = audioIt.current()->text(3); | 299 | filename = audioIt.current()->text(3); |
297 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 300 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
298 | lnk.setFile( filename ); //sets file name | 301 | lnk.setFile( filename ); //sets file name |
299 | d->selectedFiles->addToSelection( lnk); | 302 | d->selectedFiles->addToSelection( lnk); |
300 | } | 303 | } |
301 | 304 | ||
302 | tabWidget->setCurrentPage(0); | 305 | tabWidget->setCurrentPage(0); |
303 | writeCurrentM3u(); | 306 | writeCurrentM3u(); |
304 | d->selectedFiles->first(); | 307 | d->selectedFiles->first(); |
305 | } | 308 | } |
306 | 309 | ||
307 | 310 | ||
308 | void PlayListWidget::addAllVideoToList() { | 311 | void PlayListWidget::addAllVideoToList() { |
309 | 312 | ||
310 | videoView->populateView(); | 313 | videoView->populateView(); |
311 | 314 | ||
312 | QListViewItemIterator videoIt( videoView ); | 315 | QListViewItemIterator videoIt( videoView ); |
313 | DocLnk lnk; | 316 | DocLnk lnk; |
314 | QString filename; | 317 | QString filename; |
315 | for ( ; videoIt.current(); ++videoIt ) { | 318 | for ( ; videoIt.current(); ++videoIt ) { |
316 | filename = videoIt.current()->text(3); | 319 | filename = videoIt.current()->text(3); |
317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 320 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
318 | lnk.setFile( filename ); //sets file name | 321 | lnk.setFile( filename ); //sets file name |
319 | d->selectedFiles->addToSelection( lnk); | 322 | d->selectedFiles->addToSelection( lnk); |
320 | } | 323 | } |
321 | tabWidget->setCurrentPage(0); | 324 | tabWidget->setCurrentPage(0); |
322 | writeCurrentM3u(); | 325 | writeCurrentM3u(); |
323 | d->selectedFiles->first(); | 326 | d->selectedFiles->first(); |
324 | } | 327 | } |
325 | 328 | ||
326 | 329 | ||
327 | void PlayListWidget::setDocument( const QString& fileref ) { | 330 | void PlayListWidget::setDocument( const QString& fileref ) { |
328 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; | 331 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; |
329 | fromSetDocument = TRUE; | 332 | fromSetDocument = TRUE; |
330 | QFileInfo fileInfo(fileref); | 333 | QFileInfo fileInfo(fileref); |
331 | 334 | ||
332 | if ( !fileInfo.exists() ) { | 335 | if ( !fileInfo.exists() ) { |
333 | QMessageBox::warning( this, tr( "Invalid File" ), | 336 | QMessageBox::warning( this, tr( "Invalid File" ), |
334 | tr( "There was a problem in getting the file." ) ); | 337 | tr( "There was a problem in getting the file." ) ); |
335 | return; | 338 | return; |
336 | } | 339 | } |
337 | 340 | ||
338 | clearList(); | 341 | clearList(); |
339 | QString extension = fileInfo.extension(false); | 342 | QString extension = fileInfo.extension(false); |
340 | 343 | ||
341 | if( extension.find( "m3u", 0, false) != -1 | 344 | if( extension.find( "m3u", 0, false) != -1 |
342 | || extension.find( "pls", 0, false) != -1 ) { | 345 | || extension.find( "pls", 0, false) != -1 ) { |
343 | readListFromFile( fileref ); | 346 | readListFromFile( fileref ); |
344 | } else { | 347 | } else { |
345 | clearList(); | 348 | clearList(); |
346 | DocLnk lnk; | 349 | DocLnk lnk; |
347 | lnk.setName( fileInfo.baseName() ); //sets name | 350 | lnk.setName( fileInfo.baseName() ); //sets name |
348 | lnk.setFile( fileref ); //sets file name | 351 | lnk.setFile( fileref ); //sets file name |
349 | addToSelection( lnk ); | 352 | addToSelection( lnk ); |
350 | writeCurrentM3u(); | 353 | writeCurrentM3u(); |
351 | 354 | ||
352 | d->setDocumentUsed = TRUE; | 355 | d->setDocumentUsed = TRUE; |
353 | mediaPlayerState->setPlaying( FALSE ); | 356 | mediaPlayerState->setPlaying( FALSE ); |
354 | mediaPlayerState->setPlaying( TRUE ); | 357 | mediaPlayerState->setPlaying( TRUE ); |
355 | } | 358 | } |
356 | } | 359 | } |
357 | 360 | ||
358 | 361 | ||
359 | void PlayListWidget::useSelectedDocument() { | 362 | void PlayListWidget::useSelectedDocument() { |
360 | d->setDocumentUsed = FALSE; | 363 | d->setDocumentUsed = FALSE; |
361 | } | 364 | } |
362 | 365 | ||
363 | 366 | ||
364 | const DocLnk *PlayListWidget::current() const { // this is fugly | 367 | const DocLnk *PlayListWidget::current() const { // this is fugly |
365 | assert( currentTab() == CurrentPlayList ); | 368 | assert( currentTab() == CurrentPlayList ); |
366 | 369 | ||
367 | const DocLnk *lnk = d->selectedFiles->current(); | 370 | const DocLnk *lnk = d->selectedFiles->current(); |
368 | if ( !lnk ) { | 371 | if ( !lnk ) { |
369 | d->selectedFiles->first(); | 372 | d->selectedFiles->first(); |
370 | lnk = d->selectedFiles->current(); | 373 | lnk = d->selectedFiles->current(); |
371 | } | 374 | } |
372 | assert( lnk ); | 375 | assert( lnk ); |
373 | return lnk; | 376 | return lnk; |
374 | } | 377 | } |
375 | 378 | ||
376 | 379 | ||
377 | bool PlayListWidget::prev() { | 380 | bool PlayListWidget::prev() { |
378 | if ( mediaPlayerState->isShuffled() ) { | 381 | if ( mediaPlayerState->isShuffled() ) { |
379 | const DocLnk *cur = current(); | 382 | const DocLnk *cur = current(); |
380 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 383 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
381 | for ( int i = 0; i < j; i++ ) { | 384 | for ( int i = 0; i < j; i++ ) { |
382 | if ( !d->selectedFiles->next() ) | 385 | if ( !d->selectedFiles->next() ) |
383 | d->selectedFiles->first(); | 386 | d->selectedFiles->first(); |
384 | } | 387 | } |
385 | if ( cur == current() ) | 388 | if ( cur == current() ) |
386 | if ( !d->selectedFiles->next() ) { | 389 | if ( !d->selectedFiles->next() ) { |
387 | d->selectedFiles->first(); | 390 | d->selectedFiles->first(); |
388 | } | 391 | } |
389 | return TRUE; | 392 | return TRUE; |
390 | } else { | 393 | } else { |
391 | if ( !d->selectedFiles->prev() ) { | 394 | if ( !d->selectedFiles->prev() ) { |
392 | if ( mediaPlayerState->isLooping() ) { | 395 | if ( mediaPlayerState->isLooping() ) { |
393 | return d->selectedFiles->last(); | 396 | return d->selectedFiles->last(); |
394 | } else { | 397 | } else { |
395 | return FALSE; | 398 | return FALSE; |
396 | } | 399 | } |
397 | } | 400 | } |
398 | return TRUE; | 401 | return TRUE; |
399 | } | 402 | } |
400 | } | 403 | } |
401 | 404 | ||
402 | 405 | ||
403 | bool PlayListWidget::next() { | 406 | bool PlayListWidget::next() { |
404 | //odebug << "<<<<<<<<<<<<next()" << oendl; | 407 | //odebug << "<<<<<<<<<<<<next()" << oendl; |
405 | if ( mediaPlayerState->isShuffled() ) { | 408 | if ( mediaPlayerState->isShuffled() ) { |
406 | return prev(); | 409 | return prev(); |
407 | } else { | 410 | } else { |
408 | if ( !d->selectedFiles->next() ) { | 411 | if ( !d->selectedFiles->next() ) { |
409 | if ( mediaPlayerState->isLooping() ) { | 412 | if ( mediaPlayerState->isLooping() ) { |
410 | return d->selectedFiles->first(); | 413 | return d->selectedFiles->first(); |
411 | } else { | 414 | } else { |
412 | return FALSE; | 415 | return FALSE; |
413 | } | 416 | } |
414 | } | 417 | } |
415 | return TRUE; | 418 | return TRUE; |
416 | } | 419 | } |
417 | } | 420 | } |
418 | 421 | ||
419 | 422 | ||
420 | bool PlayListWidget::first() { | 423 | bool PlayListWidget::first() { |
421 | return d->selectedFiles->first(); | 424 | return d->selectedFiles->first(); |
422 | } | 425 | } |
423 | 426 | ||
424 | 427 | ||
425 | bool PlayListWidget::last() { | 428 | bool PlayListWidget::last() { |
426 | return d->selectedFiles->last(); | 429 | return d->selectedFiles->last(); |
427 | } | 430 | } |
428 | 431 | ||
429 | 432 | ||
430 | void PlayListWidget::saveList() { | 433 | void PlayListWidget::saveList() { |
431 | writem3u(); | 434 | writem3u(); |
432 | } | 435 | } |
433 | 436 | ||
434 | 437 | ||
435 | void PlayListWidget::loadList( const DocLnk & lnk) { | 438 | void PlayListWidget::loadList( const DocLnk & lnk) { |
436 | QString name = lnk.name(); | 439 | QString name = lnk.name(); |
437 | 440 | ||
438 | if( name.length()>0) { | 441 | if( name.length()>0) { |
439 | setCaption("OpiePlayer: "+name); | 442 | setCaption("OpiePlayer: "+name); |
440 | clearList(); | 443 | clearList(); |
441 | readListFromFile(lnk.file()); | 444 | readListFromFile(lnk.file()); |
442 | tabWidget->setCurrentPage(0); | 445 | tabWidget->setCurrentPage(0); |
443 | } | 446 | } |
444 | } | 447 | } |
445 | 448 | ||
446 | void PlayListWidget::addSelected() { | 449 | void PlayListWidget::addSelected() { |
447 | assert( inFileListMode() ); | 450 | assert( inFileListMode() ); |
448 | 451 | ||
449 | QListViewItemIterator it( currentFileListView ); | 452 | QListViewItemIterator it( currentFileListView ); |
450 | for ( ; it.current(); ++it ) | 453 | for ( ; it.current(); ++it ) |
451 | if ( it.current()->isSelected() ) { | 454 | if ( it.current()->isSelected() ) { |
452 | QString filename = it.current()->text(3); | 455 | QString filename = it.current()->text(3); |
453 | 456 | ||
454 | DocLnk lnk; | 457 | DocLnk lnk; |
455 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 458 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
456 | lnk.setFile( filename ); //sets file name | 459 | lnk.setFile( filename ); //sets file name |
457 | 460 | ||
458 | d->selectedFiles->addToSelection( lnk ); | 461 | d->selectedFiles->addToSelection( lnk ); |
459 | } | 462 | } |
460 | 463 | ||
461 | currentFileListView->clearSelection(); | 464 | currentFileListView->clearSelection(); |
462 | 465 | ||
463 | writeCurrentM3u(); | 466 | writeCurrentM3u(); |
464 | } | 467 | } |
465 | 468 | ||
466 | 469 | ||
467 | void PlayListWidget::removeSelected() { | 470 | void PlayListWidget::removeSelected() { |
468 | d->selectedFiles->removeSelected( ); | 471 | d->selectedFiles->removeSelected( ); |
469 | writeCurrentM3u(); | 472 | writeCurrentM3u(); |
470 | } | 473 | } |
471 | 474 | ||
472 | 475 | ||
473 | void PlayListWidget::playIt( QListViewItem *it) { | 476 | void PlayListWidget::playIt( QListViewItem *it) { |
474 | if(!it) return; | 477 | if(!it) return; |
475 | mediaPlayerState->setPlaying(FALSE); | 478 | mediaPlayerState->setPlaying(FALSE); |
476 | mediaPlayerState->setPlaying(TRUE); | 479 | mediaPlayerState->setPlaying(TRUE); |
477 | d->selectedFiles->unSelect(); | 480 | d->selectedFiles->unSelect(); |
478 | } | 481 | } |
479 | 482 | ||
480 | 483 | ||
481 | void PlayListWidget::addToSelection( QListViewItem *it) { | 484 | void PlayListWidget::addToSelection( QListViewItem *it) { |
482 | d->setDocumentUsed = FALSE; | 485 | d->setDocumentUsed = FALSE; |
483 | 486 | ||
484 | if(it) { | 487 | if(it) { |
485 | if ( currentTab() == CurrentPlayList ) | 488 | if ( currentTab() == CurrentPlayList ) |
486 | return; | 489 | return; |
487 | DocLnk lnk; | 490 | DocLnk lnk; |
488 | QString filename; | 491 | QString filename; |
489 | 492 | ||
490 | filename=it->text(3); | 493 | filename=it->text(3); |
491 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 494 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
492 | lnk.setFile( filename ); //sets file name | 495 | lnk.setFile( filename ); //sets file name |
493 | d->selectedFiles->addToSelection( lnk); | 496 | d->selectedFiles->addToSelection( lnk); |
494 | 497 | ||
495 | writeCurrentM3u(); | 498 | writeCurrentM3u(); |
496 | // tabWidget->setCurrentPage(0); | 499 | // tabWidget->setCurrentPage(0); |
497 | 500 | ||
498 | } | 501 | } |
499 | } | 502 | } |
500 | 503 | ||
501 | 504 | ||
502 | void PlayListWidget::tabChanged(QWidget *) { | 505 | void PlayListWidget::tabChanged(QWidget *) { |
503 | 506 | ||
504 | d->tbPlay->setEnabled( true ); | 507 | d->tbPlay->setEnabled( true ); |
505 | 508 | ||
506 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), | 509 | disconnect( audioView, SIGNAL( itemsSelected(bool) ), |
507 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 510 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
508 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), | 511 | disconnect( videoView, SIGNAL( itemsSelected(bool) ), |
509 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 512 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
510 | 513 | ||
511 | currentFileListView = 0; | 514 | currentFileListView = 0; |
512 | 515 | ||
513 | switch ( currentTab() ) { | 516 | switch ( currentTab() ) { |
514 | case CurrentPlayList: | 517 | case CurrentPlayList: |
515 | { | 518 | { |
516 | if( !tbDeletePlaylist->isHidden() ) { | 519 | if( !tbDeletePlaylist->isHidden() ) { |
517 | tbDeletePlaylist->hide(); | 520 | tbDeletePlaylist->hide(); |
518 | } | 521 | } |
519 | d->tbRemoveFromList->setEnabled(TRUE); | 522 | d->tbRemoveFromList->setEnabled(TRUE); |
520 | d->tbAddToList->setEnabled(FALSE); | 523 | d->tbAddToList->setEnabled(FALSE); |
521 | 524 | ||
522 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 525 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
523 | } | 526 | } |
524 | break; | 527 | break; |
525 | case AudioFiles: | 528 | case AudioFiles: |
526 | { | 529 | { |
527 | audioView->populateView(); | 530 | audioView->populateView(); |
528 | 531 | ||
529 | if( !tbDeletePlaylist->isHidden() ) { | 532 | if( !tbDeletePlaylist->isHidden() ) { |
530 | tbDeletePlaylist->hide(); | 533 | tbDeletePlaylist->hide(); |
531 | } | 534 | } |
532 | d->tbRemoveFromList->setEnabled(FALSE); | 535 | d->tbRemoveFromList->setEnabled(FALSE); |
533 | d->tbAddToList->setEnabled(TRUE); | 536 | d->tbAddToList->setEnabled(TRUE); |
534 | 537 | ||
535 | connect( audioView, SIGNAL( itemsSelected(bool) ), | 538 | connect( audioView, SIGNAL( itemsSelected(bool) ), |
536 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 539 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
537 | 540 | ||
538 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 541 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
539 | 542 | ||
540 | currentFileListView = audioView; | 543 | currentFileListView = audioView; |
541 | } | 544 | } |
542 | break; | 545 | break; |
543 | case VideoFiles: | 546 | case VideoFiles: |
544 | { | 547 | { |
545 | videoView->populateView(); | 548 | videoView->populateView(); |
546 | if( !tbDeletePlaylist->isHidden() ) { | 549 | if( !tbDeletePlaylist->isHidden() ) { |
547 | tbDeletePlaylist->hide(); | 550 | tbDeletePlaylist->hide(); |
548 | } | 551 | } |
549 | d->tbRemoveFromList->setEnabled(FALSE); | 552 | d->tbRemoveFromList->setEnabled(FALSE); |
550 | d->tbAddToList->setEnabled(TRUE); | 553 | d->tbAddToList->setEnabled(TRUE); |
551 | 554 | ||
552 | connect( videoView, SIGNAL( itemsSelected(bool) ), | 555 | connect( videoView, SIGNAL( itemsSelected(bool) ), |
553 | d->tbPlay, SLOT( setEnabled(bool) ) ); | 556 | d->tbPlay, SLOT( setEnabled(bool) ) ); |
554 | 557 | ||
555 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 558 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
556 | 559 | ||
557 | currentFileListView = videoView; | 560 | currentFileListView = videoView; |
558 | } | 561 | } |
559 | break; | 562 | break; |
560 | case PlayLists: | 563 | case PlayLists: |
561 | { | 564 | { |
562 | if( tbDeletePlaylist->isHidden() ) { | 565 | if( tbDeletePlaylist->isHidden() ) { |
563 | tbDeletePlaylist->show(); | 566 | tbDeletePlaylist->show(); |
564 | } | 567 | } |
565 | playLists->reread(); | 568 | playLists->reread(); |
566 | d->tbAddToList->setEnabled(FALSE); | 569 | d->tbAddToList->setEnabled(FALSE); |
567 | 570 | ||
568 | d->tbPlay->setEnabled( false ); | 571 | d->tbPlay->setEnabled( false ); |
569 | } | 572 | } |
570 | break; | 573 | break; |
571 | }; | 574 | }; |
572 | } | 575 | } |
573 | 576 | ||
574 | 577 | ||
575 | void PlayListWidget::btnPlay(bool b) { | 578 | void PlayListWidget::btnPlay(bool b) { |
576 | // mediaPlayerState->setPlaying(false); | 579 | // mediaPlayerState->setPlaying(false); |
577 | mediaPlayerState->setPlaying(b); | 580 | mediaPlayerState->setPlaying(b); |
578 | insanityBool=FALSE; | 581 | insanityBool=FALSE; |
579 | } | 582 | } |
580 | 583 | ||
581 | void PlayListWidget::deletePlaylist() { | 584 | void PlayListWidget::deletePlaylist() { |
582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 585 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
583 | (tr("You really want to delete\nthis playlist?")), | 586 | (tr("You really want to delete\nthis playlist?")), |
584 | (tr("Yes")), (tr("No")), 0 )){ | 587 | (tr("Yes")), (tr("No")), 0 )){ |
585 | case 0: // Yes clicked, | 588 | case 0: // Yes clicked, |
586 | QFile().remove(playLists->selectedDocument().file()); | 589 | QFile().remove(playLists->selectedDocument().file()); |
587 | QFile().remove(playLists->selectedDocument().linkFile()); | 590 | QFile().remove(playLists->selectedDocument().linkFile()); |
588 | playLists->reread(); | 591 | playLists->reread(); |
589 | break; | 592 | break; |
590 | case 1: // Cancel | 593 | case 1: // Cancel |
591 | break; | 594 | break; |
592 | }; | 595 | }; |
593 | } | 596 | } |
594 | 597 | ||
595 | 598 | ||
596 | void PlayListWidget::playSelected() { | 599 | void PlayListWidget::playSelected() { |
597 | btnPlay( TRUE); | 600 | btnPlay( TRUE); |
598 | } | 601 | } |
599 | 602 | ||
600 | bool PlayListWidget::inFileListMode() const | 603 | bool PlayListWidget::inFileListMode() const |
601 | { | 604 | { |
602 | TabType tab = currentTab(); | 605 | TabType tab = currentTab(); |
603 | return tab == AudioFiles || tab == VideoFiles; | 606 | return tab == AudioFiles || tab == VideoFiles; |
604 | } | 607 | } |
605 | 608 | ||
606 | void PlayListWidget::openURL() { | 609 | void PlayListWidget::openURL() { |
607 | // http://66.28.164.33:2080 | 610 | // http://66.28.164.33:2080 |
608 | // http://somafm.com/star0242.m3u | 611 | // http://somafm.com/star0242.m3u |
609 | QString filename, name; | 612 | QString filename, name; |
610 | InputDialog *fileDlg; | 613 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 614 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
612 | fileDlg->exec(); | 615 | fileDlg->exec(); |
613 | if( fileDlg->result() == 1 ) { | 616 | if( fileDlg->result() == 1 ) { |
614 | filename = fileDlg->text(); | 617 | filename = fileDlg->text(); |
615 | odebug << "Selected filename is " + filename << oendl; | 618 | odebug << "Selected filename is " + filename << oendl; |
616 | // Om3u *m3uList; | 619 | // Om3u *m3uList; |
617 | DocLnk lnk; | 620 | DocLnk lnk; |
618 | Config cfg( "OpiePlayer" ); | 621 | Config cfg( "OpiePlayer" ); |
619 | cfg.setGroup("PlayList"); | 622 | cfg.setGroup("PlayList"); |
620 | 623 | ||
621 | if(filename.left(4) == "http") { | 624 | if(filename.left(4) == "http") { |
622 | QString m3uFile, m3uFilePath; | 625 | QString m3uFile, m3uFilePath; |
623 | if(filename.find(":",8,TRUE) != -1) { //found a port | 626 | if(filename.find(":",8,TRUE) != -1) { //found a port |
624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 627 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
625 | m3uFile = m3uFile.right( 7); | 628 | m3uFile = m3uFile.right( 7); |
626 | } else if(filename.left(4) == "http"){ | 629 | } else if(filename.left(4) == "http"){ |
627 | m3uFile=filename; | 630 | m3uFile=filename; |
628 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 631 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
629 | } else{ | 632 | } else{ |
630 | m3uFile=filename; | 633 | m3uFile=filename; |
631 | } | 634 | } |
632 | 635 | ||
633 | lnk.setName( filename ); //sets name | 636 | lnk.setName( filename ); //sets name |
634 | lnk.setFile( filename ); //sets file name | 637 | lnk.setFile( filename ); //sets file name |
635 | 638 | ||
636 | // lnk.setIcon("opieplayer2/musicfile"); | 639 | // lnk.setIcon("opieplayer2/musicfile"); |
637 | 640 | ||
638 | d->selectedFiles->addToSelection( lnk ); | 641 | d->selectedFiles->addToSelection( lnk ); |
639 | writeCurrentM3u(); | 642 | writeCurrentM3u(); |
640 | d->selectedFiles->setSelectedItem( lnk.name()); | 643 | d->selectedFiles->setSelectedItem( lnk.name()); |
641 | } | 644 | } |
642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 645 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
643 | readListFromFile( filename ); | 646 | readListFromFile( filename ); |
644 | } else { | 647 | } else { |
645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 648 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
646 | lnk.setFile( filename ); //sets file name | 649 | lnk.setFile( filename ); //sets file name |
647 | d->selectedFiles->addToSelection( lnk); | 650 | d->selectedFiles->addToSelection( lnk); |
648 | writeCurrentM3u(); | 651 | writeCurrentM3u(); |
649 | d->selectedFiles->setSelectedItem( lnk.name()); | 652 | d->selectedFiles->setSelectedItem( lnk.name()); |
650 | } | 653 | } |
651 | } | 654 | } |
652 | 655 | ||
653 | 656 | ||
654 | delete fileDlg; | 657 | delete fileDlg; |
655 | } | 658 | } |
656 | 659 | ||
657 | 660 | ||
658 | void PlayListWidget::openFile() { | 661 | void PlayListWidget::openFile() { |
659 | 662 | ||
660 | QString filename, name; | 663 | QString filename, name; |
661 | 664 | ||
662 | Config cfg( "OpiePlayer" ); | 665 | Config cfg( "OpiePlayer" ); |
663 | cfg.setGroup("Dialog"); | 666 | cfg.setGroup("Dialog"); |
664 | MimeTypes types; | 667 | MimeTypes types; |
665 | QStringList audio, video, all; | 668 | QStringList audio, video, all; |
666 | audio << "audio/*"; | 669 | audio << "audio/*"; |
667 | audio << "playlist/plain"; | 670 | audio << "playlist/plain"; |
668 | audio << "audio/x-ogg"; | 671 | audio << "audio/x-ogg"; |
669 | audio << "audio/x-mpegurl"; | 672 | audio << "audio/x-mpegurl"; |
670 | 673 | ||
671 | video << "video/*"; | 674 | video << "video/*"; |
672 | video << "playlist/plain"; | 675 | video << "playlist/plain"; |
673 | 676 | ||
674 | all += audio; | 677 | all += audio; |
675 | all += video; | 678 | all += video; |
676 | types.insert("All Media Files", all ); | 679 | types.insert("All Media Files", all ); |
677 | types.insert("Audio", audio ); | 680 | types.insert("Audio", audio ); |
678 | types.insert("Video", video ); | 681 | types.insert("Video", video ); |
679 | 682 | ||
680 | QString str = OFileDialog::getOpenFileName( 1, | 683 | QString str = OFileDialog::getOpenFileName( 1, |
681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 684 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
682 | types, 0 ); | 685 | types, 0 ); |
683 | 686 | ||
684 | if(str.left(2) == "//") { | 687 | if(str.left(2) == "//") { |
685 | str=str.right(str.length()-1); | 688 | str=str.right(str.length()-1); |
686 | } | 689 | } |
687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 690 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
688 | 691 | ||
689 | if( !str.isEmpty() ) { | 692 | if( !str.isEmpty() ) { |
690 | 693 | ||
691 | odebug << "Selected filename is " + str << oendl; | 694 | odebug << "Selected filename is " + str << oendl; |
692 | filename = str; | 695 | filename = str; |
693 | DocLnk lnk; | 696 | DocLnk lnk; |
694 | 697 | ||
695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 698 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
696 | readListFromFile( filename ); | 699 | readListFromFile( filename ); |
697 | } else { | 700 | } else { |
698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 701 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
699 | lnk.setFile( filename ); //sets file name | 702 | lnk.setFile( filename ); //sets file name |
700 | d->selectedFiles->addToSelection( lnk ); | 703 | d->selectedFiles->addToSelection( lnk ); |
701 | writeCurrentM3u(); | 704 | writeCurrentM3u(); |
702 | d->selectedFiles->setSelectedItem( lnk.name() ); | 705 | d->selectedFiles->setSelectedItem( lnk.name() ); |
703 | } | 706 | } |
704 | } | 707 | } |
705 | } | 708 | } |
706 | 709 | ||
707 | 710 | ||
708 | void PlayListWidget::readListFromFile( const QString &filename ) { | 711 | void PlayListWidget::readListFromFile( const QString &filename ) { |
709 | odebug << "read list filename " + filename << oendl; | 712 | odebug << "read list filename " + filename << oendl; |
710 | QFileInfo fi(filename); | 713 | QFileInfo fi(filename); |
711 | Om3u *m3uList; | 714 | Om3u *m3uList; |
712 | QString s, name; | 715 | QString s, name; |
713 | m3uList = new Om3u( filename, IO_ReadOnly ); | 716 | m3uList = new Om3u( filename, IO_ReadOnly ); |
714 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 717 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
715 | m3uList->readM3u(); | 718 | m3uList->readM3u(); |
716 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 719 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
717 | m3uList->readPls(); | 720 | m3uList->readPls(); |
718 | 721 | ||
719 | DocLnk lnk; | 722 | DocLnk lnk; |
720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 723 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
721 | s = *it; | 724 | s = *it; |
722 | // odebug << s << oendl; | 725 | // odebug << s << oendl; |
723 | if(s.left(4)=="http") { | 726 | if(s.left(4)=="http") { |
724 | lnk.setName( s ); //sets file name | 727 | lnk.setName( s ); //sets file name |
725 | lnk.setIcon("opieplayer2/musicfile"); | 728 | lnk.setIcon("opieplayer2/musicfile"); |
726 | lnk.setFile( s ); //sets file name | 729 | lnk.setFile( s ); //sets file name |
727 | 730 | ||
728 | } else { //is file | 731 | } else { //is file |
729 | lnk.setName( QFileInfo(s).baseName()); | 732 | lnk.setName( QFileInfo(s).baseName()); |
730 | if(s.left(1) != "/") { | 733 | if(s.left(1) != "/") { |
731 | 734 | ||
732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 735 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
733 | } else { | 736 | } else { |
734 | lnk.setFile( s); | 737 | lnk.setFile( s); |
735 | } | 738 | } |
736 | } | 739 | } |
737 | d->selectedFiles->addToSelection( lnk ); | 740 | d->selectedFiles->addToSelection( lnk ); |
738 | } | 741 | } |
739 | Config config( "OpiePlayer" ); | 742 | Config config( "OpiePlayer" ); |
740 | config.setGroup( "PlayList" ); | 743 | config.setGroup( "PlayList" ); |
741 | 744 | ||
742 | config.writeEntry("CurrentPlaylist",filename); | 745 | config.writeEntry("CurrentPlaylist",filename); |
743 | config.write(); | 746 | config.write(); |
744 | currentPlayList=filename; | 747 | currentPlayList=filename; |
745 | 748 | ||
746 | m3uList->close(); | 749 | m3uList->close(); |
747 | delete m3uList; | 750 | delete m3uList; |
748 | 751 | ||
749 | d->selectedFiles->setSelectedItem( s); | 752 | d->selectedFiles->setSelectedItem( s); |
750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 753 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
751 | 754 | ||
752 | } | 755 | } |
753 | 756 | ||
754 | // writes current playlist to current m3u file */ | 757 | // writes current playlist to current m3u file */ |
755 | void PlayListWidget::writeCurrentM3u() { | 758 | void PlayListWidget::writeCurrentM3u() { |
756 | odebug << "writing to current m3u" << oendl; | 759 | odebug << "writing to current m3u" << oendl; |
757 | Config cfg( "OpiePlayer" ); | 760 | Config cfg( "OpiePlayer" ); |
758 | cfg.setGroup("PlayList"); | 761 | cfg.setGroup("PlayList"); |
759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 762 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
760 | 763 | ||
761 | Om3u *m3uList; | 764 | Om3u *m3uList; |
762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 765 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
763 | if( d->selectedFiles->first()) { | 766 | if( d->selectedFiles->first()) { |
764 | 767 | ||
765 | do { | 768 | do { |
766 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 769 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
767 | m3uList->add( d->selectedFiles->current()->file() ); | 770 | m3uList->add( d->selectedFiles->current()->file() ); |
768 | } | 771 | } |
769 | while ( d->selectedFiles->next() ); | 772 | while ( d->selectedFiles->next() ); |
770 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 773 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
771 | m3uList->write(); | 774 | m3uList->write(); |
772 | m3uList->close(); | 775 | m3uList->close(); |
773 | } | 776 | } |
774 | delete m3uList; | 777 | delete m3uList; |
775 | 778 | ||
776 | } | 779 | } |
777 | 780 | ||
778 | /* | 781 | /* |
779 | writes current playlist to m3u file */ | 782 | writes current playlist to m3u file */ |
780 | void PlayListWidget::writem3u() { | 783 | void PlayListWidget::writem3u() { |
781 | //InputDilog *fileDlg; | 784 | //InputDilog *fileDlg; |
782 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 785 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
783 | //fileDlg->exec(); | 786 | //fileDlg->exec(); |
784 | 787 | ||
785 | Config cfg( "OpiePlayer" ); | 788 | Config cfg( "OpiePlayer" ); |
786 | cfg.setGroup("Dialog"); | 789 | cfg.setGroup("Dialog"); |
787 | MimeTypes types; | 790 | MimeTypes types; |
788 | QStringList audio, video, all; | 791 | QStringList audio, video, all; |
789 | audio << "audio/*"; | 792 | audio << "audio/*"; |
790 | audio << "playlist/plain"; | 793 | audio << "playlist/plain"; |
791 | audio << "audio/x-mpegurl"; | 794 | audio << "audio/x-mpegurl"; |
792 | 795 | ||
793 | video << "video/*"; | 796 | video << "video/*"; |
794 | video << "playlist/plain"; | 797 | video << "playlist/plain"; |
795 | 798 | ||
796 | all += audio; | 799 | all += audio; |
797 | all += video; | 800 | all += video; |
798 | types.insert("All Media Files", all ); | 801 | types.insert("All Media Files", all ); |
799 | types.insert("Audio", audio ); | 802 | types.insert("Audio", audio ); |
800 | types.insert("Video", video ); | 803 | types.insert("Video", video ); |
801 | 804 | ||
802 | QString str = OFileDialog::getOpenFileName( 1, | 805 | QString str = OFileDialog::getOpenFileName( 1, |
803 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 806 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
804 | types, 0 ); | 807 | types, 0 ); |
805 | if(str.left(2) == "//") str=str.right(str.length()-1); | 808 | if(str.left(2) == "//") str=str.right(str.length()-1); |
806 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 809 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
807 | 810 | ||
808 | 811 | ||
809 | QString name, filename, list; | 812 | QString name, filename, list; |
810 | Om3u *m3uList; | 813 | Om3u *m3uList; |
811 | 814 | ||
812 | if( !str.isEmpty() ) { | 815 | if( !str.isEmpty() ) { |
813 | name = str; | 816 | name = str; |
814 | // name = fileDlg->text(); | 817 | // name = fileDlg->text(); |
815 | // odebug << filename << oendl; | 818 | // odebug << filename << oendl; |
816 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 819 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
817 | filename = name; | 820 | filename = name; |
818 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 821 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
819 | } | 822 | } |
820 | else //otherwise dump it somewhere noticable | 823 | else //otherwise dump it somewhere noticable |
821 | filename = QPEApplication::documentDir() + "/" + name; | 824 | filename = QPEApplication::documentDir() + "/" + name; |
822 | 825 | ||
823 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 826 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
824 | filename += ".m3u"; | 827 | filename += ".m3u"; |
825 | 828 | ||
826 | if( d->selectedFiles->first()) { //ramble through playlist view | 829 | if( d->selectedFiles->first()) { //ramble through playlist view |
827 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 830 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
828 | 831 | ||
829 | do { | 832 | do { |
830 | m3uList->add( d->selectedFiles->current()->file()); | 833 | m3uList->add( d->selectedFiles->current()->file()); |
831 | } | 834 | } |
832 | while ( d->selectedFiles->next() ); | 835 | while ( d->selectedFiles->next() ); |
833 | // odebug << list << oendl; | 836 | // odebug << list << oendl; |
834 | m3uList->write(); | 837 | m3uList->write(); |
835 | m3uList->close(); | 838 | m3uList->close(); |
836 | delete m3uList; | 839 | delete m3uList; |
837 | 840 | ||
838 | //delete fileDlg; | 841 | //delete fileDlg; |
839 | 842 | ||
840 | DocLnk lnk; | 843 | DocLnk lnk; |
841 | lnk.setFile( filename); | 844 | lnk.setFile( filename); |
842 | lnk.setIcon("opieplayer2/playlist2"); | 845 | lnk.setIcon("opieplayer2/playlist2"); |
843 | lnk.setName( name); //sets file name | 846 | lnk.setName( name); //sets file name |
844 | 847 | ||
845 | // odebug << filename << oendl; | 848 | // odebug << filename << oendl; |
846 | Config config( "OpiePlayer" ); | 849 | Config config( "OpiePlayer" ); |
847 | config.setGroup( "PlayList" ); | 850 | config.setGroup( "PlayList" ); |
848 | 851 | ||
849 | config.writeEntry("CurrentPlaylist",filename); | 852 | config.writeEntry("CurrentPlaylist",filename); |
850 | currentPlayList=filename; | 853 | currentPlayList=filename; |
851 | 854 | ||
852 | if(!lnk.writeLink()) { | 855 | if(!lnk.writeLink()) { |
853 | odebug << "Writing doclink did not work" << oendl; | 856 | odebug << "Writing doclink did not work" << oendl; |
854 | } | 857 | } |
855 | 858 | ||
856 | setCaption(tr("OpiePlayer: ") + name); | 859 | setCaption(tr("OpiePlayer: ") + name); |
857 | } | 860 | } |
858 | } | 861 | } |
859 | } | 862 | } |
860 | 863 | ||
861 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 864 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
862 | switch ( e->key() ) { | 865 | switch ( e->key() ) { |
863 | ////////////////////////////// Zaurus keys | 866 | ////////////////////////////// Zaurus keys |
864 | case Key_F9: //activity | 867 | case Key_F9: //activity |
865 | // if(audioUI->isHidden()) | 868 | // if(audioUI->isHidden()) |
866 | // audioUI->showMaximized(); | 869 | // audioUI->showMaximized(); |
867 | break; | 870 | break; |
868 | case Key_F10: //contacts | 871 | case Key_F10: //contacts |
869 | // if( videoUI->isHidden()) | 872 | // if( videoUI->isHidden()) |
870 | // videoUI->showMaximized(); | 873 | // videoUI->showMaximized(); |
871 | break; | 874 | break; |
872 | case Key_F11: //menu | 875 | case Key_F11: //menu |
873 | break; | 876 | break; |
874 | case Key_F12: //home | 877 | case Key_F12: //home |
875 | // doBlank(); | 878 | // doBlank(); |
876 | break; | 879 | break; |
877 | case Key_F13: //mail | 880 | case Key_F13: //mail |
878 | // doUnblank(); | 881 | // doUnblank(); |
879 | break; | 882 | break; |
880 | case Key_Q: //add to playlist | 883 | case Key_Q: //add to playlist |
881 | addSelected(); | 884 | addSelected(); |
882 | break; | 885 | break; |
883 | case Key_R: //remove from playlist | 886 | case Key_R: //remove from playlist |
884 | removeSelected(); | 887 | removeSelected(); |
885 | break; | 888 | break; |
886 | // case Key_P: //play | 889 | // case Key_P: //play |
887 | // odebug << "Play" << oendl; | 890 | // odebug << "Play" << oendl; |
888 | // playSelected(); | 891 | // playSelected(); |
889 | // break; | 892 | // break; |
890 | case Key_Space: | 893 | case Key_Space: |
891 | // playSelected(); puh | 894 | // playSelected(); puh |
892 | break; | 895 | break; |
893 | case Key_1: | 896 | case Key_1: |
894 | tabWidget->setCurrentPage( 0 ); | 897 | tabWidget->setCurrentPage( 0 ); |
895 | break; | 898 | break; |
896 | case Key_2: | 899 | case Key_2: |
897 | tabWidget->setCurrentPage( 1 ); | 900 | tabWidget->setCurrentPage( 1 ); |
898 | break; | 901 | break; |
899 | case Key_3: | 902 | case Key_3: |
900 | tabWidget->setCurrentPage( 2 ); | 903 | tabWidget->setCurrentPage( 2 ); |
901 | break; | 904 | break; |
902 | case Key_4: | 905 | case Key_4: |
903 | tabWidget->setCurrentPage( 3 ); | 906 | tabWidget->setCurrentPage( 3 ); |
904 | break; | 907 | break; |
905 | case Key_Down: | 908 | case Key_Down: |
906 | if ( !d->selectedFiles->next() ) | 909 | if ( !d->selectedFiles->next() ) |
907 | d->selectedFiles->first(); | 910 | d->selectedFiles->first(); |
908 | break; | 911 | break; |
909 | case Key_Up: | 912 | case Key_Up: |
910 | if ( !d->selectedFiles->prev() ) | 913 | if ( !d->selectedFiles->prev() ) |
911 | // d->selectedFiles->last(); | 914 | // d->selectedFiles->last(); |
912 | break; | 915 | break; |
913 | } | 916 | } |
914 | } | 917 | } |
915 | 918 | ||
916 | void PlayListWidget::pmViewActivated(int index) { | 919 | void PlayListWidget::pmViewActivated(int index) { |
917 | // odebug << "" << index << "" << oendl; | 920 | // odebug << "" << index << "" << oendl; |
918 | switch(index) { | 921 | switch(index) { |
919 | case -16: | 922 | case -16: |
920 | { | 923 | { |
921 | mediaPlayerState->toggleFullscreen(); | 924 | mediaPlayerState->toggleFullscreen(); |
922 | bool b=mediaPlayerState->isFullscreen(); | 925 | bool b=mediaPlayerState->isFullscreen(); |
923 | pmView->setItemChecked( index, b); | 926 | pmView->setItemChecked( index, b); |
924 | Config cfg( "OpiePlayer" ); | 927 | Config cfg( "OpiePlayer" ); |
925 | cfg.writeEntry( "FullScreen", b ); | 928 | cfg.writeEntry( "FullScreen", b ); |
926 | } | 929 | } |
927 | break; | 930 | break; |
928 | }; | 931 | }; |
929 | } | 932 | } |
930 | 933 | ||
931 | void PlayListWidget::populateSkinsMenu() { | 934 | void PlayListWidget::populateSkinsMenu() { |
932 | int item = 0; | 935 | int item = 0; |
933 | defaultSkinIndex = 0; | 936 | defaultSkinIndex = 0; |
934 | QString skinName; | 937 | QString skinName; |
935 | Config cfg( "OpiePlayer" ); | 938 | Config cfg( "OpiePlayer" ); |
936 | cfg.setGroup("Options" ); | 939 | cfg.setGroup("Options" ); |
937 | QString skin = cfg.readEntry( "Skin", "default" ); | 940 | QString skin = cfg.readEntry( "Skin", "default" ); |
938 | 941 | ||
939 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 942 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
940 | skinsDir.setFilter( QDir::Dirs ); | 943 | skinsDir.setFilter( QDir::Dirs ); |
941 | skinsDir.setSorting(QDir::Name ); | 944 | skinsDir.setSorting(QDir::Name ); |
942 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 945 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
943 | QFileInfoListIterator it( *skinslist ); | 946 | QFileInfoListIterator it( *skinslist ); |
944 | QFileInfo *fi; | 947 | QFileInfo *fi; |
945 | while ( ( fi = it.current() ) ) { | 948 | while ( ( fi = it.current() ) ) { |
946 | skinName = fi->fileName(); | 949 | skinName = fi->fileName(); |
947 | // odebug << fi->fileName() << oendl; | 950 | // odebug << fi->fileName() << oendl; |
948 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 951 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
949 | item = skinsMenu->insertItem( fi->fileName() ) ; | 952 | item = skinsMenu->insertItem( fi->fileName() ) ; |
950 | } | 953 | } |
951 | if( skinName == "default" ) { | 954 | if( skinName == "default" ) { |
952 | defaultSkinIndex = item; | 955 | defaultSkinIndex = item; |
953 | } | 956 | } |
954 | if( skinName == skin ) { | 957 | if( skinName == skin ) { |
955 | skinsMenu->setItemChecked( item, TRUE ); | 958 | skinsMenu->setItemChecked( item, TRUE ); |
956 | } | 959 | } |
957 | ++it; | 960 | ++it; |
958 | } | 961 | } |
959 | } | 962 | } |
960 | 963 | ||
961 | void PlayListWidget::skinsMenuActivated( int item ) { | 964 | void PlayListWidget::skinsMenuActivated( int item ) { |
962 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 965 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
963 | skinsMenu->setItemChecked( i, FALSE ); | 966 | skinsMenu->setItemChecked( i, FALSE ); |
964 | } | 967 | } |
965 | skinsMenu->setItemChecked( item, TRUE ); | 968 | skinsMenu->setItemChecked( item, TRUE ); |
966 | 969 | ||
967 | { | 970 | { |
968 | Config cfg( "OpiePlayer" ); | 971 | Config cfg( "OpiePlayer" ); |
969 | cfg.setGroup("Options"); | 972 | cfg.setGroup("Options"); |
970 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 973 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
971 | } | 974 | } |
972 | 975 | ||
973 | emit skinSelected(); | 976 | emit skinSelected(); |
974 | } | 977 | } |
975 | 978 | ||
976 | PlayListWidget::TabType PlayListWidget::currentTab() const | 979 | PlayListWidget::TabType PlayListWidget::currentTab() const |
977 | { | 980 | { |
978 | static const TabType indexToTabType[ TabTypeCount ] = | 981 | static const TabType indexToTabType[ TabTypeCount ] = |
979 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 982 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
980 | 983 | ||
981 | int index = tabWidget->currentPageIndex(); | 984 | int index = tabWidget->currentPageIndex(); |
982 | assert( index < TabTypeCount && index >= 0 ); | 985 | assert( index < TabTypeCount && index >= 0 ); |
983 | 986 | ||
984 | return indexToTabType[ index ]; | 987 | return indexToTabType[ index ]; |
985 | } | 988 | } |
986 | 989 | ||
987 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 990 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
988 | { | 991 | { |
989 | if ( currentTab() == CurrentPlayList ) { | 992 | if ( currentTab() == CurrentPlayList ) { |
990 | const DocLnk *lnk = current(); | 993 | const DocLnk *lnk = current(); |
991 | return Entry( lnk->name(), lnk->file() ); | 994 | return Entry( lnk->name(), lnk->file() ); |
992 | } | 995 | } |
993 | 996 | ||
994 | return Entry( currentFileListPathName() ); | 997 | return Entry( currentFileListPathName() ); |
995 | } | 998 | } |
996 | 999 | ||
997 | QString PlayListWidget::currentFileListPathName() const { | 1000 | QString PlayListWidget::currentFileListPathName() const { |
998 | return currentFileListView->currentItem()->text( 3 ); | 1001 | return currentFileListView->currentItem()->text( 3 ); |
999 | } | 1002 | } |
1000 | 1003 | ||
1001 | 1004 | ||
1002 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1005 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1003 | odebug << "qcop message "+msg << oendl; | 1006 | odebug << "qcop message "+msg << oendl; |
1004 | QDataStream stream ( data, IO_ReadOnly ); | 1007 | QDataStream stream ( data, IO_ReadOnly ); |
1005 | if ( msg == "play()" ) { //plays current selection | 1008 | if ( msg == "play()" ) { //plays current selection |
1006 | btnPlay( true); | 1009 | btnPlay( true); |
1007 | } else if ( msg == "stop()" ) { | 1010 | } else if ( msg == "stop()" ) { |
1008 | mediaPlayerState->setPlaying( false); | 1011 | mediaPlayerState->setPlaying( false); |
1009 | } else if ( msg == "togglePause()" ) { | 1012 | } else if ( msg == "togglePause()" ) { |
1010 | mediaPlayerState->togglePaused(); | 1013 | mediaPlayerState->togglePaused(); |
1011 | } else if ( msg == "next()" ) { //select next in list | 1014 | } else if ( msg == "next()" ) { //select next in list |
1012 | mediaPlayerState->setNext(); | 1015 | mediaPlayerState->setNext(); |
1013 | } else if ( msg == "prev()" ) { //select previous in list | 1016 | } else if ( msg == "prev()" ) { //select previous in list |
1014 | mediaPlayerState->setPrev(); | 1017 | mediaPlayerState->setPrev(); |
1015 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1018 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1016 | mediaPlayerState->toggleLooping(); | 1019 | mediaPlayerState->toggleLooping(); |
1017 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1020 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1018 | mediaPlayerState->toggleShuffled(); | 1021 | mediaPlayerState->toggleShuffled(); |
1019 | } else if ( msg == "volUp()" ) { //volume more | 1022 | } else if ( msg == "volUp()" ) { //volume more |
1020 | // emit moreClicked(); | 1023 | // emit moreClicked(); |
1021 | // emit moreReleased(); | 1024 | // emit moreReleased(); |
1022 | } else if ( msg == "volDown()" ) { //volume less | 1025 | } else if ( msg == "volDown()" ) { //volume less |
1023 | // emit lessClicked(); | 1026 | // emit lessClicked(); |
1024 | // emit lessReleased(); | 1027 | // emit lessReleased(); |
1025 | } else if ( msg == "play(QString)" ) { //play this now | 1028 | } else if ( msg == "play(QString)" ) { //play this now |
1026 | QString file; | 1029 | QString file; |
1027 | stream >> file; | 1030 | stream >> file; |
1028 | setDocument( (const QString &) file); | 1031 | setDocument( (const QString &) file); |
1029 | } else if ( msg == "add(QString)" ) { //add to playlist | 1032 | } else if ( msg == "add(QString)" ) { //add to playlist |
1030 | QString file; | 1033 | QString file; |
1031 | stream >> file; | 1034 | stream >> file; |
1032 | QFileInfo fileInfo(file); | 1035 | QFileInfo fileInfo(file); |
1033 | DocLnk lnk; | 1036 | DocLnk lnk; |
1034 | lnk.setName( fileInfo.baseName() ); //sets name | 1037 | lnk.setName( fileInfo.baseName() ); //sets name |
1035 | lnk.setFile( file ); //sets file name | 1038 | lnk.setFile( file ); //sets file name |
1036 | addToSelection( lnk ); | 1039 | addToSelection( lnk ); |
1037 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1040 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1038 | QString file; | 1041 | QString file; |
1039 | stream >> file; | 1042 | stream >> file; |
1040 | 1043 | ||
1041 | } | 1044 | } |
1042 | 1045 | ||
1043 | } | 1046 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 94f99f8..9f944d7 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,271 +1,275 @@ | |||
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 | #include "xinecontrol.h" | ||
35 | #include "xinevideowidget.h" | ||
34 | 36 | ||
35 | #include <qtimer.h> | 37 | /* OPIE */ |
36 | #include <qmessagebox.h> | 38 | #include <opie2/odebug.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | using namespace Opie::Core; | ||
39 | 42 | ||
40 | #include "xinecontrol.h" | 43 | /* QT */ |
41 | #include "xinevideowidget.h" | 44 | #include <qtimer.h> |
45 | #include <qmessagebox.h> | ||
42 | 46 | ||
43 | XineControl::XineControl( XineVideoWidget *xineWidget, | 47 | XineControl::XineControl( XineVideoWidget *xineWidget, |
44 | MediaPlayerState &_mediaPlayerState, | 48 | MediaPlayerState &_mediaPlayerState, |
45 | QObject *parent, const char *name ) | 49 | QObject *parent, const char *name ) |
46 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 50 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
47 | { | 51 | { |
48 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); | 52 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); |
49 | 53 | ||
50 | init(); | 54 | init(); |
51 | } | 55 | } |
52 | 56 | ||
53 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 57 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
54 | MediaPlayerState &_mediaPlayerState, | 58 | MediaPlayerState &_mediaPlayerState, |
55 | QObject *parent, const char *name ) | 59 | QObject *parent, const char *name ) |
56 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 60 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
57 | { | 61 | { |
58 | xine->ensureInitialized(); | 62 | xine->ensureInitialized(); |
59 | 63 | ||
60 | xine->setWidget( xineWidget ); | 64 | xine->setWidget( xineWidget ); |
61 | 65 | ||
62 | init(); | 66 | init(); |
63 | } | 67 | } |
64 | 68 | ||
65 | void XineControl::init() | 69 | void XineControl::init() |
66 | { | 70 | { |
67 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 71 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
68 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); | 72 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); |
69 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); | 73 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); |
70 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); | 74 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled(bool) ), this, SLOT( setFullscreen(bool) ) ); |
71 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); | 75 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( seekTo(long) ) ); |
72 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); | 76 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged(int) ), this, SLOT( setGamma(int) ) ); |
73 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 77 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
74 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); | 78 | connect( xineVideoWidget, SIGNAL( videoResized(const QSize&) ), this, SLOT( videoResized(const QSize&) ) ); |
75 | 79 | ||
76 | disabledSuspendScreenSaver = FALSE; | 80 | disabledSuspendScreenSaver = FALSE; |
77 | } | 81 | } |
78 | 82 | ||
79 | XineControl::~XineControl() { | 83 | XineControl::~XineControl() { |
80 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 84 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
81 | if ( disabledSuspendScreenSaver ) { | 85 | if ( disabledSuspendScreenSaver ) { |
82 | disabledSuspendScreenSaver = FALSE; | 86 | disabledSuspendScreenSaver = FALSE; |
83 | // Re-enable the suspend mode | 87 | // Re-enable the suspend mode |
84 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 88 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
85 | } | 89 | } |
86 | #endif | 90 | #endif |
87 | delete libXine; | 91 | delete libXine; |
88 | } | 92 | } |
89 | 93 | ||
90 | void XineControl::play( const QString& fileName ) { | 94 | void XineControl::play( const QString& fileName ) { |
91 | 95 | ||
92 | hasVideoChannel = FALSE; | 96 | hasVideoChannel = FALSE; |
93 | hasAudioChannel = FALSE; | 97 | hasAudioChannel = FALSE; |
94 | m_fileName = fileName; | 98 | m_fileName = fileName; |
95 | 99 | ||
96 | odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; | 100 | odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; |
97 | 101 | ||
98 | if ( !libXine->play( fileName, 0, 0 ) ) { | 102 | if ( !libXine->play( fileName, 0, 0 ) ) { |
99 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 103 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
100 | // toggle stop so the the play button is reset | 104 | // toggle stop so the the play button is reset |
101 | mediaPlayerState.setPlaying( false ); | 105 | mediaPlayerState.setPlaying( false ); |
102 | return; | 106 | return; |
103 | } | 107 | } |
104 | mediaPlayerState.setPlaying( true ); | 108 | mediaPlayerState.setPlaying( true ); |
105 | 109 | ||
106 | MediaPlayerState::DisplayType displayType; | 110 | MediaPlayerState::DisplayType displayType; |
107 | if ( !libXine->hasVideo() ) { | 111 | if ( !libXine->hasVideo() ) { |
108 | displayType = MediaPlayerState::Audio; | 112 | displayType = MediaPlayerState::Audio; |
109 | odebug << "HAS AUDIO" << oendl; | 113 | odebug << "HAS AUDIO" << oendl; |
110 | libXine->setShowVideo( false ); | 114 | libXine->setShowVideo( false ); |
111 | hasAudioChannel = TRUE; | 115 | hasAudioChannel = TRUE; |
112 | } else { | 116 | } else { |
113 | displayType = MediaPlayerState::Video; | 117 | displayType = MediaPlayerState::Video; |
114 | odebug << "HAS VIDEO" << oendl; | 118 | odebug << "HAS VIDEO" << oendl; |
115 | libXine->setShowVideo( true ); | 119 | libXine->setShowVideo( true ); |
116 | hasVideoChannel = TRUE; | 120 | hasVideoChannel = TRUE; |
117 | } | 121 | } |
118 | // determine if slider is shown | 122 | // determine if slider is shown |
119 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 123 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
120 | 124 | ||
121 | // which gui (video / audio) | 125 | // which gui (video / audio) |
122 | mediaPlayerState.setDisplayType( displayType ); | 126 | mediaPlayerState.setDisplayType( displayType ); |
123 | 127 | ||
124 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 128 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
125 | if ( !disabledSuspendScreenSaver ) { | 129 | if ( !disabledSuspendScreenSaver ) { |
126 | disabledSuspendScreenSaver = TRUE; | 130 | disabledSuspendScreenSaver = TRUE; |
127 | // Stop the screen from blanking and power saving state | 131 | // Stop the screen from blanking and power saving state |
128 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 132 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
129 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 133 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
130 | } | 134 | } |
131 | #endif | 135 | #endif |
132 | 136 | ||
133 | length(); | 137 | length(); |
134 | position(); | 138 | position(); |
135 | } | 139 | } |
136 | 140 | ||
137 | void XineControl::nextMedia() { | 141 | void XineControl::nextMedia() { |
138 | mediaPlayerState.setNext(); | 142 | mediaPlayerState.setNext(); |
139 | } | 143 | } |
140 | 144 | ||
141 | void XineControl::setGamma( int value ) { | 145 | void XineControl::setGamma( int value ) { |
142 | libXine->setGamma( value ); | 146 | libXine->setGamma( value ); |
143 | } | 147 | } |
144 | 148 | ||
145 | void XineControl::stop( bool isSet ) { | 149 | void XineControl::stop( bool isSet ) { |
146 | if ( !isSet ) { | 150 | if ( !isSet ) { |
147 | libXine->stop(); | 151 | libXine->stop(); |
148 | 152 | ||
149 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 153 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
150 | if ( disabledSuspendScreenSaver ) { | 154 | if ( disabledSuspendScreenSaver ) { |
151 | disabledSuspendScreenSaver = FALSE; | 155 | disabledSuspendScreenSaver = FALSE; |
152 | // Re-enable the suspend mode | 156 | // Re-enable the suspend mode |
153 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 157 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
154 | } | 158 | } |
155 | #endif | 159 | #endif |
156 | } | 160 | } |
157 | } | 161 | } |
158 | 162 | ||
159 | /** | 163 | /** |
160 | * Pause playback | 164 | * Pause playback |
161 | * @isSet | 165 | * @isSet |
162 | */ | 166 | */ |
163 | void XineControl::pause( bool isSet) { | 167 | void XineControl::pause( bool isSet) { |
164 | libXine->pause( isSet ); | 168 | libXine->pause( isSet ); |
165 | } | 169 | } |
166 | 170 | ||
167 | 171 | ||
168 | /** | 172 | /** |
169 | * get current time in playback | 173 | * get current time in playback |
170 | */ | 174 | */ |
171 | long XineControl::currentTime() { | 175 | long XineControl::currentTime() { |
172 | // todo: jede sekunde überprüfen | 176 | // todo: jede sekunde überprüfen |
173 | m_currentTime = libXine->currentTime(); | 177 | m_currentTime = libXine->currentTime(); |
174 | return m_currentTime; | 178 | return m_currentTime; |
175 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 179 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
176 | } | 180 | } |
177 | 181 | ||
178 | /** | 182 | /** |
179 | * Set the length of the media file | 183 | * Set the length of the media file |
180 | */ | 184 | */ |
181 | void XineControl::length() { | 185 | void XineControl::length() { |
182 | m_length = libXine->length(); | 186 | m_length = libXine->length(); |
183 | mediaPlayerState.setLength( m_length ); | 187 | mediaPlayerState.setLength( m_length ); |
184 | } | 188 | } |
185 | 189 | ||
186 | 190 | ||
187 | /** | 191 | /** |
188 | * Reports the position the xine backend is at right now | 192 | * Reports the position the xine backend is at right now |
189 | * @return long the postion in seconds | 193 | * @return long the postion in seconds |
190 | */ | 194 | */ |
191 | long XineControl::position() { | 195 | long XineControl::position() { |
192 | m_position = ( currentTime() ); | 196 | m_position = ( currentTime() ); |
193 | mediaPlayerState.updatePosition( m_position ); | 197 | mediaPlayerState.updatePosition( m_position ); |
194 | long emitPos = (long)m_position; | 198 | long emitPos = (long)m_position; |
195 | emit positionChanged( emitPos ); | 199 | emit positionChanged( emitPos ); |
196 | if( mediaPlayerState.isPlaying() ) { | 200 | if( mediaPlayerState.isPlaying() ) { |
197 | // needs to be stopped the media is stopped | 201 | // needs to be stopped the media is stopped |
198 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 202 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
199 | } | 203 | } |
200 | return m_position; | 204 | return m_position; |
201 | } | 205 | } |
202 | 206 | ||
203 | /** | 207 | /** |
204 | * Set videoplayback to fullscreen | 208 | * Set videoplayback to fullscreen |
205 | * @param isSet | 209 | * @param isSet |
206 | */ | 210 | */ |
207 | void XineControl::setFullscreen( bool isSet ) { | 211 | void XineControl::setFullscreen( bool isSet ) { |
208 | libXine->showVideoFullScreen( isSet ); | 212 | libXine->showVideoFullScreen( isSet ); |
209 | } | 213 | } |
210 | 214 | ||
211 | 215 | ||
212 | QString XineControl::getMetaInfo() { | 216 | QString XineControl::getMetaInfo() { |
213 | 217 | ||
214 | QString returnString; | 218 | QString returnString; |
215 | 219 | ||
216 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 220 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
217 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 221 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
218 | } | 222 | } |
219 | 223 | ||
220 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 224 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
221 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 225 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
222 | } | 226 | } |
223 | 227 | ||
224 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 228 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
225 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 229 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
226 | } | 230 | } |
227 | 231 | ||
228 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 232 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
229 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 233 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
230 | } | 234 | } |
231 | 235 | ||
232 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 236 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
233 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 237 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
234 | } | 238 | } |
235 | 239 | ||
236 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 240 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
237 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 241 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
238 | } | 242 | } |
239 | return returnString; | 243 | return returnString; |
240 | } | 244 | } |
241 | 245 | ||
242 | QString XineControl::getErrorCode() { | 246 | QString XineControl::getErrorCode() { |
243 | 247 | ||
244 | int errorCode = libXine->error(); | 248 | int errorCode = libXine->error(); |
245 | 249 | ||
246 | odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; | 250 | odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; |
247 | 251 | ||
248 | if ( errorCode == 1 ) { | 252 | if ( errorCode == 1 ) { |
249 | return tr( "No input plugin found for this media type" ); | 253 | return tr( "No input plugin found for this media type" ); |
250 | } else if ( errorCode == 2 ) { | 254 | } else if ( errorCode == 2 ) { |
251 | return tr( "No demux plugin found for this media type" ); | 255 | return tr( "No demux plugin found for this media type" ); |
252 | } else if ( errorCode == 3 ) { | 256 | } else if ( errorCode == 3 ) { |
253 | return tr( "Demuxing failed for this media type" ); | 257 | return tr( "Demuxing failed for this media type" ); |
254 | } else if ( errorCode == 4 ) { | 258 | } else if ( errorCode == 4 ) { |
255 | return tr( "Malformed MRL" ); | 259 | return tr( "Malformed MRL" ); |
256 | } else { | 260 | } else { |
257 | return tr( "Some other error" ); | 261 | return tr( "Some other error" ); |
258 | } | 262 | } |
259 | } | 263 | } |
260 | 264 | ||
261 | /** | 265 | /** |
262 | * Seek to a position in the track | 266 | * Seek to a position in the track |
263 | * @param second the second to jump to | 267 | * @param second the second to jump to |
264 | */ | 268 | */ |
265 | void XineControl::seekTo( long second ) { | 269 | void XineControl::seekTo( long second ) { |
266 | libXine->seekTo( (int)second ); | 270 | libXine->seekTo( (int)second ); |
267 | } | 271 | } |
268 | 272 | ||
269 | void XineControl::videoResized ( const QSize &s ) { | 273 | void XineControl::videoResized ( const QSize &s ) { |
270 | libXine->resize( s ); | 274 | libXine->resize( s ); |
271 | } | 275 | } |