summaryrefslogtreecommitdiff
path: root/noncore
authorharlekin <harlekin>2002-10-01 15:36:31 (UTC)
committer harlekin <harlekin>2002-10-01 15:36:31 (UTC)
commit657eeb18141838eeb0d18351a6755d7fa686f9d9 (patch) (side-by-side diff)
tree049c19f776543aee296ce0cd3a1fde8c37ec374b /noncore
parentbba0335bbea81519beafb7fec1979a0abbd8a7ea (diff)
downloadopie-657eeb18141838eeb0d18351a6755d7fa686f9d9.zip
opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.gz
opie-657eeb18141838eeb0d18351a6755d7fa686f9d9.tar.bz2
mediadetect no longer needed, also beginning of id3 etc tag info support along with some other small fixes
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp39
-rw-r--r--noncore/multimedia/opieplayer2/lib.h28
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp79
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h32
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro4
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp109
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h14
8 files changed, 229 insertions, 101 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 620c71f..a6fd334 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -53,17 +53,17 @@ extern MediaPlayerState *mediaPlayerState;
extern PlayListWidget *playList;
static const int xo = -2; // movable x offset
static const int yo = 22; // movable y offset
Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
setFrameStyle( WinPanel | Sunken );
- setText( "No Song" );
+ //setText( "No Song" );
}
Ticker::~Ticker() {
}
void Ticker::setText( const QString& text ) {
pos = 0; // reset it everytime the text is changed
scrollText = text;
@@ -455,30 +455,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
audioButtons[i].isHeld = FALSE;
if ( !audioButtons[i].isToggle ) {
setToggleButton( i, FALSE );
}
qDebug("mouseEvent %d", i);
switch (i) {
case AudioPlay:
if( mediaPlayerState->isPaused ) {
-// setToggleButton( i, FALSE );
mediaPlayerState->setPaused( FALSE );
return;
} else if( !mediaPlayerState->isPaused ) {
-// setToggleButton( i, TRUE );
mediaPlayerState->setPaused( TRUE );
return;
- } else {
- // setToggleButton( i, TRUE );
- // mediaPlayerState->setPlaying( videoButtons[i].isDown );
}
case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
- case AudioNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
- case AudioPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
+ case AudioNext: if( playList->whichList() ==0 ) mediaPlayerState->setNext(); return;
+ case AudioPrevious: if( playList->whichList() ==0 ) mediaPlayerState->setPrev(); return;
case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
case AudioVolumeUp: emit moreReleased(); return;
case AudioVolumeDown: emit lessReleased(); return;
case AudioPlayList: mediaPlayerState->setList(); return;
case AudioForward: emit forwardReleased(); return;
case AudioBack: emit backReleased(); return;
}
}
@@ -503,17 +498,17 @@ void AudioWidget::showEvent( QShowEvent* ) {
}
void AudioWidget::closeEvent( QCloseEvent* ) {
mediaPlayerState->setList();
}
-void AudioWidget::paintEvent( QPaintEvent * pe) {
+void AudioWidget::paintEvent( QPaintEvent * pe ) {
if ( !pe->erased() ) {
// Combine with background and double buffer
QPixmap pix( pe->rect().size() );
QPainter p( &pix );
p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
@@ -575,25 +570,13 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
// toggleButton(3);
break;
case Key_Left:
// toggleButton(4);
mediaPlayerState->setPrev();
// toggleButton(4);
break;
case Key_Escape: {
-/*
- * author pleas tell me where the i come from .-)
- #if defined(QT_QWS_IPAQ)
- if( mediaPlayerState->isPaused ) {
- setToggleButton( i, FALSE );
- mediaPlayerState->setPaused( FALSE );
- } else if( !mediaPlayerState->isPaused ) {
- setToggleButton( i, TRUE );
- mediaPlayerState->setPaused( TRUE );
- }
-#endif
-*/
}
break;
};
}
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index 4021d4a..85030de 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -145,17 +145,19 @@ int Lib::minorVersion() {
int Lib::subVersion() {
xine_get_version ( &m_major_version, &m_minor_version, &m_sub_version );
return m_sub_version;
}
int Lib::play( const QString& fileName, int startPos, int start_time ) {
QString str = fileName.stripWhiteSpace();
- xine_open( m_xine, QFile::encodeName(str.utf8() ).data() );
+ if ( !xine_open( m_xine, QFile::encodeName(str.utf8() ).data() ) ) {
+ return 0;
+ }
return xine_play( m_xine, startPos, start_time);
}
void Lib::stop() {
qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>");
xine_stop( m_xine );
}
@@ -186,58 +188,78 @@ int Lib::currentTime() {
}
int Lib::length() {
xine_get_pos_length( m_xine, &m_pos, &m_time, &m_length );
return m_length/1000;
}
bool Lib::isSeekable() {
- return xine_get_stream_info ( m_xine, XINE_STREAM_INFO_SEEKABLE );
+ return xine_get_stream_info( m_xine, XINE_STREAM_INFO_SEEKABLE );
+}
+
+void Lib::seekTo( int time ) {
+// xine_trick_mode ( m_xine, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_(
+ xine_play( m_xine, 0, time );
}
+
Frame Lib::currentFrame() {
Frame frame;
return frame;
};
-QString Lib::metaInfo() {
- xine_get_meta_info( m_xine, 0 );
+QString Lib::metaInfo( int number) {
+ return xine_get_meta_info( m_xine, number );
}
int Lib::error() {
return xine_get_error( m_xine );
};
void Lib::handleXineEvent( xine_event_t* t ) {
if ( t->type == XINE_EVENT_PLAYBACK_FINISHED ) {
emit stopped();
}
}
void Lib::setShowVideo( bool video ) {
m_video = video;
- ::null_set_show_video( m_videoOutput, video );
+ ::null_set_show_video( m_videoOutput, video );
}
bool Lib::isShowingVideo() {
return ::null_is_showing_video( m_videoOutput );
}
+bool Lib::hasVideo() {
+ //looks like it is not implemented yet
+ //return xine_get_stream_info( m_xine, XINE_STREAM_INFO_VIDEO_CHANNELS );
+ // ugly hack until xine is ready, look for the width of the video
+ int test = xine_get_stream_info( m_xine, 2 );
+ if( test > 0 ) {
+ // qDebug( QString(" has video: %1").arg( test ) );
+ return true;
+ } else {
+ //qDebug ( "does not have video ");
+ return false;
+ }
+}
+
void Lib::showVideoFullScreen( bool fullScreen ) {
::null_set_fullscreen( m_videoOutput, fullScreen );
}
bool Lib::isVideoFullScreen() {
return ::null_is_fullscreen( m_videoOutput );
}
void Lib::setScaling( bool scale ) {
- ::null_set_scaling( m_videoOutput, scale );
+ ::null_set_scaling( m_videoOutput, scale );
}
void Lib::setGamma( int value ) {
//qDebug( QString( "%1").arg(value) );
::null_set_videoGamma( m_videoOutput, value );
}
bool Lib::isScaling() {
@@ -245,21 +267,18 @@ bool Lib::isScaling() {
}
void Lib::xine_event_handler( void* user_data, xine_event_t* t ) {
( (Lib*)user_data)->handleXineEvent( t );
}
void Lib::xine_display_frame( void* user_data, uint8_t *frame,
int width, int height, int bytes ) {
- ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
+ ( (Lib*)user_data)->drawFrame( frame, width, height, bytes );
}
void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
if ( !m_video ) {
qWarning("not showing video now");
return;
}
-
-// qWarning( "called draw frame %d %d", width, height );
-
m_wid-> setVideoFrame ( frame, width, height, bytes );
}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index 29adc4d..6cdd9c6 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -112,26 +112,46 @@ namespace XINE {
/**
*
*/
bool isVideoFullScreen()/*const*/ ;
/**
* Get the meta info (like author etc) from the stream
- *
+ * XINE_META_INFO_TITLE 0
+ * XINE_META_INFO_COMMENT 1
+ * XINE_META_INFO_ARTIST 2
+ * XINE_META_INFO_GENRE 3
+ * XINE_META_INFO_ALBUM 4
+ * XINE_META_INFO_YEAR 5
+ * XINE_META_INFO_VIDEOCODEC 6
+ * XINE_META_INFO_AUDIOCODEC 7
+ * XINE_META_INFO_SYSTEMLAYER 8
+ * XINE_META_INFO_INPUT_PLUGIN 9
*/
- QString metaInfo() ;
+ QString metaInfo( int number );
/**
*
*/
bool isScaling();
/**
+ * seek to a position
+ */
+ void seekTo( int time );
+
+ /**
+ *
+ * @return is media stream has video
+ */
+ bool hasVideo();
+
+ /**
*
*/
void setScaling( bool );
/**
* Set the Gamma value for video output
* @param int the value between -100 and 100, 0 is original
*/
@@ -139,16 +159,20 @@ namespace XINE {
/**
* test
*/
Frame currentFrame()/*const*/;
/**
* Returns the error code
+ * XINE_ERROR_NONE 0
+ * XINE_ERROR_NO_INPUT_PLUGIN 1
+ * XINE_ERROR_NO_DEMUXER_PLUGIN 2
+ * XINE_ERROR_DEMUXER_FAILED 3
*/
int error() /*const*/;
signals:
void stopped();
private:
int m_bytes_per_pixel;
int m_length, m_pos, m_time;
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 553e3c1..8da7f73 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -31,17 +31,17 @@ extern MediaPlayerState *mediaPlayerState;
#define FBIOBLANK 0x4611
MediaPlayer::MediaPlayer( QObject *parent, const char *name )
: QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
playList->setCaption(tr("OpiePlayer: Initializating"));
-
+
qApp->processEvents();
// QPEApplication::grabKeyboard(); // EVIL
connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
@@ -95,47 +95,60 @@ void MediaPlayer::setPlaying( bool play ) {
const DocLnk *playListCurrent = playList->current();
if ( playListCurrent != NULL ) {
currentFile = playListCurrent;
}
xineControl->play( currentFile->file() );
fileName = currentFile->name();
long seconds = mediaPlayerState->length();//
time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
- qDebug(time);
-
- } else { //if playing in file list.. play in a different way
- // random and looping settings enabled causes problems here,
- // since there is no selected file in the playlist, but a selected file in the file list,
- // so we remember and shutoff
+ //qDebug(time);
+
+ } else {
+ //if playing in file list.. play in a different way
+ // random and looping settings enabled causes problems here,
+ // since there is no selected file in the playlist, but a selected file in the file list,
+ // so we remember and shutoff
l = mediaPlayerState->looping();
- if(l)
+ if(l) {
mediaPlayerState->setLooping( false );
+ }
r = mediaPlayerState->shuffled();
- mediaPlayerState->setShuffled(false);
-
+ mediaPlayerState->setShuffled( false );
+
fileName = playList->currentFileListPathName();
- xineControl->play( fileName);
- long seconds = mediaPlayerState->length();//
+ xineControl->play( fileName );
+ long seconds = mediaPlayerState->length();
time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
- qDebug(time);
- if( fileName.left(4) != "http" )
- fileName = QFileInfo( fileName).baseName();
+ //qDebug(time);
+ if( fileName.left(4) != "http" ) {
+ fileName = QFileInfo( fileName ).baseName();
+ }
}
- if( fileName.left(4) == "http" )
- tickerText= tr( " File: " ) + fileName;
- else
- tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time;
+
+ if( fileName.left(4) == "http" ) {
+ if ( xineControl->getMetaInfo().isEmpty() ) {
+ tickerText = tr( " File: " ) + fileName;
+ } else {
+ tickerText = xineControl->getMetaInfo();
+ }
+ } else {
+ if ( xineControl->getMetaInfo().isEmpty() ) {
+ tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
+ } else {
+ tickerText = xineControl->getMetaInfo() + " Length: " + time + " ";
+ }
+ }
audioUI->setTickerText( tickerText );
}
void MediaPlayer::prev() {
- if(playList->whichList() == 0) { //if using the playlist
+ if( playList->whichList() == 0 ) { //if using the playlist
if ( playList->prev() ) {
play();
} else if ( mediaPlayerState->looping() ) {
if ( playList->last() ) {
play();
}
} else {
mediaPlayerState->setList();
@@ -187,95 +200,95 @@ const int yoff = 110;
void MediaPlayer::stopChangingVolume() {
killTimers();
// Get rid of the on-screen display stuff
drawnOnScreenDisplay = FALSE;
onScreenDisplayVolume = 0;
int w=0;
int h=0;
- if( !xineControl->hasVideo()) {
+ if( !xineControl->hasVideo() ) {
w = audioUI->width();
h = audioUI->height();
- audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
+ audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
} else {
w = videoUI->width();
h = videoUI->height();
- videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
+ videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
}
}
void MediaPlayer::timerEvent( QTimerEvent * ) {
if ( volumeDirection == +1 ) {
- volControl->incVol(2);
- } else if ( volumeDirection == -1 ) {
- volControl->decVol(2);
+ volControl->incVol( 2 );
+ } else if ( volumeDirection == -1 ) {
+ volControl->decVol( 2 );
}
// TODO FIXME
// huh??
unsigned int v= 0;
v = volControl->volume();
v = v / 10;
if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
return;
}
int w=0; int h=0;
- if( !xineControl->hasVideo()) {
+ if( !xineControl->hasVideo() ) {
w = audioUI->width();
h = audioUI->height();
if ( drawnOnScreenDisplay ) {
if ( onScreenDisplayVolume > v ) {
- audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
+ audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
}
}
drawnOnScreenDisplay = TRUE;
onScreenDisplayVolume = v;
QPainter p( audioUI );
p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
QFont f;
f.setPixelSize( 20 );
f.setBold( TRUE );
p.setFont( f );
p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
for ( unsigned int i = 0; i < 10; i++ ) {
if ( v > i ) {
- p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
+ p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
} else {
- p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
+ p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
}
}
} else {
w = videoUI->width();
h = videoUI->height();
if ( drawnOnScreenDisplay ) {
if ( onScreenDisplayVolume > v ) {
- videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
+ videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
}
}
drawnOnScreenDisplay = TRUE;
onScreenDisplayVolume = v;
QPainter p( videoUI );
p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
QFont f;
f.setPixelSize( 20 );
f.setBold( TRUE );
p.setFont( f );
- p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
+ p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
for ( unsigned int i = 0; i < 10; i++ ) {
if ( v > i ) {
p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
} else {
p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
}
}
@@ -322,12 +335,12 @@ void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
break;
}
}
void MediaPlayer::cleanUp() {// this happens on closing
Config cfg( "OpiePlayer" );
mediaPlayerState->writeConfig( cfg );
playList->writeConfig( cfg );
-
+
// QPEApplication::grabKeyboard();
// QPEApplication::ungrabKeyboard();
}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index 05be128..131db33 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -1,8 +1,40 @@
+ /*
+                This file is part of the Opie Project
+
+              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
+ Copyright (c) 2002 LJP <>
+ Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
+ =.
+ .=l.
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; Library General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the GNU
+  -_. . .   )=.  = Library General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+*/
#ifndef MEDIA_PLAYER_H
#define MEDIA_PLAYER_H
#include <qmainwindow.h>
#include <qframe.h>
#include <qpe/qlibrary.h>
#include <qpe/mediaplayerplugininterface.h>
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index 1b687a3..619d36d 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,18 +1,18 @@
TEMPLATE = app
#CONFIG = qt warn_on release
CONFIG = qt warn_on debug
DESTDIR = $(OPIEDIR)/bin
-HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\
+HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h \
videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \
frame.h lib.h xinevideowidget.h volumecontrol.h playlistwidgetgui.h\
alphablend.h yuv2rgb.h
SOURCES = main.cpp \
- playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\
+ playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp \
videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \
frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp volumecontrol.cpp \
playlistwidgetgui.cpp\
alphablend.c yuv2rgb.c yuv2rgb_arm.c yuv2rgb_arm4l.S
TARGET = opieplayer2
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lpthread -lopie -lxine
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index fabc9a5..c22822c 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -28,83 +28,89 @@
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qtimer.h>
+#include <qmessagebox.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include "xinecontrol.h"
#include "mediaplayerstate.h"
#include "videowidget.h"
extern MediaPlayerState *mediaPlayerState;
extern VideoWidget *videoUI;
XineControl::XineControl( QObject *parent, const char *name )
: QObject( parent, name ) {
+
libXine = new XINE::Lib(videoUI->vidWidget() );
- connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & )));
- connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
+ connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) );
+ connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
- connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
+ connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
disabledSuspendScreenSaver = FALSE;
}
XineControl::~XineControl() {
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( disabledSuspendScreenSaver ) {
disabledSuspendScreenSaver = FALSE;
// Re-enable the suspend mode
- QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
#endif
delete libXine;
}
void XineControl::play( const QString& fileName ) {
- hasVideoChannel=FALSE;
- hasAudioChannel=FALSE;
+ hasVideoChannel = FALSE;
+ hasAudioChannel = FALSE;
m_fileName = fileName;
//qDebug("<<FILENAME: " + fileName + ">>>>");
- libXine->play( fileName );
- mediaPlayerState->setPlaying( true );
- char whichGui = mdetect.videoOrAudio( fileName );
- if (whichGui == 'f') {
- qDebug("Nicht erkannter Dateityp");
+ if ( !libXine->play( fileName ) ) {
+ QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
return;
}
- if (whichGui == 'a') {
+ mediaPlayerState->setPlaying( true );
+
+ char whichGui;
+ // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
+ if ( !libXine->hasVideo() ) {
+ whichGui = 'a';
+ qDebug("HAS AUDIO");
libXine->setShowVideo( false );
- hasAudioChannel=TRUE;
+ hasAudioChannel = TRUE;
} else {
+ whichGui = 'v';
+ qDebug("HAS VIDEO");
libXine->setShowVideo( true );
- hasVideoChannel=TRUE;
+ hasVideoChannel = TRUE;
}
// determine if slider is shown
mediaPlayerState->setIsStreaming( !libXine->isSeekable() );
// which gui (video / audio)
mediaPlayerState->setView( whichGui );
-
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( !disabledSuspendScreenSaver ) {
disabledSuspendScreenSaver = TRUE;
// Stop the screen from blanking and power saving state
- QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
<< ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend );
}
#endif
length();
position();
}
@@ -112,49 +118,48 @@ void XineControl::nextMedia() {
mediaPlayerState->setNext();
}
void XineControl::setGamma( int value ) {
libXine->setGamma( value );
}
void XineControl::stop( bool isSet ) {
- if ( !isSet) {
- libXine->stop( );
+ if ( !isSet ) {
+ libXine->stop();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
if ( disabledSuspendScreenSaver ) {
disabledSuspendScreenSaver = FALSE;
// Re-enable the suspend mode
- QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
+ QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
}
#endif
-
}
}
/**
* Pause playback
* @isSet
*/
void XineControl::pause( bool isSet) {
- if (isSet) {
+ if ( isSet ) {
libXine->pause();
} else {
- libXine->play( m_fileName, 0, m_currentTime);
+ libXine->play( m_fileName, 0, m_currentTime );
}
}
/**
* get current time in playback
*/
long XineControl::currentTime() {
// todo: jede sekunde überprüfen
- m_currentTime = libXine->currentTime();
+ m_currentTime = libXine->currentTime();
return m_currentTime;
QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
}
/**
* Set the length of the media file
*/
void XineControl::length() {
@@ -163,38 +168,80 @@ void XineControl::length() {
}
/**
* Reports the position the xine backend is at right now
* @return long the postion in seconds
*/
long XineControl::position() {
- m_position = ( currentTime() );
- mediaPlayerState->updatePosition( m_position );
+ m_position = ( currentTime() );
+ mediaPlayerState->updatePosition( m_position );
long emitPos = (long)m_position;
emit positionChanged( emitPos );
- if(mediaPlayerState->isPlaying)
+ if( mediaPlayerState->isPlaying ) {
// needs to be stopped the media is stopped
- QTimer::singleShot( 1000, this, SLOT( position() ) );
-// qDebug("POSITION : %d", m_position);
+ QTimer::singleShot( 1000, this, SLOT( position() ) );
+ }
+ // qDebug("POSITION : %d", m_position);
return m_position;
}
/**
* Set videoplayback to fullscreen
* @param isSet
*/
void XineControl::setFullscreen( bool isSet ) {
- libXine->showVideoFullScreen( isSet);
+ libXine->showVideoFullScreen( isSet );
+}
+
+
+QString XineControl::getMetaInfo() {
+
+ QString returnString;
+
+ if ( !libXine->metaInfo( 0 ).isEmpty() ) {
+ returnString += tr( " Titel: " + libXine->metaInfo( 0 ) );
+ }
+
+ if ( !libXine->metaInfo( 1 ).isEmpty() ) {
+ returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
+ }
+
+ if ( !libXine->metaInfo( 2 ).isEmpty() ) {
+ returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
+ }
+
+ if ( !libXine->metaInfo( 3 ).isEmpty() ) {
+ returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
+ }
+
+ if ( !libXine->metaInfo( 4 ).isEmpty() ) {
+ returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
+ }
+
+ if ( !libXine->metaInfo( 5 ).isEmpty() ) {
+ returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
+ }
+ return returnString;
+}
+
+QString XineControl::getErrorCode() {
+ int errorCode = libXine->error();
+
+ if ( errorCode == 1 ) {
+ return tr( "No input plugin found for this media type" );
+ } else {
+ return tr( "Some other error" );
+ }
}
/**
* Seek to a position in the track
* @param second the second to jump to
*/
void XineControl::seekTo( long second ) {
- libXine->play( m_fileName , 0, (int)second );
+ libXine->seekTo( (int)second );
}
void XineControl::videoResized ( const QSize &s ) {
- libXine-> resize ( s );
+ libXine->resize( s );
}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 1de610b..b1300a8 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -30,17 +30,16 @@
Boston, MA 02111-1307, USA.
*/
#ifndef XINECONTROL_H
#define XINECONTROL_H
#include "lib.h"
-#include "mediadetect.h"
#include <qobject.h>
class XineControl : public QObject {
Q_OBJECT
public:
XineControl( QObject *parent = 0, const char *name =0 );
~XineControl();
@@ -72,28 +71,39 @@ public slots:
void length();
long position();
/**
* Proceed to the next media file in playlist
*/
void nextMedia();
+ /**
+ * Get as much info about the stream from xine as possible
+ */
+ QString getMetaInfo();
+
+ /**
+ * get the error code and "translate" it for the user
+ *
+ */
+ QString getErrorCode();
+
+
void videoResized ( const QSize &s );
/**
* Set the gamma value of the video output
* @param int value between -100 and 100, 0 is original
*/
void setGamma( int );
private:
XINE::Lib *libXine;
- MediaDetect mdetect;
long m_currentTime;
long m_position;
int m_length;
QString m_fileName;
bool disabledSuspendScreenSaver : 1;
bool hasVideoChannel : 1;
bool hasAudioChannel : 1;