author | harlekin <harlekin> | 2002-07-08 23:46:13 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-08 23:46:13 (UTC) |
commit | 56554891922367c5d4e7d0f6965daa1026c0cc54 (patch) (unidiff) | |
tree | a21ce87e748517bfb5011a78f2e306826c493db2 | |
parent | 647a6c7ec282ea9b0b45baf8935b8eefc3ff8269 (diff) | |
download | opie-56554891922367c5d4e7d0f6965daa1026c0cc54.zip opie-56554891922367c5d4e7d0f6965daa1026c0cc54.tar.gz opie-56554891922367c5d4e7d0f6965daa1026c0cc54.tar.bz2 |
more gui parts working now
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 32 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 2 |
3 files changed, 31 insertions, 19 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index be59d8d..0ab0124 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -1,168 +1,172 @@ | |||
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 | 5 | ||
6 | #include <qmainwindow.h> | 6 | #include <qmainwindow.h> |
7 | #include <qmessagebox.h> | 7 | #include <qmessagebox.h> |
8 | #include <qwidgetstack.h> | 8 | #include <qwidgetstack.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | 10 | ||
11 | #include "mediaplayer.h" | 11 | #include "mediaplayer.h" |
12 | #include "playlistwidget.h" | 12 | #include "playlistwidget.h" |
13 | #include "audiowidget.h" | 13 | #include "audiowidget.h" |
14 | 14 | ||
15 | #include "mediaplayerstate.h" | 15 | #include "mediaplayerstate.h" |
16 | 16 | ||
17 | 17 | ||
18 | 18 | ||
19 | extern AudioWidget *audioUI; | 19 | extern AudioWidget *audioUI; |
20 | extern PlayListWidget *playList; | 20 | extern PlayListWidget *playList; |
21 | extern MediaPlayerState *mediaPlayerState; | 21 | extern MediaPlayerState *mediaPlayerState; |
22 | 22 | ||
23 | 23 | ||
24 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) | 24 | MediaPlayer::MediaPlayer( QObject *parent, const char *name ) |
25 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { | 25 | : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { |
26 | 26 | ||
27 | 27 | ||
28 | xineControl = new XineControl(); | 28 | xineControl = new XineControl(); |
29 | // QPEApplication::grabKeyboard(); // EVIL | 29 | // QPEApplication::grabKeyboard(); // EVIL |
30 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 30 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
31 | 31 | ||
32 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); | 32 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); |
33 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); | 33 | connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); |
34 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); | 34 | connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); |
35 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); | 35 | connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); |
36 | 36 | ||
37 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 37 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
38 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 38 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
39 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 39 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
40 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 40 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
41 | 41 | ||
42 | } | 42 | } |
43 | 43 | ||
44 | MediaPlayer::~MediaPlayer() { | 44 | MediaPlayer::~MediaPlayer() { |
45 | } | 45 | } |
46 | 46 | ||
47 | void MediaPlayer::pauseCheck( bool b ) { | 47 | void MediaPlayer::pauseCheck( bool b ) { |
48 | // Only pause if playing | 48 | // Only pause if playing |
49 | if ( b && !mediaPlayerState->playing() ) { | 49 | if ( b && !mediaPlayerState->playing() ) { |
50 | mediaPlayerState->setPaused( FALSE ); | 50 | mediaPlayerState->setPaused( FALSE ); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | void MediaPlayer::play() { | 54 | void MediaPlayer::play() { |
55 | mediaPlayerState->setPlaying( FALSE ); | 55 | mediaPlayerState->setPlaying( FALSE ); |
56 | mediaPlayerState->setPlaying( TRUE ); | 56 | mediaPlayerState->setPlaying( TRUE ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void MediaPlayer::setPlaying( bool play ) { | 59 | void MediaPlayer::setPlaying( bool play ) { |
60 | if ( !play ) { | 60 | if ( !play ) { |
61 | mediaPlayerState->setPaused( FALSE ); | 61 | mediaPlayerState->setPaused( FALSE ); |
62 | return; | 62 | return; |
63 | } | 63 | } |
64 | 64 | ||
65 | if ( mediaPlayerState->paused() ) { | 65 | if ( mediaPlayerState->paused() ) { |
66 | mediaPlayerState->setPaused( FALSE ); | 66 | mediaPlayerState->setPaused( FALSE ); |
67 | return; | 67 | return; |
68 | } | 68 | } |
69 | 69 | ||
70 | const DocLnk *playListCurrent = playList->current(); | 70 | const DocLnk *playListCurrent = playList->current(); |
71 | if ( playListCurrent != NULL ) { | 71 | if ( playListCurrent != NULL ) { |
72 | currentFile = playListCurrent; | 72 | currentFile = playListCurrent; |
73 | } | 73 | } |
74 | 74 | ||
75 | audioUI->setTickerText( currentFile->file( ) ); | 75 | audioUI->setTickerText( currentFile->file( ) ); |
76 | 76 | ||
77 | xineControl->play( currentFile->file() ); | 77 | xineControl->play( currentFile->file() ); |
78 | 78 | ||
79 | // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben | 79 | // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben |
80 | 80 | ||
81 | // Ob auch video 'v' : 'a' | 81 | // Ob auch video 'v' : 'a' |
82 | // mediaPlayerState->setView( 'v' ); | 82 | // mediaPlayerState->setView( 'v' ); |
83 | 83 | ||
84 | // abspielen starten. | 84 | // abspielen starten. |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
88 | void MediaPlayer::prev() { | 88 | void MediaPlayer::prev() { |
89 | if ( playList->prev() ) | 89 | if ( playList->prev() ) { |
90 | play(); | 90 | play(); |
91 | else if ( mediaPlayerState->looping() ) { | 91 | } else if ( mediaPlayerState->looping() ) { |
92 | if ( playList->last() ) | 92 | if ( playList->last() ) { |
93 | play(); | 93 | play(); |
94 | } else | 94 | } |
95 | mediaPlayerState->setList(); | 95 | } else { |
96 | mediaPlayerState->setList(); | ||
97 | } | ||
96 | } | 98 | } |
97 | 99 | ||
98 | 100 | ||
99 | void MediaPlayer::next() { | 101 | void MediaPlayer::next() { |
100 | if ( playList->next() ) | 102 | if ( playList->next() ) { |
101 | play(); | 103 | play(); |
102 | else if ( mediaPlayerState->looping() ) { | 104 | } else if ( mediaPlayerState->looping() ) { |
103 | if ( playList->first() ) | 105 | if ( playList->first() ) { |
104 | play(); | 106 | play(); |
105 | } else | 107 | } |
106 | mediaPlayerState->setList(); | 108 | } else { |
109 | mediaPlayerState->setList(); | ||
110 | } | ||
107 | } | 111 | } |
108 | 112 | ||
109 | 113 | ||
110 | void MediaPlayer::startDecreasingVolume() { | 114 | void MediaPlayer::startDecreasingVolume() { |
111 | volumeDirection = -1; | 115 | volumeDirection = -1; |
112 | startTimer( 100 ); | 116 | startTimer( 100 ); |
113 | // da kommt demnächst osound denk ich mal | 117 | // da kommt demnächst osound denk ich mal |
114 | // AudioDevice::decreaseVolume(); | 118 | // AudioDevice::decreaseVolume(); |
115 | } | 119 | } |
116 | 120 | ||
117 | 121 | ||
118 | void MediaPlayer::startIncreasingVolume() { | 122 | void MediaPlayer::startIncreasingVolume() { |
119 | volumeDirection = +1; | 123 | volumeDirection = +1; |
120 | startTimer( 100 ); | 124 | startTimer( 100 ); |
121 | // AudioDevice::increaseVolume(); | 125 | // AudioDevice::increaseVolume(); |
122 | } | 126 | } |
123 | 127 | ||
124 | 128 | ||
125 | void MediaPlayer::stopChangingVolume() { | 129 | void MediaPlayer::stopChangingVolume() { |
126 | killTimers(); | 130 | killTimers(); |
127 | } | 131 | } |
128 | 132 | ||
129 | 133 | ||
130 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 134 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
131 | // if ( volumeDirection == +1 ) | 135 | // if ( volumeDirection == +1 ) |
132 | // AudioDevice::increaseVolume(); | 136 | // AudioDevice::increaseVolume(); |
133 | // else if ( volumeDirection == -1 ) | 137 | // else if ( volumeDirection == -1 ) |
134 | // AudioDevice::decreaseVolume(); | 138 | // AudioDevice::decreaseVolume(); |
135 | } | 139 | } |
136 | 140 | ||
137 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { | 141 | void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { |
138 | switch ( e->key() ) { | 142 | switch ( e->key() ) { |
139 | ////////////////////////////// Zaurus keys | 143 | ////////////////////////////// Zaurus keys |
140 | case Key_Home: | 144 | case Key_Home: |
141 | break; | 145 | break; |
142 | case Key_F9: //activity | 146 | case Key_F9: //activity |
143 | break; | 147 | break; |
144 | case Key_F10: //contacts | 148 | case Key_F10: //contacts |
145 | break; | 149 | break; |
146 | case Key_F11: //menu | 150 | case Key_F11: //menu |
147 | break; | 151 | break; |
148 | case Key_F12: //home | 152 | case Key_F12: //home |
149 | qDebug("Blank here"); | 153 | qDebug("Blank here"); |
150 | break; | 154 | break; |
151 | case Key_F13: //mail | 155 | case Key_F13: //mail |
152 | break; | 156 | break; |
153 | } | 157 | } |
154 | } | 158 | } |
155 | 159 | ||
156 | void MediaPlayer::doBlank() { | 160 | void MediaPlayer::doBlank() { |
157 | 161 | ||
158 | } | 162 | } |
159 | 163 | ||
160 | void MediaPlayer::doUnblank() { | 164 | void MediaPlayer::doUnblank() { |
161 | 165 | ||
162 | } | 166 | } |
163 | 167 | ||
164 | void MediaPlayer::cleanUp() { | 168 | void MediaPlayer::cleanUp() { |
165 | // QPEApplication::grabKeyboard(); | 169 | // QPEApplication::grabKeyboard(); |
166 | // QPEApplication::ungrabKeyboard(); | 170 | // QPEApplication::ungrabKeyboard(); |
167 | 171 | ||
168 | } | 172 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index aaa1a24..cda9be2 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,51 +1,59 @@ | |||
1 | 1 | ||
2 | #include "xinecontrol.h" | 2 | #include "xinecontrol.h" |
3 | #include "mediaplayerstate.h" | 3 | #include "mediaplayerstate.h" |
4 | 4 | ||
5 | extern MediaPlayerState *mediaPlayerState; | 5 | extern MediaPlayerState *mediaPlayerState; |
6 | 6 | ||
7 | XineControl::XineControl( QObject *parent, const char *name ) | 7 | XineControl::XineControl( QObject *parent, const char *name ) |
8 | : QObject( parent, name ) { | 8 | : QObject( parent, name ) { |
9 | libXine = new XINE::Lib(); | 9 | libXine = new XINE::Lib(); |
10 | 10 | ||
11 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 11 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
12 | connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) ); | 12 | connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) ); |
13 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | ||
13 | 14 | ||
14 | } | 15 | } |
15 | 16 | ||
16 | XineControl::~XineControl() { | 17 | XineControl::~XineControl() { |
17 | delete libXine; | 18 | delete libXine; |
18 | } | 19 | } |
19 | 20 | ||
20 | void XineControl::play( const QString& fileName ) { | 21 | void XineControl::play( const QString& fileName ) { |
21 | libXine->play( fileName ); | 22 | libXine->play( fileName ); |
22 | mediaPlayerState->setPlaying( true ); | 23 | mediaPlayerState->setPlaying( true ); |
24 | // default to audio view until we know how to handle video | ||
25 | mediaPlayerState->setView('a'); | ||
26 | // determines of slider is shown | ||
27 | mediaPlayerState->isStreaming = false; | ||
23 | // hier dann schaun welcher view | 28 | // hier dann schaun welcher view |
24 | } | 29 | } |
25 | 30 | ||
26 | void XineControl::stop() { | 31 | void XineControl::stop( bool isSet ) { |
27 | libXine->stop(); | 32 | if ( isSet) { |
28 | mediaPlayerState->setPlaying( false ); | 33 | libXine->stop(); |
34 | } | ||
35 | // mediaPlayerState->setPlaying( false ); | ||
29 | } | 36 | } |
30 | 37 | ||
31 | void XineControl::pause( bool ) { | 38 | void XineControl::pause( bool isSet) { |
39 | |||
32 | libXine->pause(); | 40 | libXine->pause(); |
33 | } | 41 | } |
34 | 42 | ||
35 | int XineControl::currentTime() { | 43 | int XineControl::currentTime() { |
36 | // todo: jede sekunde überprüfen | 44 | // todo: jede sekunde überprüfen |
37 | m_currentTime = libXine->currentTime(); | 45 | m_currentTime = libXine->currentTime(); |
38 | return m_currentTime; | 46 | return m_currentTime; |
39 | } | 47 | } |
40 | 48 | ||
41 | void XineControl::length() { | 49 | void XineControl::length() { |
42 | m_length = libXine->length(); | 50 | m_length = libXine->length(); |
43 | mediaPlayerState->setLength( m_length ); | 51 | mediaPlayerState->setLength( m_length ); |
44 | } | 52 | } |
45 | 53 | ||
46 | int XineControl::position() { | 54 | int XineControl::position() { |
47 | m_position = (m_currentTime/m_length*100); | 55 | m_position = (m_currentTime/m_length*100); |
48 | mediaPlayerState->setPosition( m_position ); | 56 | mediaPlayerState->setPosition( m_position ); |
49 | return m_position; | 57 | return m_position; |
50 | emit positionChanged( m_position ); | 58 | emit positionChanged( m_position ); |
51 | } | 59 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 58ad8ec..e45f1df 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,38 +1,38 @@ | |||
1 | 1 | ||
2 | #ifndef XINECONTROL_H | 2 | #ifndef XINECONTROL_H |
3 | #define XINECONTROL_H | 3 | #define XINECONTROL_H |
4 | 4 | ||
5 | #include "lib.h" | 5 | #include "lib.h" |
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | 7 | ||
8 | class XineControl : public QObject { | 8 | class XineControl : public QObject { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | public: | 10 | public: |
11 | XineControl( QObject *parent = 0, const char *name =0 ); | 11 | XineControl( QObject *parent = 0, const char *name =0 ); |
12 | ~XineControl(); | 12 | ~XineControl(); |
13 | 13 | ||
14 | public slots: | 14 | public slots: |
15 | void play( const QString& fileName ); | 15 | void play( const QString& fileName ); |
16 | void stop(); | 16 | void stop( bool ); |
17 | void pause( bool ); | 17 | void pause( bool ); |
18 | 18 | ||
19 | int currentTime(); | 19 | int currentTime(); |
20 | 20 | ||
21 | // get length of media file and set it | 21 | // get length of media file and set it |
22 | void length(); | 22 | void length(); |
23 | 23 | ||
24 | int position(); | 24 | int position(); |
25 | 25 | ||
26 | private: | 26 | private: |
27 | XINE::Lib *libXine; | 27 | XINE::Lib *libXine; |
28 | int m_length; | 28 | int m_length; |
29 | int m_currentTime; | 29 | int m_currentTime; |
30 | int m_position; | 30 | int m_position; |
31 | 31 | ||
32 | signals: | 32 | signals: |
33 | void positionChanged( int position ); | 33 | void positionChanged( int position ); |
34 | 34 | ||
35 | }; | 35 | }; |
36 | 36 | ||
37 | 37 | ||
38 | #endif | 38 | #endif |