Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index a9c74c4..8acc488 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -15,58 +15,56 @@ | |||
15 | #include "audiowidget.h" | 15 | #include "audiowidget.h" |
16 | #include "videowidget.h" | 16 | #include "videowidget.h" |
17 | #include "volumecontrol.h" | 17 | #include "volumecontrol.h" |
18 | 18 | ||
19 | #include "mediaplayerstate.h" | 19 | #include "mediaplayerstate.h" |
20 | 20 | ||
21 | // for setBacklight() | 21 | // for setBacklight() |
22 | #include <linux/fb.h> | 22 | #include <linux/fb.h> |
23 | #include <sys/file.h> | 23 | #include <sys/file.h> |
24 | #include <sys/ioctl.h> | 24 | #include <sys/ioctl.h> |
25 | 25 | ||
26 | 26 | ||
27 | extern VideoWidget *videoUI; | ||
28 | extern PlayListWidget *playList; | ||
29 | 27 | ||
30 | 28 | ||
31 | #define FBIOBLANK 0x4611 | 29 | #define FBIOBLANK 0x4611 |
32 | 30 | ||
33 | MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) | 31 | MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) |
34 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ) { | 32 | : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { |
35 | 33 | ||
36 | audioUI = 0; | 34 | audioUI = 0; |
37 | videoUI = 0; | 35 | videoUI = 0; |
38 | xineControl = 0; | 36 | xineControl = 0; |
39 | recreateAudioAndVideoWidgets(); | 37 | recreateAudioAndVideoWidgets(); |
40 | 38 | ||
41 | fd=-1;fl=-1; | 39 | fd=-1;fl=-1; |
42 | playList->setCaption( tr( "OpiePlayer: Initializating" ) ); | 40 | playList.setCaption( tr( "OpiePlayer: Initializating" ) ); |
43 | 41 | ||
44 | qApp->processEvents(); | 42 | qApp->processEvents(); |
45 | // QPEApplication::grabKeyboard(); // EVIL | 43 | // QPEApplication::grabKeyboard(); // EVIL |
46 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 44 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
47 | 45 | ||
48 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 46 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
49 | 47 | ||
50 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 48 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
51 | 49 | ||
52 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 50 | connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
53 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 51 | connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
54 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); | 52 | connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); |
55 | 53 | ||
56 | volControl = new VolumeControl; | 54 | volControl = new VolumeControl; |
57 | Config cfg( "OpiePlayer" ); | 55 | Config cfg( "OpiePlayer" ); |
58 | cfg.setGroup("PlayList"); | 56 | cfg.setGroup("PlayList"); |
59 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 57 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
60 | playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); | 58 | playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); |
61 | } | 59 | } |
62 | 60 | ||
63 | MediaPlayer::~MediaPlayer() { | 61 | MediaPlayer::~MediaPlayer() { |
64 | delete xineControl; | 62 | delete xineControl; |
65 | delete volControl; | 63 | delete volControl; |
66 | } | 64 | } |
67 | 65 | ||
68 | void MediaPlayer::pauseCheck( bool b ) { | 66 | void MediaPlayer::pauseCheck( bool b ) { |
69 | if ( b && !mediaPlayerState.isPlaying() ) { | 67 | if ( b && !mediaPlayerState.isPlaying() ) { |
70 | mediaPlayerState.setPaused( FALSE ); | 68 | mediaPlayerState.setPaused( FALSE ); |
71 | } | 69 | } |
72 | } | 70 | } |
@@ -78,38 +76,38 @@ void MediaPlayer::play() { | |||
78 | 76 | ||
79 | void MediaPlayer::setPlaying( bool play ) { | 77 | void MediaPlayer::setPlaying( bool play ) { |
80 | if ( !play ) { | 78 | if ( !play ) { |
81 | return; | 79 | return; |
82 | } | 80 | } |
83 | 81 | ||
84 | if ( mediaPlayerState.isPaused() ) { | 82 | if ( mediaPlayerState.isPaused() ) { |
85 | mediaPlayerState.setPaused( FALSE ); | 83 | mediaPlayerState.setPaused( FALSE ); |
86 | return; | 84 | return; |
87 | } | 85 | } |
88 | 86 | ||
89 | QString tickerText, time, fileName; | 87 | QString tickerText, time, fileName; |
90 | if ( playList->currentTab() != PlayListWidget::CurrentPlayList ) { | 88 | if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { |
91 | //if playing in file list.. play in a different way | 89 | //if playing in file list.. play in a different way |
92 | // random and looping settings enabled causes problems here, | 90 | // random and looping settings enabled causes problems here, |
93 | // since there is no selected file in the playlist, but a selected file in the file list, | 91 | // since there is no selected file in the playlist, but a selected file in the file list, |
94 | // so we remember and shutoff | 92 | // so we remember and shutoff |
95 | l = mediaPlayerState.isLooping(); | 93 | l = mediaPlayerState.isLooping(); |
96 | if(l) { | 94 | if(l) { |
97 | mediaPlayerState.setLooping( false ); | 95 | mediaPlayerState.setLooping( false ); |
98 | } | 96 | } |
99 | r = mediaPlayerState.isShuffled(); | 97 | r = mediaPlayerState.isShuffled(); |
100 | mediaPlayerState.setShuffled( false ); | 98 | mediaPlayerState.setShuffled( false ); |
101 | } | 99 | } |
102 | 100 | ||
103 | PlayListWidget::Entry playListEntry = playList->currentEntry(); | 101 | PlayListWidget::Entry playListEntry = playList.currentEntry(); |
104 | fileName = playListEntry.name; | 102 | fileName = playListEntry.name; |
105 | xineControl->play( playListEntry.file ); | 103 | xineControl->play( playListEntry.file ); |
106 | 104 | ||
107 | long seconds = mediaPlayerState.length(); | 105 | long seconds = mediaPlayerState.length(); |
108 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); | 106 | time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); |
109 | 107 | ||
110 | if( fileName.left(4) == "http" ) { | 108 | if( fileName.left(4) == "http" ) { |
111 | fileName = QFileInfo( fileName ).baseName(); | 109 | fileName = QFileInfo( fileName ).baseName(); |
112 | if ( xineControl->getMetaInfo().isEmpty() ) { | 110 | if ( xineControl->getMetaInfo().isEmpty() ) { |
113 | tickerText = tr( " File: " ) + fileName; | 111 | tickerText = tr( " File: " ) + fileName; |
114 | } else { | 112 | } else { |
115 | tickerText = xineControl->getMetaInfo(); | 113 | tickerText = xineControl->getMetaInfo(); |
@@ -117,45 +115,45 @@ void MediaPlayer::setPlaying( bool play ) { | |||
117 | } else { | 115 | } else { |
118 | if ( xineControl->getMetaInfo().isEmpty() ) { | 116 | if ( xineControl->getMetaInfo().isEmpty() ) { |
119 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; | 117 | tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; |
120 | } else { | 118 | } else { |
121 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; | 119 | tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; |
122 | } | 120 | } |
123 | } | 121 | } |
124 | audioUI->setTickerText( tickerText ); | 122 | audioUI->setTickerText( tickerText ); |
125 | } | 123 | } |
126 | 124 | ||
127 | 125 | ||
128 | void MediaPlayer::prev() { | 126 | void MediaPlayer::prev() { |
129 | if( playList->currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist | 127 | if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist |
130 | if ( playList->prev() ) { | 128 | if ( playList.prev() ) { |
131 | play(); | 129 | play(); |
132 | } else if ( mediaPlayerState.isLooping() ) { | 130 | } else if ( mediaPlayerState.isLooping() ) { |
133 | if ( playList->last() ) { | 131 | if ( playList.last() ) { |
134 | play(); | 132 | play(); |
135 | } | 133 | } |
136 | } else { | 134 | } else { |
137 | mediaPlayerState.setList(); | 135 | mediaPlayerState.setList(); |
138 | } | 136 | } |
139 | } | 137 | } |
140 | } | 138 | } |
141 | 139 | ||
142 | 140 | ||
143 | void MediaPlayer::next() { | 141 | void MediaPlayer::next() { |
144 | 142 | ||
145 | if(playList->currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist | 143 | if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist |
146 | if ( playList->next() ) { | 144 | if ( playList.next() ) { |
147 | play(); | 145 | play(); |
148 | } else if ( mediaPlayerState.isLooping() ) { | 146 | } else if ( mediaPlayerState.isLooping() ) { |
149 | if ( playList->first() ) { | 147 | if ( playList.first() ) { |
150 | play(); | 148 | play(); |
151 | } | 149 | } |
152 | } else { | 150 | } else { |
153 | mediaPlayerState.setList(); | 151 | mediaPlayerState.setList(); |
154 | } | 152 | } |
155 | } else { //if playing from file list, let's just stop | 153 | } else { //if playing from file list, let's just stop |
156 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); | 154 | qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); |
157 | mediaPlayerState.setPlaying(false); | 155 | mediaPlayerState.setPlaying(false); |
158 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); | 156 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); |
159 | if(l) mediaPlayerState.setLooping(l); | 157 | if(l) mediaPlayerState.setLooping(l); |
160 | if(r) mediaPlayerState.setShuffled(r); | 158 | if(r) mediaPlayerState.setShuffled(r); |
161 | } | 159 | } |
@@ -330,37 +328,37 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | |||
330 | // mediaPlayerState->toggleBlank(); | 328 | // mediaPlayerState->toggleBlank(); |
331 | break; | 329 | break; |
332 | case Key_F13: //mail | 330 | case Key_F13: //mail |
333 | qDebug("Blank here"); | 331 | qDebug("Blank here"); |
334 | // mediaPlayerState->toggleBlank(); | 332 | // mediaPlayerState->toggleBlank(); |
335 | break; | 333 | break; |
336 | } | 334 | } |
337 | } | 335 | } |
338 | 336 | ||
339 | void MediaPlayer::cleanUp() {// this happens on closing | 337 | void MediaPlayer::cleanUp() {// this happens on closing |
340 | Config cfg( "OpiePlayer" ); | 338 | Config cfg( "OpiePlayer" ); |
341 | mediaPlayerState.writeConfig( cfg ); | 339 | mediaPlayerState.writeConfig( cfg ); |
342 | playList->writeDefaultPlaylist( ); | 340 | playList.writeDefaultPlaylist( ); |
343 | 341 | ||
344 | // QPEApplication::grabKeyboard(); | 342 | // QPEApplication::grabKeyboard(); |
345 | // QPEApplication::ungrabKeyboard(); | 343 | // QPEApplication::ungrabKeyboard(); |
346 | } | 344 | } |
347 | 345 | ||
348 | void MediaPlayer::recreateAudioAndVideoWidgets() | 346 | void MediaPlayer::recreateAudioAndVideoWidgets() |
349 | { | 347 | { |
350 | delete xineControl; | 348 | delete xineControl; |
351 | delete audioUI; | 349 | delete audioUI; |
352 | delete videoUI; | 350 | delete videoUI; |
353 | audioUI = new AudioWidget( mediaPlayerState, 0, "audioUI" ); | 351 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
354 | videoUI = new VideoWidget( mediaPlayerState, 0, "videoUI" ); | 352 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
355 | 353 | ||
356 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 354 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
357 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 355 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 356 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
359 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 357 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | 358 | ||
361 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 359 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
362 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 360 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
363 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 361 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
364 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 362 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | 363 | ||
366 | xineControl = new XineControl( videoUI, mediaPlayerState ); | 364 | xineControl = new XineControl( videoUI, mediaPlayerState ); |