author | simon <simon> | 2002-12-02 23:33:37 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 23:33:37 (UTC) |
commit | c3c95ff297355f7024c15134bbc1d15d340bf8fd (patch) (unidiff) | |
tree | ad5ed1eef8ad82d53aef634bfa4b247210200c20 | |
parent | 22e232bdb4bae5e28013a4d14bfda3c068827557 (diff) | |
download | opie-c3c95ff297355f7024c15134bbc1d15d340bf8fd.zip opie-c3c95ff297355f7024c15134bbc1d15d340bf8fd.tar.gz opie-c3c95ff297355f7024c15134bbc1d15d340bf8fd.tar.bz2 |
- I better be a good boy and delete what I allocate :)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 8acc488..06b1a04 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,190 +1,192 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qpe/qlibrary.h> | 2 | #include <qpe/qlibrary.h> |
3 | #include <qpe/resource.h> | 3 | #include <qpe/resource.h> |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/qcopenvelope_qws.h> | 5 | #include <qpe/qcopenvelope_qws.h> |
6 | #include <qfileinfo.h> | 6 | #include <qfileinfo.h> |
7 | 7 | ||
8 | #include <qmainwindow.h> | 8 | #include <qmainwindow.h> |
9 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
10 | #include <qwidgetstack.h> | 10 | #include <qwidgetstack.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | 12 | ||
13 | #include "mediaplayer.h" | 13 | #include "mediaplayer.h" |
14 | #include "playlistwidget.h" | 14 | #include "playlistwidget.h" |
15 | #include "audiowidget.h" | 15 | #include "audiowidget.h" |
16 | #include "videowidget.h" | 16 | #include "videowidget.h" |
17 | #include "volumecontrol.h" | 17 | #include "volumecontrol.h" |
18 | 18 | ||
19 | #include "mediaplayerstate.h" | 19 | #include "mediaplayerstate.h" |
20 | 20 | ||
21 | // for setBacklight() | 21 | // for setBacklight() |
22 | #include <linux/fb.h> | 22 | #include <linux/fb.h> |
23 | #include <sys/file.h> | 23 | #include <sys/file.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | 28 | ||
29 | #define FBIOBLANK 0x4611 | 29 | #define FBIOBLANK 0x4611 |
30 | 30 | ||
31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { | 32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
33 | 33 | ||
34 | audioUI = 0; | 34 | audioUI = 0; |
35 | videoUI = 0; | 35 | videoUI = 0; |
36 | xineControl = 0; | 36 | xineControl = 0; |
37 | recreateAudioAndVideoWidgets(); | 37 | recreateAudioAndVideoWidgets(); |
38 | 38 | ||
39 | fd=-1;fl=-1; | 39 | fd=-1;fl=-1; |
40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); | 40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
41 | 41 | ||
42 | qApp->processEvents(); | 42 | qApp->processEvents(); |
43 | // QPEApplication::grabKeyboard(); // EVIL | 43 | // QPEApplication::grabKeyboard(); // EVIL |
44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
45 | 45 | ||
46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
47 | 47 | ||
48 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 48 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
49 | 49 | ||
50 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 50 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
51 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 51 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
52 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 52 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
53 | 53 | ||
54 | volControl = new VolumeControl; | 54 | volControl = new VolumeControl; |
55 | Config cfg( "OpiePlayer" ); | 55 | Config cfg( "OpiePlayer" ); |
56 | cfg.setGroup("PlayList"); | 56 | cfg.setGroup("PlayList"); |
57 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 57 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
58 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 58 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
59 | } | 59 | } |
60 | 60 | ||
61 | MediaPlayer::~MediaPlayer() { | 61 | MediaPlayer::~MediaPlayer() { |
62 | delete xineControl; | 62 | delete xineControl; |
63 | delete audioUI; | ||
64 | delete videoUI; | ||
63 | delete volControl; | 65 | delete volControl; |
64 | } | 66 | } |
65 | 67 | ||
66 | void MediaPlayer::pauseCheck( bool b ) { | 68 | void MediaPlayer::pauseCheck( bool b ) { |
67 | if ( b && !mediaPlayerState.isPlaying() ) { | 69 | if ( b && !mediaPlayerState.isPlaying() ) { |
68 | mediaPlayerState.setPaused( FALSE ); | 70 | mediaPlayerState.setPaused( FALSE ); |
69 | } | 71 | } |
70 | } | 72 | } |
71 | 73 | ||
72 | void MediaPlayer::play() { | 74 | void MediaPlayer::play() { |
73 | mediaPlayerState.setPlaying( FALSE ); | 75 | mediaPlayerState.setPlaying( FALSE ); |
74 | mediaPlayerState.setPlaying( TRUE ); | 76 | mediaPlayerState.setPlaying( TRUE ); |
75 | } | 77 | } |
76 | 78 | ||
77 | void MediaPlayer::setPlaying( bool play ) { | 79 | void MediaPlayer::setPlaying( bool play ) { |
78 | if ( !play ) { | 80 | if ( !play ) { |
79 | return; | 81 | return; |
80 | } | 82 | } |
81 | 83 | ||
82 | if ( mediaPlayerState.isPaused() ) { | 84 | if ( mediaPlayerState.isPaused() ) { |
83 | mediaPlayerState.setPaused( FALSE ); | 85 | mediaPlayerState.setPaused( FALSE ); |
84 | return; | 86 | return; |
85 | } | 87 | } |
86 | 88 | ||
87 | QString tickerText, time, fileName; | 89 | QString tickerText, time, fileName; |
88 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { | 90 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
89 | //if playing in file list.. play in a different way | 91 | //if playing in file list.. play in a different way |
90 | // random and looping settings enabled causes problems here, | 92 | // random and looping settings enabled causes problems here, |
91 | // since there is no selected file in the playlist, but a selected file in the file list, | 93 | // since there is no selected file in the playlist, but a selected file in the file list, |
92 | // so we remember and shutoff | 94 | // so we remember and shutoff |
93 | l = mediaPlayerState.isLooping(); | 95 | l = mediaPlayerState.isLooping(); |
94 | if(l) { | 96 | if(l) { |
95 | mediaPlayerState.setLooping( false ); | 97 | mediaPlayerState.setLooping( false ); |
96 | } | 98 | } |
97 | r = mediaPlayerState.isShuffled(); | 99 | r = mediaPlayerState.isShuffled(); |
98 | mediaPlayerState.setShuffled( false ); | 100 | mediaPlayerState.setShuffled( false ); |
99 | } | 101 | } |
100 | 102 | ||
101 | PlayListWidget::Entry playListEntry = playList.currentEntry(); | 103 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
102 | fileName = playListEntry.name; | 104 | fileName = playListEntry.name; |
103 | xineControl->play( playListEntry.file ); | 105 | xineControl->play( playListEntry.file ); |
104 | 106 | ||
105 | long seconds = mediaPlayerState.length(); | 107 | long seconds = mediaPlayerState.length(); |
106 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 108 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
107 | 109 | ||
108 | if( fileName.left(4) == "http" ) { | 110 | if( fileName.left(4) == "http" ) { |
109 | fileName = QFileInfo( fileName ).baseName(); | 111 | fileName = QFileInfo( fileName ).baseName(); |
110 | if ( xineControl->getMetaInfo().isEmpty() ) { | 112 | if ( xineControl->getMetaInfo().isEmpty() ) { |
111 | tickerText = tr( " File: " ) + fileName; | 113 | tickerText = tr( " File: " ) + fileName; |
112 | } else { | 114 | } else { |
113 | tickerText = xineControl->getMetaInfo(); | 115 | tickerText = xineControl->getMetaInfo(); |
114 | } | 116 | } |
115 | } else { | 117 | } else { |
116 | if ( xineControl->getMetaInfo().isEmpty() ) { | 118 | if ( xineControl->getMetaInfo().isEmpty() ) { |
117 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 119 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
118 | } else { | 120 | } else { |
119 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 121 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
120 | } | 122 | } |
121 | } | 123 | } |
122 | audioUI->setTickerText( tickerText ); | 124 | audioUI->setTickerText( tickerText ); |
123 | } | 125 | } |
124 | 126 | ||
125 | 127 | ||
126 | void MediaPlayer::prev() { | 128 | void MediaPlayer::prev() { |
127 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 129 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
128 | if ( playList.prev() ) { | 130 | if ( playList.prev() ) { |
129 | play(); | 131 | play(); |
130 | } else if ( mediaPlayerState.isLooping() ) { | 132 | } else if ( mediaPlayerState.isLooping() ) { |
131 | if ( playList.last() ) { | 133 | if ( playList.last() ) { |
132 | play(); | 134 | play(); |
133 | } | 135 | } |
134 | } else { | 136 | } else { |
135 | mediaPlayerState.setList(); | 137 | mediaPlayerState.setList(); |
136 | } | 138 | } |
137 | } | 139 | } |
138 | } | 140 | } |
139 | 141 | ||
140 | 142 | ||
141 | void MediaPlayer::next() { | 143 | void MediaPlayer::next() { |
142 | 144 | ||
143 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 145 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
144 | if ( playList.next() ) { | 146 | if ( playList.next() ) { |
145 | play(); | 147 | play(); |
146 | } else if ( mediaPlayerState.isLooping() ) { | 148 | } else if ( mediaPlayerState.isLooping() ) { |
147 | if ( playList.first() ) { | 149 | if ( playList.first() ) { |
148 | play(); | 150 | play(); |
149 | } | 151 | } |
150 | } else { | 152 | } else { |
151 | mediaPlayerState.setList(); | 153 | mediaPlayerState.setList(); |
152 | } | 154 | } |
153 | } else { //if playing from file list, let's just stop | 155 | } else { //if playing from file list, let's just stop |
154 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 156 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
155 | mediaPlayerState.setPlaying(false); | 157 | mediaPlayerState.setPlaying(false); |
156 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 158 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
157 | if(l) mediaPlayerState.setLooping(l); | 159 | if(l) mediaPlayerState.setLooping(l); |
158 | if(r) mediaPlayerState.setShuffled(r); | 160 | if(r) mediaPlayerState.setShuffled(r); |
159 | } | 161 | } |
160 | qApp->processEvents(); | 162 | qApp->processEvents(); |
161 | } | 163 | } |
162 | 164 | ||
163 | 165 | ||
164 | void MediaPlayer::startDecreasingVolume() { | 166 | void MediaPlayer::startDecreasingVolume() { |
165 | volumeDirection = -1; | 167 | volumeDirection = -1; |
166 | startTimer( 100 ); | 168 | startTimer( 100 ); |
167 | volControl->decVol(2); | 169 | volControl->decVol(2); |
168 | } | 170 | } |
169 | 171 | ||
170 | 172 | ||
171 | void MediaPlayer::startIncreasingVolume() { | 173 | void MediaPlayer::startIncreasingVolume() { |
172 | volumeDirection = +1; | 174 | volumeDirection = +1; |
173 | startTimer( 100 ); | 175 | startTimer( 100 ); |
174 | volControl->incVol(2); | 176 | volControl->incVol(2); |
175 | } | 177 | } |
176 | 178 | ||
177 | 179 | ||
178 | bool drawnOnScreenDisplay = FALSE; | 180 | bool drawnOnScreenDisplay = FALSE; |
179 | unsigned int onScreenDisplayVolume = 0; | 181 | unsigned int onScreenDisplayVolume = 0; |
180 | const int yoff = 110; | 182 | const int yoff = 110; |
181 | 183 | ||
182 | void MediaPlayer::stopChangingVolume() { | 184 | void MediaPlayer::stopChangingVolume() { |
183 | killTimers(); | 185 | killTimers(); |
184 | // Get rid of the on-screen display stuff | 186 | // Get rid of the on-screen display stuff |
185 | drawnOnScreenDisplay = FALSE; | 187 | drawnOnScreenDisplay = FALSE; |
186 | onScreenDisplayVolume = 0; | 188 | onScreenDisplayVolume = 0; |
187 | int w=0; | 189 | int w=0; |
188 | int h=0; | 190 | int h=0; |
189 | if( !xineControl->hasVideo() ) { | 191 | if( !xineControl->hasVideo() ) { |
190 | w = audioUI->width(); | 192 | w = audioUI->width(); |