00001 #include "videowidget.h"
00002 #include "../opieplayer2/lib.h"
00003 #include "../opieplayer2/threadutil.h"
00004 #include "../opieplayer2/xinevideowidget.h"
00005
00006 #include <opie2/odebug.h>
00007
00008 #include <qpe/qpeapplication.h>
00009
00010 #include <qlayout.h>
00011 #include <qslider.h>
00012 #include <qlabel.h>
00013
00014 VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f)
00015 :QWidget(parent,name,f)
00016 {
00017 m_xineLib = 0;
00018 m_scaleUp = false;
00019 m_MainLayout = new QVBoxLayout(this);
00020 m_MainLayout->setAutoAdd(true);
00021 m_Videodisplay = new XineVideoWidget(this,"videodisp");
00022 connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&)));
00023 connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked()));
00024 }
00025
00026 VideoWidget::~VideoWidget()
00027 {
00028 }
00029
00030 void VideoWidget::slotClicked()
00031 {
00032 emit videoclicked();
00033 }
00034
00035 void VideoWidget::closeEvent(QCloseEvent*e)
00036 {
00037 }
00038
00039 void VideoWidget::fullScreen(bool )
00040 {
00041 }
00042
00043 int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
00044 {
00045 m_current = aLnk;
00046 bool recon;
00047 if (m_xineLib != aLib) {
00048 if (m_xineLib) disconnect(m_xineLib);
00049 m_xineLib = aLib;
00050 if (aLib) m_xineLib->setWidget(m_Videodisplay);
00051 }
00052 if (!m_xineLib) {
00053 return -1;
00054 }
00055 connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
00056 m_xineLib->setWidget(m_Videodisplay);
00057 m_xineLib->setShowVideo(true);
00058 int res = m_xineLib->play(m_current.file());
00059 vSize = m_xineLib->videoSize();
00060
00061 slot_Videoresized(m_Videodisplay->size());
00062 odebug << "Xine play: " << res << oendl;
00063 if (res != 1) {
00064 return -2;
00065 }
00066 return m_xineLib->length();
00067 }
00068
00069 void VideoWidget::stopPlaying()
00070 {
00071 if (m_xineLib) {
00072 m_xineLib->stop();
00073 }
00074 }
00075
00076 void VideoWidget::slotStopped()
00077 {
00078 }
00079
00080 void VideoWidget::slot_Videoresized(const QSize&s)
00081 {
00082 if (m_xineLib) {
00083 if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) {
00084 m_xineLib->resize(vSize);
00085 } else {
00086 m_xineLib->resize(s);
00087 }
00088 }
00089 }
00090
00091 void VideoWidget::scaleUp(bool how)
00092 {
00093 if (how == m_scaleUp) return;
00094 m_scaleUp = how;
00095 slot_Videoresized(m_Videodisplay->size());
00096 m_Videodisplay->repaint();
00097 }
00098
00099 void VideoWidget::updatePos(int )
00100 {
00101 }