Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 100 |
1 files changed, 65 insertions, 35 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index bf2acc8..553e3c1 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,11 +1,12 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qcopenvelope_qws.h> | 5 | #include <qpe/qcopenvelope_qws.h> |
6 | #include <qfileinfo.h> | ||
6 | 7 | ||
7 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
8 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
9 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
10 | #include <qfile.h> | 11 | #include <qfile.h> |
11 | 12 | ||
@@ -72,71 +73,100 @@ void MediaPlayer::pauseCheck( bool b ) { | |||
72 | if ( b && !mediaPlayerState->playing() ) { | 73 | if ( b && !mediaPlayerState->playing() ) { |
73 | mediaPlayerState->setPaused( FALSE ); | 74 | mediaPlayerState->setPaused( FALSE ); |
74 | } | 75 | } |
75 | } | 76 | } |
76 | 77 | ||
77 | void MediaPlayer::play() { | 78 | void MediaPlayer::play() { |
78 | mediaPlayerState->setPlaying( FALSE ); | 79 | mediaPlayerState->setPlaying( FALSE ); |
79 | mediaPlayerState->setPlaying( TRUE ); | 80 | mediaPlayerState->setPlaying( TRUE ); |
80 | } | 81 | } |
81 | 82 | ||
82 | void MediaPlayer::setPlaying( bool play ) { | 83 | void MediaPlayer::setPlaying( bool play ) { |
83 | if ( !play ) { | 84 | if ( !play ) { |
84 | return; | 85 | return; |
85 | } | 86 | } |
86 | 87 | ||
87 | if ( mediaPlayerState->paused() ) { | 88 | if ( mediaPlayerState->paused() ) { |
88 | mediaPlayerState->setPaused( FALSE ); | 89 | mediaPlayerState->setPaused( FALSE ); |
89 | return; | 90 | return; |
90 | } | ||
91 | |||
92 | const DocLnk *playListCurrent = playList->current(); | ||
93 | if ( playListCurrent != NULL ) { | ||
94 | currentFile = playListCurrent; | ||
95 | } | 91 | } |
96 | 92 | ||
97 | xineControl->play( currentFile->file() ); | 93 | QString tickerText, time, fileName; |
98 | 94 | if( playList->whichList() == 0 ) { //check for filelist | |
99 | long seconds = mediaPlayerState->length();// | 95 | const DocLnk *playListCurrent = playList->current(); |
100 | QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 96 | if ( playListCurrent != NULL ) { |
101 | qDebug(time); | 97 | currentFile = playListCurrent; |
102 | 98 | } | |
103 | QString tickerText; | 99 | xineControl->play( currentFile->file() ); |
104 | if( currentFile->file().left(4) == "http" ) | 100 | fileName = currentFile->name(); |
105 | tickerText= tr( " File: " ) + currentFile->name(); | 101 | long seconds = mediaPlayerState->length();// |
106 | else | 102 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
107 | tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; | 103 | qDebug(time); |
108 | 104 | ||
109 | audioUI->setTickerText( currentFile->file( ) ); | 105 | } else { //if playing in file list.. play in a different way |
106 | // random and looping settings enabled causes problems here, | ||
107 | // since there is no selected file in the playlist, but a selected file in the file list, | ||
108 | // so we remember and shutoff | ||
109 | l = mediaPlayerState->looping(); | ||
110 | if(l) | ||
111 | mediaPlayerState->setLooping( false ); | ||
112 | r = mediaPlayerState->shuffled(); | ||
113 | mediaPlayerState->setShuffled(false); | ||
114 | |||
115 | fileName = playList->currentFileListPathName(); | ||
116 | xineControl->play( fileName); | ||
117 | long seconds = mediaPlayerState->length();// | ||
118 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | ||
119 | qDebug(time); | ||
120 | if( fileName.left(4) != "http" ) | ||
121 | fileName = QFileInfo( fileName).baseName(); | ||
110 | 122 | ||
123 | } | ||
124 | if( fileName.left(4) == "http" ) | ||
125 | tickerText= tr( " File: " ) + fileName; | ||
126 | else | ||
127 | tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time; | ||
128 | audioUI->setTickerText( tickerText ); | ||
111 | } | 129 | } |
112 | 130 | ||
113 | 131 | ||
114 | void MediaPlayer::prev() { | 132 | void MediaPlayer::prev() { |
115 | if ( playList->prev() ) { | 133 | if(playList->whichList() == 0) { //if using the playlist |
116 | play(); | 134 | if ( playList->prev() ) { |
117 | } else if ( mediaPlayerState->looping() ) { | ||
118 | if ( playList->last() ) { | ||
119 | play(); | 135 | play(); |
136 | } else if ( mediaPlayerState->looping() ) { | ||
137 | if ( playList->last() ) { | ||
138 | play(); | ||
139 | } | ||
140 | } else { | ||
141 | mediaPlayerState->setList(); | ||
120 | } | 142 | } |
121 | } else { | ||
122 | mediaPlayerState->setList(); | ||
123 | } | 143 | } |
124 | } | 144 | } |
125 | 145 | ||
126 | 146 | ||
127 | void MediaPlayer::next() { | 147 | void MediaPlayer::next() { |
128 | if ( playList->next() ) { | 148 | |
129 | play(); | 149 | if(playList->whichList() == 0) { //if using the playlist |
130 | } else if ( mediaPlayerState->looping() ) { | 150 | if ( playList->next() ) { |
131 | if ( playList->first() ) { | ||
132 | play(); | 151 | play(); |
152 | } else if ( mediaPlayerState->looping() ) { | ||
153 | if ( playList->first() ) { | ||
154 | play(); | ||
155 | } | ||
156 | } else { | ||
157 | mediaPlayerState->setList(); | ||
133 | } | 158 | } |
134 | } else { | 159 | } else { //if playing from file list, let's just stop |
135 | mediaPlayerState->setList(); | 160 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
161 | mediaPlayerState->setPlaying(false); | ||
162 | mediaPlayerState->setView('l'); | ||
163 | if(l) mediaPlayerState->setLooping(l); | ||
164 | if(r) mediaPlayerState->setShuffled(r); | ||
136 | } | 165 | } |
166 | qApp->processEvents(); | ||
137 | } | 167 | } |
138 | 168 | ||
139 | 169 | ||
140 | void MediaPlayer::startDecreasingVolume() { | 170 | void MediaPlayer::startDecreasingVolume() { |
141 | volumeDirection = -1; | 171 | volumeDirection = -1; |
142 | startTimer( 100 ); | 172 | startTimer( 100 ); |