-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 7 | ||||
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.h | 20 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 18 | ||||
-rw-r--r-- | core/multimedia/opieplayer/mediaplayerstate.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 1 |
5 files changed, 28 insertions, 20 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 3212001..20345b7 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -43,103 +43,106 @@ struct MediaButton { | |||
43 | }; | 43 | }; |
44 | 44 | ||
45 | 45 | ||
46 | // Layout information for the audioButtons (and if it is a toggle button or not) | 46 | // Layout information for the audioButtons (and if it is a toggle button or not) |
47 | MediaButton audioButtons[] = { | 47 | MediaButton audioButtons[] = { |
48 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play | 48 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play |
49 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop | 49 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop |
50 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause | 50 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause |
51 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next | 51 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next |
52 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous | 52 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous |
53 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up | 53 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up |
54 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 54 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
55 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 55 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
61 | 61 | ||
62 | 62 | ||
63 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 63 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
64 | QWidget( parent, name, f ) | 64 | QWidget( parent, name, f ) |
65 | { | 65 | { |
66 | // QPEApplication::grabKeyboard(); | 66 | // QPEApplication::grabKeyboard(); |
67 | setCaption( tr("OpiePlayer") ); | 67 | setCaption( tr("OpiePlayer") ); |
68 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 68 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
69 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); | 69 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); |
70 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); | 70 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); |
71 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); | 71 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); |
72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); | 72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); |
73 | 73 | ||
74 | songInfo = new Ticker( this ); | 74 | songInfo = new Ticker( this ); |
75 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 75 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
77 | 77 | ||
78 | slider = new QSlider( Qt::Horizontal, this ); | 78 | slider = new QSlider( Qt::Horizontal, this ); |
79 | slider->setFixedWidth( 220 ); | 79 | slider->setFixedWidth( 220 ); |
80 | slider->setFixedHeight( 20 ); | 80 | slider->setFixedHeight( 20 ); |
81 | slider->setMinValue( 0 ); | 81 | slider->setMinValue( 0 ); |
82 | slider->setMaxValue( 1 ); | 82 | slider->setMaxValue( 1 ); |
83 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 83 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
84 | slider->setFocusPolicy( QWidget::NoFocus ); | 84 | slider->setFocusPolicy( QWidget::NoFocus ); |
85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
86 | 86 | ||
87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
89 | 89 | ||
90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
91 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
92 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
93 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 91 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
94 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 92 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
95 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 93 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
96 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 94 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
97 | 95 | ||
96 | if( !mediaPlayerState->isStreaming) { // this stops the slider from being moved, thus | ||
97 | // does not stop stream when it reaches the end | ||
98 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
99 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
100 | } | ||
98 | // Intialise state | 101 | // Intialise state |
99 | setLength( mediaPlayerState->length() ); | 102 | setLength( mediaPlayerState->length() ); |
100 | setPosition( mediaPlayerState->position() ); | 103 | setPosition( mediaPlayerState->position() ); |
101 | setLooping( mediaPlayerState->fullscreen() ); | 104 | setLooping( mediaPlayerState->fullscreen() ); |
102 | setPaused( mediaPlayerState->paused() ); | 105 | setPaused( mediaPlayerState->paused() ); |
103 | setPlaying( mediaPlayerState->playing() ); | 106 | setPlaying( mediaPlayerState->playing() ); |
104 | 107 | ||
105 | } | 108 | } |
106 | 109 | ||
107 | 110 | ||
108 | AudioWidget::~AudioWidget() { | 111 | AudioWidget::~AudioWidget() { |
109 | for ( int i = 0; i < 4; i++ ) | 112 | for ( int i = 0; i < 4; i++ ) |
110 | delete pixmaps[i]; | 113 | delete pixmaps[i]; |
111 | } | 114 | } |
112 | 115 | ||
113 | 116 | ||
114 | static bool audioSliderBeingMoved = FALSE; | 117 | static bool audioSliderBeingMoved = FALSE; |
115 | 118 | ||
116 | 119 | ||
117 | void AudioWidget::sliderPressed() { | 120 | void AudioWidget::sliderPressed() { |
118 | audioSliderBeingMoved = TRUE; | 121 | audioSliderBeingMoved = TRUE; |
119 | } | 122 | } |
120 | 123 | ||
121 | 124 | ||
122 | void AudioWidget::sliderReleased() { | 125 | void AudioWidget::sliderReleased() { |
123 | audioSliderBeingMoved = FALSE; | 126 | audioSliderBeingMoved = FALSE; |
124 | if ( slider->width() == 0 ) | 127 | if ( slider->width() == 0 ) |
125 | return; | 128 | return; |
126 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 129 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
127 | mediaPlayerState->setPosition( val ); | 130 | mediaPlayerState->setPosition( val ); |
128 | } | 131 | } |
129 | 132 | ||
130 | 133 | ||
131 | void AudioWidget::setPosition( long i ) { | 134 | void AudioWidget::setPosition( long i ) { |
132 | updateSlider( i, mediaPlayerState->length() ); | 135 | updateSlider( i, mediaPlayerState->length() ); |
133 | } | 136 | } |
134 | 137 | ||
135 | 138 | ||
136 | void AudioWidget::setLength( long max ) { | 139 | void AudioWidget::setLength( long max ) { |
137 | updateSlider( mediaPlayerState->position(), max ); | 140 | updateSlider( mediaPlayerState->position(), max ); |
138 | } | 141 | } |
139 | 142 | ||
140 | 143 | ||
141 | void AudioWidget::setView( char view ) { | 144 | void AudioWidget::setView( char view ) { |
142 | if ( view == 'a' ) { | 145 | if ( view == 'a' ) { |
143 | startTimer( 150 ); | 146 | startTimer( 150 ); |
144 | showMaximized(); | 147 | showMaximized(); |
145 | } else { | 148 | } else { |
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h index d1d72b6..4ffd167 100644 --- a/core/multimedia/opieplayer/audiowidget.h +++ b/core/multimedia/opieplayer/audiowidget.h | |||
@@ -8,138 +8,138 @@ | |||
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 | 20 | ||
21 | #ifndef AUDIO_WIDGET_H | 21 | #ifndef AUDIO_WIDGET_H |
22 | #define AUDIO_WIDGET_H | 22 | #define AUDIO_WIDGET_H |
23 | 23 | ||
24 | #include <qwidget.h> | 24 | #include <qwidget.h> |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qslider.h> | 29 | #include <qslider.h> |
30 | #include <qframe.h> | 30 | #include <qframe.h> |
31 | 31 | ||
32 | 32 | ||
33 | class QPixmap; | 33 | class QPixmap; |
34 | 34 | ||
35 | 35 | ||
36 | enum AudioButtons { | 36 | enum AudioButtons { |
37 | AudioPlay, | 37 | AudioPlay, |
38 | AudioStop, | 38 | AudioStop, |
39 | AudioPause, | 39 | AudioPause, |
40 | AudioNext, | 40 | AudioNext, |
41 | AudioPrevious, | 41 | AudioPrevious, |
42 | AudioVolumeUp, | 42 | AudioVolumeUp, |
43 | AudioVolumeDown, | 43 | AudioVolumeDown, |
44 | AudioLoop, | 44 | AudioLoop, |
45 | AudioPlayList | 45 | AudioPlayList |
46 | }; | 46 | }; |
47 | 47 | ||
48 | 48 | ||
49 | #define USE_DBLBUF | 49 | #define USE_DBLBUF |
50 | 50 | ||
51 | 51 | ||
52 | class Ticker : public QFrame { | 52 | class Ticker : public QFrame { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { | 55 | Ticker( QWidget* parent=0 ) : QFrame( parent ) { |
56 | setFrameStyle( WinPanel | Sunken ); | 56 | setFrameStyle( WinPanel | Sunken ); |
57 | setText( "No Song" ); | 57 | setText( "No Song" ); |
58 | } | 58 | } |
59 | ~Ticker() { } | 59 | ~Ticker() { } |
60 | void setText( const QString& text ) { | 60 | void setText( const QString& text ) { |
61 | pos = 0; // reset it everytime the text is changed | 61 | pos = 0; // reset it everytime the text is changed |
62 | scrollText = text; | 62 | scrollText = text; |
63 | pixelLen = fontMetrics().width( scrollText ); | 63 | pixelLen = fontMetrics().width( scrollText ); |
64 | killTimers(); | 64 | killTimers(); |
65 | if ( pixelLen > width() ) | 65 | if ( pixelLen > width() ) |
66 | startTimer( 50 ); | 66 | startTimer( 50 ); |
67 | update(); | 67 | update(); |
68 | } | 68 | } |
69 | protected: | 69 | protected: |
70 | void timerEvent( QTimerEvent * ) { | 70 | void timerEvent( QTimerEvent * ) { |
71 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; | 71 | pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; |
72 | #ifndef USE_DBLBUF | 72 | #ifndef USE_DBLBUF |
73 | scroll( -1, 0, contentsRect() ); | 73 | scroll( -1, 0, contentsRect() ); |
74 | #else | 74 | #else |
75 | repaint( FALSE ); | 75 | repaint( FALSE ); |
76 | #endif | 76 | #endif |
77 | } | 77 | } |
78 | void drawContents( QPainter *p ) { | 78 | void drawContents( QPainter *p ) { |
79 | #ifndef USE_DBLBUF | 79 | #ifndef USE_DBLBUF |
80 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 80 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) |
81 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 81 | p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
82 | #else | 82 | #else |
83 | // Double buffering code. | 83 | // Double buffering code. |
84 | // Looks like qvfb makes it look like it flickers but I don't think it really is | 84 | // Looks like qvfb makes it look like it flickers but I don't think it really is |
85 | QPixmap pm( width(), height() ); | 85 | QPixmap pm( width(), height() ); |
86 | pm.fill( colorGroup().base() ); | 86 | pm.fill( colorGroup().base() ); |
87 | QPainter pmp( &pm ); | 87 | QPainter pmp( &pm ); |
88 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) | 88 | for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) |
89 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); | 89 | pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); |
90 | p->drawPixmap( 0, 0, pm ); | 90 | p->drawPixmap( 0, 0, pm ); |
91 | #endif | 91 | #endif |
92 | } | 92 | } |
93 | private: | 93 | private: |
94 | QString scrollText; | 94 | QString scrollText; |
95 | int pos, pixelLen; | 95 | int pos, pixelLen; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | class AudioWidget : public QWidget { | 99 | class AudioWidget : public QWidget { |
100 | Q_OBJECT | 100 | Q_OBJECT |
101 | public: | 101 | public: |
102 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 102 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
103 | ~AudioWidget(); | 103 | ~AudioWidget(); |
104 | void setTickerText( const QString &text ) { songInfo->setText( text ); } | 104 | void setTickerText( const QString &text ) { songInfo->setText( text ); } |
105 | 105 | bool isStreaming; | |
106 | public slots: | 106 | public slots: |
107 | void updateSlider( long, long ); | 107 | void updateSlider( long, long ); |
108 | void sliderPressed( ); | 108 | void sliderPressed( ); |
109 | void sliderReleased( ); | 109 | void sliderReleased( ); |
110 | void setPaused( bool b) { setToggleButton( AudioPause, b ); } | 110 | void setPaused( bool b) { setToggleButton( AudioPause, b ); } |
111 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 111 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
112 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 112 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
113 | void setPosition( long ); | 113 | void setPosition( long ); |
114 | void setLength( long ); | 114 | void setLength( long ); |
115 | void setView( char ); | 115 | void setView( char ); |
116 | 116 | ||
117 | signals: | 117 | signals: |
118 | void moreClicked(); | 118 | void moreClicked(); |
119 | void lessClicked(); | 119 | void lessClicked(); |
120 | void moreReleased(); | 120 | void moreReleased(); |
121 | void lessReleased(); | 121 | void lessReleased(); |
122 | void sliderMoved(long); | 122 | void sliderMoved(long); |
123 | 123 | ||
124 | protected: | 124 | protected: |
125 | void paintEvent( QPaintEvent *pe ); | 125 | void paintEvent( QPaintEvent *pe ); |
126 | void showEvent( QShowEvent *se ); | 126 | void showEvent( QShowEvent *se ); |
127 | void mouseMoveEvent( QMouseEvent *event ); | 127 | void mouseMoveEvent( QMouseEvent *event ); |
128 | void mousePressEvent( QMouseEvent *event ); | 128 | void mousePressEvent( QMouseEvent *event ); |
129 | void mouseReleaseEvent( QMouseEvent *event ); | 129 | void mouseReleaseEvent( QMouseEvent *event ); |
130 | void timerEvent( QTimerEvent *event ); | 130 | void timerEvent( QTimerEvent *event ); |
131 | void closeEvent( QCloseEvent *event ); | 131 | void closeEvent( QCloseEvent *event ); |
132 | void keyReleaseEvent( QKeyEvent *e); | 132 | void keyReleaseEvent( QKeyEvent *e); |
133 | 133 | ||
134 | private: | 134 | private: |
135 | void toggleButton( int ); | 135 | void toggleButton( int ); |
136 | void setToggleButton( int, bool ); | 136 | void setToggleButton( int, bool ); |
137 | void paintButton( QPainter *p, int i ); | 137 | void paintButton( QPainter *p, int i ); |
138 | QPixmap *pixmaps[4]; | 138 | QPixmap *pixmaps[4]; |
139 | Ticker *songInfo; | 139 | Ticker *songInfo; |
140 | QSlider *slider; | 140 | QSlider *slider; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | 143 | ||
144 | #endif // AUDIO_WIDGET_H | 144 | #endif // AUDIO_WIDGET_H |
145 | 145 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index b9f96de..45c2d3e 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -191,104 +191,105 @@ void LoopControl::startVideo() { | |||
191 | 191 | ||
192 | current_frame = long( playtime.elapsed() * framerate / 1000 ); | 192 | current_frame = long( playtime.elapsed() * framerate / 1000 ); |
193 | 193 | ||
194 | if ( prev_frame != -1 && current_frame <= prev_frame ) | 194 | if ( prev_frame != -1 && current_frame <= prev_frame ) |
195 | return; | 195 | return; |
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | // Don't skip | 198 | // Don't skip |
199 | current_frame++; | 199 | current_frame++; |
200 | } | 200 | } |
201 | 201 | ||
202 | if ( prev_frame == -1 || current_frame > prev_frame ) { | 202 | if ( prev_frame == -1 || current_frame > prev_frame ) { |
203 | if ( current_frame > prev_frame + 1 ) { | 203 | if ( current_frame > prev_frame + 1 ) { |
204 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 204 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
205 | } | 205 | } |
206 | moreVideo = videoUI->playVideo(); | 206 | moreVideo = videoUI->playVideo(); |
207 | prev_frame = current_frame; | 207 | prev_frame = current_frame; |
208 | } | 208 | } |
209 | 209 | ||
210 | } else { | 210 | } else { |
211 | 211 | ||
212 | moreVideo = FALSE; | 212 | moreVideo = FALSE; |
213 | killTimer( videoId ); | 213 | killTimer( videoId ); |
214 | 214 | ||
215 | } | 215 | } |
216 | 216 | ||
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void LoopControl::startAudio() { | 221 | void LoopControl::startAudio() { |
222 | 222 | ||
223 | //qDebug("start audio"); | 223 | //qDebug("start audio"); |
224 | audioMutex->lock(); | 224 | audioMutex->lock(); |
225 | if ( moreAudio ) { | 225 | if ( moreAudio ) { |
226 | 226 | ||
227 | if ( !isMuted && mediaPlayerState->curDecoder() ) { | 227 | if ( !isMuted && mediaPlayerState->curDecoder() ) { |
228 | 228 | ||
229 | currentSample = audioSampleCounter + 1; | 229 | currentSample = audioSampleCounter + 1; |
230 | 230 | ||
231 | if ( currentSample != audioSampleCounter + 1 ) | 231 | if ( currentSample != audioSampleCounter + 1 ) |
232 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 232 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); |
233 | 233 | ||
234 | long samplesRead = 0; | 234 | long samplesRead = 0; |
235 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); | 235 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); |
236 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 236 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
237 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 237 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
238 | 238 | ||
239 | // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 239 | // this causes drop outs not sure why its even here |
240 | // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 240 | // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { |
241 | // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | ||
242 | // } | ||
243 | // else if ( sampleWaitTime <= -5000 ) { | ||
244 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | ||
245 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | ||
246 | // currentSample = sampleWeShouldBeAt; | ||
241 | // } | 247 | // } |
242 | // else if ( sampleWaitTime <= -5000 ) { | ||
243 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | ||
244 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | ||
245 | // currentSample = sampleWeShouldBeAt; | ||
246 | // } | ||
247 | 248 | ||
248 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 249 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
249 | audioSampleCounter = currentSample + samplesRead - 1; | 250 | audioSampleCounter = currentSample + samplesRead - 1; |
250 | 251 | ||
251 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 252 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); |
252 | 253 | ||
253 | } else { | 254 | } else { |
254 | 255 | ||
255 | moreAudio = FALSE; | 256 | moreAudio = FALSE; |
256 | 257 | ||
257 | } | 258 | } |
258 | 259 | ||
259 | } | 260 | } |
260 | 261 | ||
261 | audioMutex->unlock(); | 262 | audioMutex->unlock(); |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | void LoopControl::killTimers() { | 266 | void LoopControl::killTimers() { |
266 | 267 | ||
267 | audioMutex->lock(); | 268 | audioMutex->lock(); |
268 | 269 | ||
269 | if ( hasVideoChannel ) | 270 | if ( hasVideoChannel ) |
270 | killTimer( videoId ); | 271 | killTimer( videoId ); |
271 | killTimer( sliderId ); | 272 | killTimer( sliderId ); |
272 | threadOkToGo = FALSE; | 273 | threadOkToGo = FALSE; |
273 | 274 | ||
274 | audioMutex->unlock(); | 275 | audioMutex->unlock(); |
275 | } | 276 | } |
276 | 277 | ||
277 | 278 | ||
278 | void LoopControl::startTimers() { | 279 | void LoopControl::startTimers() { |
279 | 280 | ||
280 | audioMutex->lock(); | 281 | audioMutex->lock(); |
281 | 282 | ||
282 | moreVideo = FALSE; | 283 | moreVideo = FALSE; |
283 | moreAudio = FALSE; | 284 | moreAudio = FALSE; |
284 | 285 | ||
285 | if ( hasVideoChannel ) { | 286 | if ( hasVideoChannel ) { |
286 | moreVideo = TRUE; | 287 | moreVideo = TRUE; |
287 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value | 288 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value |
288 | videoId = startTimer( mSecsBetweenFrames ); | 289 | videoId = startTimer( mSecsBetweenFrames ); |
289 | } | 290 | } |
290 | 291 | ||
291 | if ( hasAudioChannel ) { | 292 | if ( hasAudioChannel ) { |
292 | moreAudio = TRUE; | 293 | moreAudio = TRUE; |
293 | threadOkToGo = TRUE; | 294 | threadOkToGo = TRUE; |
294 | } | 295 | } |
@@ -387,88 +388,91 @@ bool LoopControl::init( const QString& filename ) { | |||
387 | 388 | ||
388 | mediaPlayerState->setLength( total_audio_samples ); | 389 | mediaPlayerState->setLength( total_audio_samples ); |
389 | 390 | ||
390 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 391 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
391 | qDebug( "LC- frequency = %d", freq ); | 392 | qDebug( "LC- frequency = %d", freq ); |
392 | 393 | ||
393 | audioSampleCounter = 0; | 394 | audioSampleCounter = 0; |
394 | int bits_per_sample; | 395 | int bits_per_sample; |
395 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { | 396 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { |
396 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); | 397 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); |
397 | qDebug("using stupid hack"); | 398 | qDebug("using stupid hack"); |
398 | } else { | 399 | } else { |
399 | bits_per_sample=0; | 400 | bits_per_sample=0; |
400 | } | 401 | } |
401 | 402 | ||
402 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); | 403 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
403 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 404 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
404 | channels = audioDevice->channels(); | 405 | channels = audioDevice->channels(); |
405 | 406 | ||
406 | //### must check which frequency is actually used. | 407 | //### must check which frequency is actually used. |
407 | static const int size = 1; | 408 | static const int size = 1; |
408 | short int buf[size]; | 409 | short int buf[size]; |
409 | long samplesRead = 0; | 410 | long samplesRead = 0; |
410 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 411 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
411 | } | 412 | } |
412 | 413 | ||
413 | if ( hasVideoChannel ) { | 414 | if ( hasVideoChannel ) { |
414 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 415 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
415 | 416 | ||
416 | mediaPlayerState->setLength( total_video_frames ); | 417 | mediaPlayerState->setLength( total_video_frames ); |
417 | 418 | ||
418 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 419 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
419 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 420 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
420 | 421 | ||
421 | if ( framerate <= 1.0 ) { | 422 | if ( framerate <= 1.0 ) { |
422 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 423 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
423 | framerate = 25; | 424 | framerate = 25; |
424 | } | 425 | } |
425 | 426 | ||
426 | if ( total_video_frames == 1 ) { | 427 | if ( total_video_frames == 1 ) { |
427 | DecodeLoopDebug(( "Cannot seek to frame" )); | 428 | DecodeLoopDebug(( "Cannot seek to frame" )); |
428 | } | 429 | } |
429 | 430 | ||
430 | } | 431 | } |
431 | 432 | ||
432 | current_frame = 0; | 433 | current_frame = 0; |
433 | prev_frame = -1; | 434 | prev_frame = -1; |
434 | 435 | ||
436 | if( fileName.left(7) == "http://") | ||
437 | mediaPlayerState->isStreaming = TRUE; | ||
438 | |||
435 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); | 439 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); |
436 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); | 440 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); |
437 | 441 | ||
438 | audioMutex->unlock(); | 442 | audioMutex->unlock(); |
439 | 443 | ||
440 | return TRUE; | 444 | return TRUE; |
441 | } | 445 | } |
442 | 446 | ||
443 | 447 | ||
444 | void LoopControl::play() { | 448 | void LoopControl::play() { |
445 | qDebug("LC- play"); | 449 | qDebug("LC- play"); |
446 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 450 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
447 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 451 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
448 | disabledSuspendScreenSaver = TRUE; | 452 | disabledSuspendScreenSaver = TRUE; |
449 | previousSuspendMode = hasVideoChannel; | 453 | previousSuspendMode = hasVideoChannel; |
450 | // Stop the screen from blanking and power saving state | 454 | // Stop the screen from blanking and power saving state |
451 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 455 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
452 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 456 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
453 | } | 457 | } |
454 | #endif | 458 | #endif |
455 | 459 | ||
456 | playtime.start(); | 460 | playtime.start(); |
457 | startTimers(); | 461 | startTimers(); |
458 | } | 462 | } |
459 | 463 | ||
460 | 464 | ||
461 | void LoopControl::setMute( bool on ) { | 465 | void LoopControl::setMute( bool on ) { |
462 | if ( on != isMuted ) { | 466 | if ( on != isMuted ) { |
463 | isMuted = on; | 467 | isMuted = on; |
464 | if ( !on ) { | 468 | if ( !on ) { |
465 | // Force an update of the position | 469 | // Force an update of the position |
466 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 470 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
467 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 471 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
468 | // Resume playing audio | 472 | // Resume playing audio |
469 | moreAudio = TRUE; | 473 | moreAudio = TRUE; |
470 | } | 474 | } |
471 | } | 475 | } |
472 | } | 476 | } |
473 | 477 | ||
474 | 478 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h index ad273f1..06c5556 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.h +++ b/core/multimedia/opieplayer/mediaplayerstate.h | |||
@@ -1,85 +1,85 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 | #ifndef MEDIA_PLAYER_STATE_H | 20 | #ifndef MEDIA_PLAYER_STATE_H |
21 | #define MEDIA_PLAYER_STATE_H | 21 | #define MEDIA_PLAYER_STATE_H |
22 | 22 | ||
23 | 23 | ||
24 | #include <qobject.h> | 24 | #include <qobject.h> |
25 | 25 | ||
26 | 26 | ||
27 | class MediaPlayerDecoder; | 27 | class MediaPlayerDecoder; |
28 | class Config; | 28 | class Config; |
29 | 29 | ||
30 | 30 | ||
31 | class MediaPlayerState : public QObject { | 31 | class MediaPlayerState : public QObject { |
32 | Q_OBJECT | 32 | Q_OBJECT |
33 | public: | 33 | public: |
34 | MediaPlayerState( QObject *parent, const char *name ); | 34 | MediaPlayerState( QObject *parent, const char *name ); |
35 | ~MediaPlayerState(); | 35 | ~MediaPlayerState(); |
36 | 36 | ||
37 | 37 | bool isStreaming; | |
38 | bool fullscreen() { return isFullscreen; } | 38 | bool fullscreen() { return isFullscreen; } |
39 | bool scaled() { return isScaled; } | 39 | bool scaled() { return isScaled; } |
40 | bool looping() { return isLooping; } | 40 | bool looping() { return isLooping; } |
41 | bool shuffled() { return isShuffled; } | 41 | bool shuffled() { return isShuffled; } |
42 | bool playlist() { return usePlaylist; } | 42 | bool playlist() { return usePlaylist; } |
43 | bool paused() { return isPaused; } | 43 | bool paused() { return isPaused; } |
44 | bool playing() { return isPlaying; } | 44 | bool playing() { return isPlaying; } |
45 | long position() { return curPosition; } | 45 | long position() { return curPosition; } |
46 | long length() { return curLength; } | 46 | long length() { return curLength; } |
47 | char view() { return curView; } | 47 | char view() { return curView; } |
48 | 48 | ||
49 | MediaPlayerDecoder *newDecoder( const QString& file ); | 49 | MediaPlayerDecoder *newDecoder( const QString& file ); |
50 | MediaPlayerDecoder *curDecoder(); | 50 | MediaPlayerDecoder *curDecoder(); |
51 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the | 51 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the |
52 | // number of audio samples if we are using the libmad plugin | 52 | // number of audio samples if we are using the libmad plugin |
53 | public slots: | 53 | public slots: |
54 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } | 54 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } |
55 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } | 55 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } |
56 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } | 56 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } |
57 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } | 57 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } |
58 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } | 58 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } |
59 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } | 59 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } |
60 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } | 60 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } |
61 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } | 61 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } |
62 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } | 62 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } |
63 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } | 63 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } |
64 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } | 64 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } |
65 | 65 | ||
66 | void setPrev() { emit prev(); } | 66 | void setPrev() { emit prev(); } |
67 | void setNext() { emit next(); } | 67 | void setNext() { emit next(); } |
68 | void setList() { setPlaying( FALSE ); setView('l'); } | 68 | void setList() { setPlaying( FALSE ); setView('l'); } |
69 | void setVideo() { setView('v'); } | 69 | void setVideo() { setView('v'); } |
70 | void setAudio() { setView('a'); } | 70 | void setAudio() { setView('a'); } |
71 | 71 | ||
72 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } | 72 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } |
73 | void toggleScaled() { setScaled( !isScaled); } | 73 | void toggleScaled() { setScaled( !isScaled); } |
74 | void toggleLooping() { setLooping( !isLooping); } | 74 | void toggleLooping() { setLooping( !isLooping); } |
75 | void toggleShuffled() { setShuffled( !isShuffled); } | 75 | void toggleShuffled() { setShuffled( !isShuffled); } |
76 | void togglePlaylist() { setPlaylist( !usePlaylist); } | 76 | void togglePlaylist() { setPlaylist( !usePlaylist); } |
77 | void togglePaused() { setPaused( !isPaused); } | 77 | void togglePaused() { setPaused( !isPaused); } |
78 | void togglePlaying() { setPlaying( !isPlaying); } | 78 | void togglePlaying() { setPlaying( !isPlaying); } |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void fullscreenToggled( bool ); | 81 | void fullscreenToggled( bool ); |
82 | void scaledToggled( bool ); | 82 | void scaledToggled( bool ); |
83 | void loopingToggled( bool ); | 83 | void loopingToggled( bool ); |
84 | void shuffledToggled( bool ); | 84 | void shuffledToggled( bool ); |
85 | void playlistToggled( bool ); | 85 | void playlistToggled( bool ); |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 250645c..ff156f8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -948,74 +948,75 @@ void PlayListWidget::populateAudioView() { | |||
948 | 948 | ||
949 | QListViewItem * newItem; | 949 | QListViewItem * newItem; |
950 | if ( QFile( dit.current()->file()).exists() ) { | 950 | if ( QFile( dit.current()->file()).exists() ) { |
951 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 951 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
952 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 952 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
953 | } | 953 | } |
954 | } | 954 | } |
955 | } | 955 | } |
956 | 956 | ||
957 | void PlayListWidget::populateVideoView() { | 957 | void PlayListWidget::populateVideoView() { |
958 | StorageInfo storageInfo; | 958 | StorageInfo storageInfo; |
959 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 959 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
960 | 960 | ||
961 | Global::findDocuments(&vFiles, "video/*"); | 961 | Global::findDocuments(&vFiles, "video/*"); |
962 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 962 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
963 | QListIterator<FileSystem> it ( fs ); | 963 | QListIterator<FileSystem> it ( fs ); |
964 | videoView->clear(); | 964 | videoView->clear(); |
965 | QString storage; | 965 | QString storage; |
966 | for ( ; Vdit.current(); ++Vdit ) { | 966 | for ( ; Vdit.current(); ++Vdit ) { |
967 | for( ; it.current(); ++it ){ | 967 | for( ; it.current(); ++it ){ |
968 | const QString name = (*it)->name(); | 968 | const QString name = (*it)->name(); |
969 | const QString path = (*it)->path(); | 969 | const QString path = (*it)->path(); |
970 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 970 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
971 | } | 971 | } |
972 | 972 | ||
973 | QListViewItem * newItem; | 973 | QListViewItem * newItem; |
974 | if ( QFile( Vdit.current()->file()).exists() ) { | 974 | if ( QFile( Vdit.current()->file()).exists() ) { |
975 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 975 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
976 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 976 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
977 | } | 977 | } |
978 | } | 978 | } |
979 | } | 979 | } |
980 | 980 | ||
981 | void PlayListWidget::openFile() { | 981 | void PlayListWidget::openFile() { |
982 | QString filename, name; | 982 | QString filename, name; |
983 | InputDialog *fileDlg; | 983 | InputDialog *fileDlg; |
984 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 984 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
985 | fileDlg->exec(); | 985 | fileDlg->exec(); |
986 | if( fileDlg->result() == 1 ) { | 986 | if( fileDlg->result() == 1 ) { |
987 | filename = fileDlg->LineEdit1->text(); | 987 | filename = fileDlg->LineEdit1->text(); |
988 | 988 | ||
989 | // InputDialog *fileDlg2; | 989 | // InputDialog *fileDlg2; |
990 | // fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0); | 990 | // fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0); |
991 | // fileDlg2->exec(); | 991 | // fileDlg2->exec(); |
992 | // if( fileDlg2->result() == 1 ) { | 992 | // if( fileDlg2->result() == 1 ) { |
993 | // name = fileDlg2->LineEdit1->text(); | 993 | // name = fileDlg2->LineEdit1->text(); |
994 | // } | 994 | // } |
995 | //http://205.188.234.129:8030 | 995 | //http://205.188.234.129:8030 |
996 | // http://66.28.68.70:8000 | ||
996 | qDebug(filename); | 997 | qDebug(filename); |
997 | DocLnk lnk; | 998 | DocLnk lnk; |
998 | // if(filename.left(7) == "http://") | 999 | // if(filename.left(7) == "http://") |
999 | // name= filename.right(filename.length()-filename.find("http://")-7); | 1000 | // name= filename.right(filename.length()-filename.find("http://")-7); |
1000 | // else name = filename; | 1001 | // else name = filename; |
1001 | // qDebug("name is "+name); | 1002 | // qDebug("name is "+name); |
1002 | // lnk.setComment(filename); | 1003 | // lnk.setComment(filename); |
1003 | lnk.setName(filename); //sets file name | 1004 | lnk.setName(filename); //sets file name |
1004 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1005 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") |
1005 | filename += "/"; | 1006 | filename += "/"; |
1006 | lnk.setFile(filename); //sets File property | 1007 | lnk.setFile(filename); //sets File property |
1007 | 1008 | ||
1008 | lnk.setType("audio/x-mpegurl"); | 1009 | lnk.setType("audio/x-mpegurl"); |
1009 | lnk.setExec("opieplayer"); | 1010 | lnk.setExec("opieplayer"); |
1010 | lnk.setIcon("opieplayer/MPEGPlayer"); | 1011 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1011 | 1012 | ||
1012 | if(!lnk.writeLink()) | 1013 | if(!lnk.writeLink()) |
1013 | qDebug("Writing doclink did not work"); | 1014 | qDebug("Writing doclink did not work"); |
1014 | d->selectedFiles->addToSelection( lnk); | 1015 | d->selectedFiles->addToSelection( lnk); |
1015 | // if(fileDlg2) | 1016 | // if(fileDlg2) |
1016 | // delete fileDlg2; | 1017 | // delete fileDlg2; |
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | if(fileDlg) | 1020 | if(fileDlg) |
1020 | delete fileDlg; | 1021 | delete fileDlg; |
1021 | } | 1022 | } |