summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/xinecontrol.cpp
authorkergoth <kergoth>2003-08-09 16:24:58 (UTC)
committer kergoth <kergoth>2003-08-09 16:24:58 (UTC)
commite16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (unidiff)
tree9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/multimedia/opieplayer2/xinecontrol.cpp
parent1c58d1407f9584fedcdae390a04e2b37e5853361 (diff)
downloadopie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/multimedia/opieplayer2/xinecontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 1c489e3..a392f4a 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -15,116 +15,117 @@
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qmessagebox.h> 36#include <qmessagebox.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39
39#include "xinecontrol.h" 40#include "xinecontrol.h"
40#include "mediaplayerstate.h" 41#include "mediaplayerstate.h"
41#include "xinevideowidget.h" 42#include "xinevideowidget.h"
42 43
43XineControl::XineControl( XineVideoWidget *xineWidget, 44XineControl::XineControl( XineVideoWidget *xineWidget,
44 MediaPlayerState &_mediaPlayerState, 45 MediaPlayerState &_mediaPlayerState,
45 QObject *parent, const char *name ) 46 QObject *parent, const char *name )
46 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 47 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
47{ 48{
48 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); 49 libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget );
49 50
50 init(); 51 init();
51} 52}
52 53
53XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, 54XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget,
54 MediaPlayerState &_mediaPlayerState, 55 MediaPlayerState &_mediaPlayerState,
55 QObject *parent, const char *name ) 56 QObject *parent, const char *name )
56 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) 57 : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget )
57{ 58{
58 xine->ensureInitialized(); 59 xine->ensureInitialized();
59 60
60 xine->setWidget( xineWidget ); 61 xine->setWidget( xineWidget );
61 62
62 init(); 63 init();
63} 64}
64 65
65void XineControl::init() 66void XineControl::init()
66{ 67{
67 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 68 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
68 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); 69 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) );
69 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 70 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
70 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 71 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
71 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 72 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
72 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 73 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
73 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 74 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
74 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); 75 connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) );
75 76
76 disabledSuspendScreenSaver = FALSE; 77 disabledSuspendScreenSaver = FALSE;
77} 78}
78 79
79XineControl::~XineControl() { 80XineControl::~XineControl() {
80#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 81#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
81 if ( disabledSuspendScreenSaver ) { 82 if ( disabledSuspendScreenSaver ) {
82 disabledSuspendScreenSaver = FALSE; 83 disabledSuspendScreenSaver = FALSE;
83 // Re-enable the suspend mode 84 // Re-enable the suspend mode
84 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 85 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
85 } 86 }
86#endif 87#endif
87 delete libXine; 88 delete libXine;
88} 89}
89 90
90void XineControl::play( const QString& fileName ) { 91void XineControl::play( const QString& fileName ) {
92
91 hasVideoChannel = FALSE; 93 hasVideoChannel = FALSE;
92 hasAudioChannel = FALSE; 94 hasAudioChannel = FALSE;
93 m_fileName = fileName; 95 m_fileName = fileName;
94 96
95 qDebug("<<FILENAME: " + fileName + ">>>>"); 97 qDebug("<<FILENAME: " + fileName + ">>>>");
96 98
97 if ( !libXine->play( fileName, 0, 0 ) ) { 99 if ( !libXine->play( fileName, 0, 0 ) ) {
98 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 100 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
99 // toggle stop so the the play button is reset 101 // toggle stop so the the play button is reset
100 mediaPlayerState.setPlaying( false ); 102 mediaPlayerState.setPlaying( false );
101 return; 103 return;
102 } 104 }
103 mediaPlayerState.setPlaying( true ); 105 mediaPlayerState.setPlaying( true );
104 106
105 MediaPlayerState::DisplayType displayType; 107 MediaPlayerState::DisplayType displayType;
106 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
107 if ( !libXine->hasVideo() ) { 108 if ( !libXine->hasVideo() ) {
108 displayType = MediaPlayerState::Audio; 109 displayType = MediaPlayerState::Audio;
109 qDebug("HAS AUDIO"); 110 qDebug("HAS AUDIO");
110 libXine->setShowVideo( false ); 111 libXine->setShowVideo( false );
111 hasAudioChannel = TRUE; 112 hasAudioChannel = TRUE;
112 } else { 113 } else {
113 displayType = MediaPlayerState::Video; 114 displayType = MediaPlayerState::Video;
114 qDebug("HAS VIDEO"); 115 qDebug("HAS VIDEO");
115 libXine->setShowVideo( true ); 116 libXine->setShowVideo( true );
116 hasVideoChannel = TRUE; 117 hasVideoChannel = TRUE;
117 } 118 }
118 // determine if slider is shown 119 // determine if slider is shown
119 mediaPlayerState.setIsSeekable( libXine->isSeekable() ); 120 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
120 121
121 // which gui (video / audio) 122 // which gui (video / audio)
122 mediaPlayerState.setDisplayType( displayType ); 123 mediaPlayerState.setDisplayType( displayType );
123 124
124#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 125#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
125 if ( !disabledSuspendScreenSaver ) { 126 if ( !disabledSuspendScreenSaver ) {
126 disabledSuspendScreenSaver = TRUE; 127 disabledSuspendScreenSaver = TRUE;
127 // Stop the screen from blanking and power saving state 128 // Stop the screen from blanking and power saving state
128 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 129 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
129 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 130 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
130 } 131 }
@@ -176,49 +177,48 @@ long XineControl::currentTime() {
176} 177}
177 178
178/** 179/**
179 * Set the length of the media file 180 * Set the length of the media file
180 */ 181 */
181void XineControl::length() { 182void XineControl::length() {
182 m_length = libXine->length(); 183 m_length = libXine->length();
183 mediaPlayerState.setLength( m_length ); 184 mediaPlayerState.setLength( m_length );
184} 185}
185 186
186 187
187/** 188/**
188 * Reports the position the xine backend is at right now 189 * Reports the position the xine backend is at right now
189 * @return long the postion in seconds 190 * @return long the postion in seconds
190 */ 191 */
191long XineControl::position() { 192long XineControl::position() {
192 m_position = ( currentTime() ); 193 m_position = ( currentTime() );
193 mediaPlayerState.updatePosition( m_position ); 194 mediaPlayerState.updatePosition( m_position );
194 long emitPos = (long)m_position; 195 long emitPos = (long)m_position;
195 emit positionChanged( emitPos ); 196 emit positionChanged( emitPos );
196 if( mediaPlayerState.isPlaying() ) { 197 if( mediaPlayerState.isPlaying() ) {
197 // needs to be stopped the media is stopped 198 // needs to be stopped the media is stopped
198 QTimer::singleShot( 1000, this, SLOT( position() ) ); 199 QTimer::singleShot( 1000, this, SLOT( position() ) );
199 } 200 }
200 // qDebug("POSITION : %d", m_position);
201 return m_position; 201 return m_position;
202} 202}
203 203
204/** 204/**
205 * Set videoplayback to fullscreen 205 * Set videoplayback to fullscreen
206 * @param isSet 206 * @param isSet
207 */ 207 */
208void XineControl::setFullscreen( bool isSet ) { 208void XineControl::setFullscreen( bool isSet ) {
209 libXine->showVideoFullScreen( isSet ); 209 libXine->showVideoFullScreen( isSet );
210} 210}
211 211
212 212
213QString XineControl::getMetaInfo() { 213QString XineControl::getMetaInfo() {
214 214
215 QString returnString; 215 QString returnString;
216 216
217 if ( !libXine->metaInfo( 0 ).isEmpty() ) { 217 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
218 returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); 218 returnString += tr( " Title: " + libXine->metaInfo( 0 ) );
219 } 219 }
220 220
221 if ( !libXine->metaInfo( 1 ).isEmpty() ) { 221 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
222 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); 222 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
223 } 223 }
224 224