-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index d08ff04..cf7dcb2 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -22,116 +22,136 @@ | |||
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library 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 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library 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 "xinecontrol.h" | 36 | #include "xinecontrol.h" |
37 | #include "mediaplayerstate.h" | 37 | #include "mediaplayerstate.h" |
38 | #include "videowidget.h" | 38 | #include "videowidget.h" |
39 | 39 | ||
40 | extern MediaPlayerState *mediaPlayerState; | 40 | extern MediaPlayerState *mediaPlayerState; |
41 | extern VideoWidget *videoUI; | 41 | extern VideoWidget *videoUI; |
42 | XineControl::XineControl( QObject *parent, const char *name ) | 42 | XineControl::XineControl( QObject *parent, const char *name ) |
43 | : QObject( parent, name ) { | 43 | : QObject( parent, name ) { |
44 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 44 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
45 | 45 | ||
46 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 46 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
47 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 47 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
48 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 48 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
50 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 50 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
52 | |||
53 | } | 52 | } |
54 | 53 | ||
55 | XineControl::~XineControl() { | 54 | XineControl::~XineControl() { |
56 | delete libXine; | 55 | delete libXine; |
57 | } | 56 | } |
58 | 57 | ||
59 | void XineControl::play( const QString& fileName ) { | 58 | void XineControl::play( const QString& fileName ) { |
60 | m_fileName = fileName; | 59 | m_fileName = fileName; |
61 | libXine->play( fileName ); | 60 | libXine->play( fileName ); |
62 | mediaPlayerState->setPlaying( true ); | 61 | mediaPlayerState->setPlaying( true ); |
63 | // default to audio view until we know how to handle video | 62 | // default to audio view until we know how to handle video |
64 | // MediaDetect mdetect; | 63 | // MediaDetect mdetect; |
65 | char whichGui = mdetect.videoOrAudio( fileName ); | 64 | char whichGui = mdetect.videoOrAudio( fileName ); |
66 | if (whichGui == 'f') { | 65 | if (whichGui == 'f') { |
67 | qDebug("Nicht erkannter Dateityp"); | 66 | qDebug("Nicht erkannter Dateityp"); |
68 | return; | 67 | return; |
69 | } | 68 | } |
70 | 69 | ||
71 | if (whichGui == 'a') { | 70 | if (whichGui == 'a') { |
72 | libXine->setShowVideo( false ); | 71 | libXine->setShowVideo( false ); |
73 | } else { | 72 | } else { |
74 | libXine->setShowVideo( true ); | 73 | libXine->setShowVideo( true ); |
75 | } | 74 | } |
76 | 75 | ||
77 | // determine if slider is shown | 76 | // determine if slider is shown |
78 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); | 77 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); |
79 | mediaPlayerState->setIsStreaming( libXine->isSeekable() ); | 78 | mediaPlayerState->setIsStreaming( libXine->isSeekable() ); |
80 | // which gui (video / audio) | 79 | // which gui (video / audio) |
81 | mediaPlayerState->setView( whichGui ); | 80 | mediaPlayerState->setView( whichGui ); |
82 | length(); | 81 | length(); |
83 | position(); | 82 | position(); |
84 | } | 83 | } |
85 | 84 | ||
86 | void XineControl::stop( bool isSet ) { | 85 | void XineControl::stop( bool isSet ) { |
87 | if ( !isSet) { | 86 | if ( !isSet) { |
88 | libXine->stop(); | 87 | libXine->stop(); |
89 | mediaPlayerState->setList(); | 88 | mediaPlayerState->setList(); |
90 | //mediaPlayerState->setPlaying( false ); | 89 | //mediaPlayerState->setPlaying( false ); |
91 | } else { | 90 | } else { |
92 | // play again | 91 | // play again |
93 | } | 92 | } |
94 | } | 93 | } |
95 | 94 | ||
95 | /** | ||
96 | * Pause playback | ||
97 | * @isSet | ||
98 | */ | ||
96 | void XineControl::pause( bool isSet) { | 99 | void XineControl::pause( bool isSet) { |
97 | libXine->pause(); | 100 | libXine->pause(); |
98 | } | 101 | } |
99 | 102 | ||
103 | |||
104 | /** | ||
105 | * get current time in playback | ||
106 | */ | ||
100 | long XineControl::currentTime() { | 107 | long XineControl::currentTime() { |
101 | // todo: jede sekunde überprüfen | 108 | // todo: jede sekunde überprüfen |
102 | m_currentTime = libXine->currentTime(); | 109 | m_currentTime = libXine->currentTime(); |
103 | return m_currentTime; | 110 | return m_currentTime; |
104 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 111 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
105 | } | 112 | } |
106 | 113 | ||
114 | /** | ||
115 | * Set the length of the media file | ||
116 | */ | ||
107 | void XineControl::length() { | 117 | void XineControl::length() { |
108 | m_length = libXine->length(); | 118 | m_length = libXine->length(); |
109 | mediaPlayerState->setLength( m_length ); | 119 | mediaPlayerState->setLength( m_length ); |
110 | } | 120 | } |
111 | 121 | ||
122 | |||
123 | /** | ||
124 | * Reports the position the xine backend is at right now | ||
125 | * @return long the postion in seconds | ||
126 | */ | ||
112 | long XineControl::position() { | 127 | long XineControl::position() { |
113 | m_position = ( currentTime() ); | 128 | m_position = ( currentTime() ); |
114 | mediaPlayerState->updatePosition( m_position ); | 129 | mediaPlayerState->updatePosition( m_position ); |
115 | long emitPos = (long)m_position; | 130 | long emitPos = (long)m_position; |
116 | emit positionChanged( emitPos ); | 131 | emit positionChanged( emitPos ); |
117 | if(mediaPlayerState->isPlaying) | 132 | if(mediaPlayerState->isPlaying) |
118 | // needs to be stopped the media is stopped | 133 | // needs to be stopped the media is stopped |
119 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 134 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
120 | // qDebug("POSITION : %d", m_position); | 135 | // qDebug("POSITION : %d", m_position); |
121 | return m_position; | 136 | return m_position; |
122 | } | 137 | } |
123 | 138 | ||
139 | /** | ||
140 | * Set videoplayback to fullscreen | ||
141 | * @param isSet | ||
142 | */ | ||
124 | void XineControl::setFullscreen( bool isSet ) { | 143 | void XineControl::setFullscreen( bool isSet ) { |
125 | libXine->showVideoFullScreen( isSet); | 144 | libXine->showVideoFullScreen( isSet); |
126 | } | 145 | } |
127 | 146 | ||
147 | /** | ||
148 | * Seek to a position in the track | ||
149 | * @param second the second to jump to | ||
150 | */ | ||
128 | void XineControl::seekTo( long second ) { | 151 | void XineControl::seekTo( long second ) { |
129 | qDebug("seek triggered!!"); | ||
130 | libXine->play( m_fileName , 0, (int)second ); | 152 | libXine->play( m_fileName , 0, (int)second ); |
131 | } | 153 | } |
132 | 154 | ||
133 | 155 | void XineControl::videoResized ( const QSize &s ) { | |
134 | void XineControl::videoResized ( const QSize &s ) | ||
135 | { | ||
136 | libXine-> resize ( s ); | 156 | libXine-> resize ( s ); |
137 | } | 157 | } |