-rw-r--r-- | noncore/multimedia/opieplayer3/audiowidget.cpp | 33 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/audiowidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.cpp | 180 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/mwindow.h | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/opieplayer3.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.cpp | 131 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/playlist.h | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/videowidget.cpp | 39 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer3/videowidget.h | 4 |
9 files changed, 353 insertions, 66 deletions
diff --git a/noncore/multimedia/opieplayer3/audiowidget.cpp b/noncore/multimedia/opieplayer3/audiowidget.cpp index 7ba6274..b435c1b 100644 --- a/noncore/multimedia/opieplayer3/audiowidget.cpp +++ b/noncore/multimedia/opieplayer3/audiowidget.cpp @@ -14,75 +14,91 @@ AudioWidget::AudioWidget( QWidget * parent, const char * name, WFlags f) {
m_xineLib = 0;
m_MainLayout = new QVBoxLayout(this);
m_MainLayout->setAutoAdd(true);
m_InfoBox = new QTextView(this);
+#if 0
m_PosSlider = new QSlider(QSlider::Horizontal,this);
m_PosSlider->setTickInterval(60);
connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
m_pressed = false;
m_uppos=0;
+#endif
}
AudioWidget::~AudioWidget()
{
}
-void AudioWidget::slotNewPos(int pos)
+void AudioWidget::slotNewPos(int /* pos*/)
{
if (!m_xineLib) return;
+#if 0
if (m_uppos==pos) return;
m_xineLib->seekTo(pos);
+#endif
}
void AudioWidget::sliderPressed()
{
+#if 0
m_pressed = true;
+#endif
}
void AudioWidget::sliderReleased()
{
+#if 0
m_pressed = false;
+#endif
}
void AudioWidget::closeEvent(QCloseEvent*e)
{
odebug << "AudioWidget::closeEvent(QCloseEvent*e)" << oendl;
if (m_xineLib) {
m_xineLib->stop();
}
QWidget::closeEvent(e);
}
-void AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
+int AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
{
m_current = aLnk;
if (m_xineLib != aLib) {
- disconnect(m_xineLib);
+ if (m_xineLib) disconnect(m_xineLib);
m_xineLib = aLib;
}
if (!m_xineLib) {
- return;
+ return -1;
}
+#if 0
m_uppos=0;
m_PosSlider->setValue(0);
+#endif
m_xineLib->setShowVideo(false);
- m_xineLib->play(m_current.file());
+ int res = m_xineLib->play(m_current.file());
+ if (res != 1) {
+ return -2;
+ }
// title
QString title = m_xineLib->metaInfo(0);
// artist
QString artist = m_xineLib->metaInfo(2);
// album
QString album = m_xineLib->metaInfo(4);
int l = m_xineLib->length();
+ int tmp = l;
+#if 0
m_PosSlider->setRange(0,l);
+#endif
QString laenge="";
int h = l/3600;
l-=h*3600;
int m = l/60;
l-=m*60;
if (h>0) {
@@ -99,27 +115,32 @@ void AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib) QString text = "<qt>";
if (artist.length()) {
text+="<H2><center>"+artist+"</center></h2>";
}
if (title.length()) {
text+="<H2><center>"+title+"</center></h2>";
+ } else {
+ text+="<H2><center>"+m_current.name()+"</center></h2>";
}
if (album.length()) {
text+="<H2><center>"+album+"</center></h2>";
}
text+="<h3><center>"+laenge+"</center></h3>";
m_InfoBox->setText(text);
+ return tmp;
}
void AudioWidget::stopPlaying()
{
if (m_xineLib) {
m_xineLib->stop();
}
}
-void AudioWidget::updatePos(int val)
+void AudioWidget::updatePos(int /* val */)
{
+#if 0
if (m_pressed) return;
m_uppos = val;
m_PosSlider->setValue(val);
+#endif
}
diff --git a/noncore/multimedia/opieplayer3/audiowidget.h b/noncore/multimedia/opieplayer3/audiowidget.h index 07b51b6..5e5dc09 100644 --- a/noncore/multimedia/opieplayer3/audiowidget.h +++ b/noncore/multimedia/opieplayer3/audiowidget.h @@ -18,26 +18,28 @@ class AudioWidget:public QWidget {
Q_OBJECT
public:
AudioWidget( QWidget * parent=0, const char * name=0, WFlags f=0 );
virtual ~AudioWidget();
- void playFile(const DocLnk&,XINE::Lib*);
+ int playFile(const DocLnk&,XINE::Lib*);
public slots:
virtual void stopPlaying();
virtual void updatePos(int);
protected:
XINE::Lib*m_xineLib;
DocLnk m_current;
QVBoxLayout*m_MainLayout;
QTextView*m_InfoBox;
+#if 0
QSlider*m_PosSlider;
bool m_pressed;
int m_uppos;
+#endif
protected slots:
virtual void closeEvent(QCloseEvent*e);
virtual void slotNewPos(int pos);
virtual void sliderPressed();
virtual void sliderReleased();
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp index dab910a..57418f0 100644 --- a/noncore/multimedia/opieplayer3/mwindow.cpp +++ b/noncore/multimedia/opieplayer3/mwindow.cpp @@ -47,31 +47,38 @@ #include <qfileinfo.h>
#include <qfile.h>
#include <qtoolbar.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qtimer.h>
+#include <qslider.h>
+#include <qlayout.h>
OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
using namespace Opie::Ui;
PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f)
: QMainWindow(w,name,f)
{
setCaption( QObject::tr("Opie Mediaplayer 3" ) );
- setupActions();
- setupToolBar();
- setupMenu();
- m_stack = new OWidgetStack(this);
+ m_MainBox = new QWidget(this);
+
+ QVBoxLayout*m_l = new QVBoxLayout(m_MainBox);
+
+ m_stack = new OWidgetStack(m_MainBox);
m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
- setCentralWidget(m_stack );
+ m_l->addWidget(m_stack);
+ m_scrollBar = new QSlider(QSlider::Horizontal,m_MainBox);
+ m_l->addWidget(m_scrollBar);
+ m_scrollBar->setEnabled(false);
+
m_playList = new PlaylistView(m_stack,"playlist");
m_stack->addWidget(m_playList,stack_list);
-
+ connect(m_playList,SIGNAL(contentChanged(int)),this,SLOT(slotListChanged(int)));
m_sfl = new OFileSelector("video/*;audio/*",m_stack);
m_stack->addWidget(m_sfl,stack_file);
connect(m_sfl, SIGNAL(fileSelected(const DocLnk &)), m_playList, SLOT(slotAddFile(const DocLnk &)));
m_AudioPlayer = new AudioWidget(m_stack);
m_stack->addWidget(m_AudioPlayer,stack_audio);
connect(this,SIGNAL(sigPos(int)),m_AudioPlayer,SLOT(updatePos(int)));
@@ -80,12 +87,34 @@ PMainWindow::PMainWindow(QWidget*w, const char*name, WFlags f) connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int)));
connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
m_stack->raiseWidget(stack_list);
m_PlayLib = 0;
m_LastItem = 0;
+ setupActions();
+ setupToolBar();
+ setupMenu();
+
+ setCentralWidget(m_MainBox );
+}
+
+void PMainWindow::slotListChanged(int count)
+{
+ if (!m_playList->isVisible()) {
+ return;
+ }
+ a_removeFiles->setEnabled(count>0);
+}
+
+void PMainWindow::mediaWindowraised()
+{
+ playlistOnly->setEnabled(false);
+ a_appendFiles->setEnabled(true);
+ a_loadPlaylist->setEnabled(true);
+ a_showPlaylist->setEnabled(true);
+ a_ShowMedia->setEnabled(false);
}
void PMainWindow::checkLib()
{
if (m_PlayLib == 0) {
m_PlayLib = new XINE::Lib(XINE::Lib::InitializeImmediately);
@@ -106,71 +135,136 @@ void PMainWindow::fileSelected(const DocLnk&) {
}
void PMainWindow::slotAppendFiles()
{
m_stack->raiseWidget(m_sfl);
+ playlistOnly->setEnabled(false);
+
+ a_showPlaylist->setEnabled(true);
+ if (m_PlayLib && m_playing) {
+ a_ShowMedia->setEnabled(true);
+ } else {
+ a_ShowMedia->setEnabled(false);
+ }
}
void PMainWindow::slotShowList()
{
m_stack->raiseWidget(m_playList);
+ playlistOnly->setEnabled(true);
+ a_showPlaylist->setEnabled(false);
+ if (m_playList->childCount()) {
+ a_removeFiles->setEnabled(true);
+ } else {
+ a_removeFiles->setEnabled(false);
+ }
+ if (m_PlayLib && m_playing) {
+ a_ShowMedia->setEnabled(true);
+ } else {
+ a_ShowMedia->setEnabled(false);
+ }
}
-void PMainWindow::slotPlayList()
+void PMainWindow::slotShowMediaWindow()
{
if (m_playing && m_LastItem && m_PlayLib) {
if (!m_LastItem->isVideo()) {
m_stack->raiseWidget(stack_audio);
} else {
m_stack->raiseWidget(stack_video);
}
+ mediaWindowraised();
+ return;
+ }
+}
+
+void PMainWindow::slotPlayList()
+{
+ if (m_playing && m_LastItem && m_PlayLib) {
+ slotShowMediaWindow();
return;
}
m_LastItem = m_playList->currentItem();
if (!m_LastItem) {
slotPlayNext();
return;
}
//m_VideoPlayer->setFullScreen(a_ShowFull->isOn());
slotPlayCurrent();
}
+void PMainWindow::slotUserStop()
+{
+ if (!m_playing || !m_PlayLib) return;
+ m_playing = false;
+ m_PlayLib->stop();
+ m_scrollBar->setEnabled(false);
+ hideVideo();
+ slotShowList();
+}
+
+void PMainWindow::slotTogglePlay(bool how)
+{
+ if (how == m_playing) {
+ if (how) {
+ slotShowMediaWindow();
+ }
+ return;
+ }
+ if (how) {
+ slotPlayList();
+ } else {
+ slotUserStop();
+ }
+}
+
void PMainWindow::hideVideo()
{
if (m_VideoPlayer->isVisible() && a_ShowFull->isOn()) {
- m_VideoPlayer->showNormal();
+ //m_VideoPlayer->showNormal();
m_VideoPlayer->hide();
}
}
void PMainWindow::slotPlayCurrent()
{
if (!m_LastItem) {
if (m_PlayLib) m_PlayLib->stop();
+ m_scrollBar->setEnabled(false);
+ a_playAction->setOn(false);
hideVideo();
- m_stack->raiseWidget(stack_list);
+ slotShowList();
return;
}
checkLib();
m_CurrentPos = 0;
m_playList->setCurrentItem(m_LastItem);
odebug << "Pos: " << m_PlayLib->currentTime() << oendl;
+ int result = 0;
if (!m_LastItem->isVideo()) {
hideVideo();
m_playing = true;
- QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
m_stack->raiseWidget(stack_audio);
- m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
+ result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
} else {
m_playing = true;
- QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
setupVideo(a_ShowFull->isOn());
- m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
+ result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
}
+ if (result<0) {
+ // fehler
+ return;
+ }
+ mediaWindowraised();
+ odebug << "Range: " << result << oendl;
+ m_scrollBar->setRange(0,result);
+ m_scrollBar->setValue(0);
+ m_scrollBar->setEnabled(true);
+ QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
}
void PMainWindow::slotPlayNext()
{
PlaylistItem*item = m_playList->nextItem(m_LastItem);
if (!item) return;
@@ -189,70 +283,81 @@ void PMainWindow::slotPlayPrevious() PlaylistItem*item = m_playList->prevItem(m_LastItem);
if (!item) return;
m_LastItem = item;
slotPlayCurrent();
}
-void PMainWindow::slotUserStop()
-{
- if (!m_playing || !m_PlayLib) return;
- m_playing = false;
- m_PlayLib->stop();
- hideVideo();
- m_stack->raiseWidget(stack_list);
-}
-
void PMainWindow::slotStopped()
{
if (!m_playing) return;
m_playing = false;
slotGoNext();
}
void PMainWindow::slotCheckPos()
{
if (!m_playing) return;
- emit sigPos(m_PlayLib->currentTime());
+ //emit sigPos(m_PlayLib->currentTime());
+ m_scrollBar->setValue(m_PlayLib->currentTime());
QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) );
}
void PMainWindow::slotRemoveFiles()
{
- slotUserStop();
+ if (m_playing||!m_playList->isVisible()) return;
PlaylistItem* Item = m_playList->currentItem();
- m_stack->raiseWidget(stack_list);
+ slotShowList();
m_playList->removeFromList(Item);
}
void PMainWindow::setupActions()
{
- a_appendFiles = new QAction(tr("Open file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false );
+ a_appendFiles = new QAction(tr("Append file(s)"),Resource::loadIconSet( "opieplayer2/add_to_playlist" ), 0, 0, this, 0, false );
connect(a_appendFiles,SIGNAL(activated()),this,SLOT(slotAppendFiles()));
+ a_addDir = new QAction(tr("Add directory"),Resource::loadIconSet("folder_open"),0,0,this,0,false);
+ connect(a_addDir,SIGNAL(activated()),m_playList,SLOT(slotAppendDir()));
+ a_loadPlaylist = new QAction(tr("Append .m3u playlist"),Resource::loadIconSet("opieplayer2/add_to_playlist"),0,0,this,0,false);
+ connect(a_loadPlaylist,SIGNAL(activated()),m_playList,SLOT(slotOpenM3u()));
+ a_savePlaylist = new QAction(tr("Save .m3u playlist"),Resource::loadIconSet("save"),0,0,this,0,false);
+ connect(a_savePlaylist,SIGNAL(activated()),m_playList,SLOT(slotSaveAsM3u()));
+
+ playlistOnly = new QActionGroup(this,"playlistgroup",false);
+ playlistOnly->insert(a_appendFiles);
+ playlistOnly->insert(a_addDir);
+ playlistOnly->insert(a_loadPlaylist);
+ playlistOnly->insert(a_savePlaylist);
+
a_showPlaylist = new QAction(tr("Show playlist"),Resource::loadIconSet( "txt" ), 0, 0, this, 0, false );
connect(a_showPlaylist,SIGNAL(activated()),this,SLOT(slotShowList()));
+ a_ShowMedia = new QAction(tr("Show media window"),Resource::loadIconSet("opieplayer2/musicfile"), 0, 0, this, 0, false );
+ connect(a_ShowMedia,SIGNAL(activated()),this,SLOT(slotShowMediaWindow()));
+
a_removeFiles = new QAction(tr("Remove file"),Resource::loadIconSet( "opieplayer2/remove_from_playlist" ), 0, 0, this, 0, false );
connect(a_removeFiles,SIGNAL(activated()),this,SLOT(slotRemoveFiles()));
playersGroup = new QActionGroup(this,"playgroup",false);
- a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, false );
- connect(a_playAction,SIGNAL(activated()),this,SLOT(slotPlayList()));
+ a_playAction = new QAction(tr("Play list"),Resource::loadIconSet( "opieplayer2/play" ), 0, 0, this, 0, true);
+ a_playAction->setOn(false);
+ connect(a_playAction,SIGNAL(toggled(bool)),this,SLOT(slotTogglePlay(bool)));
+
a_playNext = new QAction(tr("Play next in list"),Resource::loadIconSet( "fastforward" ), 0, 0, this, 0, false );
connect(a_playNext,SIGNAL(activated()),this,SLOT(slotPlayNext()));
a_playPrevious = new QAction(tr("Play previous in list"),Resource::loadIconSet( "fastback" ), 0, 0, this, 0, false );
connect(a_playPrevious,SIGNAL(activated()),this,SLOT(slotPlayPrevious()));
a_ShowFull = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true );
connect(a_ShowFull,SIGNAL(toggled(bool)),this,SLOT(slotToggleFull(bool)));
- a_stopPlay = new QAction(tr("Show videos fullscreen"),Resource::loadIconSet( "stop" ), 0, 0, this, 0, false );
- connect(a_stopPlay,SIGNAL(activated()),this,SLOT(slotUserStop()));
playersGroup->insert(a_playPrevious);
playersGroup->insert(a_playAction);
- playersGroup->insert(a_stopPlay);
playersGroup->insert(a_playNext);
- //playersGroup->insert(a_ShowFull);
+
+ /* initial states of actions */
+ a_showPlaylist->setEnabled(false);
+ a_removeFiles->setEnabled(false);
+ a_ShowMedia->setEnabled(false);
}
void PMainWindow::setupToolBar()
{
setToolBarsMovable( false );
m_toolBar = new QToolBar( this );
@@ -260,31 +365,33 @@ void PMainWindow::setupToolBar() m_menuBar=menuBar();
addToolBar(m_toolBar);
m_toolBar->setHorizontalStretchable( true );
a_appendFiles->addTo(m_toolBar);
a_removeFiles->addTo(m_toolBar);
a_showPlaylist->addTo(m_toolBar);
+ a_ShowMedia->addTo(m_toolBar);
a_ShowFull->addTo(m_toolBar);
playersGroup->addTo(m_toolBar);
}
void PMainWindow::setupVideo(bool full)
{
if (full) {
m_VideoPlayer->setBackgroundColor(black);
m_VideoPlayer->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
m_VideoPlayer->setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height());
m_VideoPlayer->showFullScreen();
+ connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
} else {
m_VideoPlayer->hide();
+ m_VideoPlayer->disconnect(this);
m_stack->addWidget(m_VideoPlayer,stack_video);
m_stack->raiseWidget(stack_video);
}
+ mediaWindowraised();
m_VideoPlayer->fullScreen(full);
- m_VideoPlayer->disconnect(this);
- connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
}
void PMainWindow::slotVideoclicked()
{
odebug << "PMainWindow::slotVideoclicked()" << oendl;
if (a_ShowFull->isOn()) {
@@ -305,16 +412,21 @@ void PMainWindow::slotToggleFull(bool how) void PMainWindow::setupMenu()
{
fileMenu = new QPopupMenu( m_menuBar );
m_menuBar->insertItem( tr( "Playlist" ), fileMenu );
a_appendFiles->addTo(fileMenu);
a_removeFiles->addTo(fileMenu);
+ a_addDir->addTo(fileMenu);
+ fileMenu->insertSeparator();
+ a_loadPlaylist->addTo(fileMenu);
+ a_savePlaylist->addTo(fileMenu);
dispMenu = new QPopupMenu( m_menuBar );
m_menuBar->insertItem( tr( "Show" ), dispMenu );
a_showPlaylist->addTo(dispMenu);
+ a_ShowMedia->addTo(dispMenu);
a_ShowFull->addTo(dispMenu);
playMenu = new QPopupMenu(m_menuBar);
m_menuBar->insertItem(tr("Playing"),playMenu);
playersGroup->addTo(playMenu);
}
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h index 28f820f..10c7a29 100644 --- a/noncore/multimedia/opieplayer3/mwindow.h +++ b/noncore/multimedia/opieplayer3/mwindow.h @@ -55,36 +55,42 @@ class PlaylistView; class QToolBar;
class QPopupMenu;
class QMenuBar;
class AudioWidget;
class VideoWidget;
class PlaylistItem;
+class QSlider;
class PMainWindow : public QMainWindow {
Q_OBJECT
public:
static QString appName() { return QString::fromLatin1("opie-mediaplayer3" ); }
PMainWindow(QWidget*, const char*, WFlags );
virtual ~PMainWindow();
public slots:
virtual void slotVideoclicked();
protected:
+
+ /* GUI parts */
static const int stack_list = 0;
static const int stack_file = 1;
static const int stack_audio = 2;
static const int stack_video = 3;
Opie::Ui::OWidgetStack *m_stack;
Opie::Ui::OFileSelector*m_sfl;
PlaylistView*m_playList;
AudioWidget*m_AudioPlayer;
VideoWidget*m_VideoPlayer;
+ QWidget*m_MainBox;
+ QSlider*m_scrollBar;
- QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_deleteItem,*a_stopAction;
- QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay;
- QActionGroup*playersGroup;
+ QAction*a_appendFiles,*a_removeFiles,*a_showPlaylist,*a_playAction,*a_stopAction;
+ QAction*a_playNext,*a_playPrevious,*a_ShowFull,*a_stopPlay,*a_ShowMedia;
+ QAction*a_addDir,*a_loadPlaylist,*a_savePlaylist;
+ QActionGroup*playersGroup,*playlistOnly;
QToolBar*m_toolBar;
QPopupMenu *fileMenu,*dispMenu,*playMenu;
QMenuBar*m_menuBar;
XINE::Lib*m_PlayLib;
void setupActions();
@@ -94,12 +100,13 @@ protected: void setupVideo(bool full);
void hideVideo();
bool m_playing:1;
int m_CurrentPos;
PlaylistItem*m_LastItem;
+ void mediaWindowraised();
protected slots:
virtual void fileSelected(const DocLnk&);
virtual void slotAppendFiles();
virtual void slotRemoveFiles();
virtual void slotShowList();
@@ -109,12 +116,15 @@ protected slots: virtual void slotPlayCurrent();
virtual void slotStopped();
virtual void slotCheckPos();
virtual void slotToggleFull(bool);
virtual void slotUserStop();
virtual void slotGoNext();
+ virtual void slotTogglePlay(bool);
+ virtual void slotShowMediaWindow();
+ virtual void slotListChanged(int);
signals:
void sigPos(int);
};
#endif
diff --git a/noncore/multimedia/opieplayer3/opieplayer3.pro b/noncore/multimedia/opieplayer3/opieplayer3.pro index 1c7149f..a5d5def 100644 --- a/noncore/multimedia/opieplayer3/opieplayer3.pro +++ b/noncore/multimedia/opieplayer3/opieplayer3.pro @@ -1,13 +1,13 @@ CONFIG = qt warn_on quick-app HEADERS = mwindow.h playlist.h ../opieplayer2/lib.h ../opieplayer2/threadutil.h \ - ../opieplayer2/alphablend.h ../opieplayer2/yuv2rgb.h \ + ../opieplayer2/alphablend.h ../opieplayer2/yuv2rgb.h ../opieplayer2/om3u.h \ audiowidget.h ../opieplayer2/xinevideowidget.h \ videowidget.h SOURCES = mwindow.cpp playlist.cpp ../opieplayer2/lib.cpp ../opieplayer2/threadutil.cpp \ - ../opieplayer2/nullvideo.c \ + ../opieplayer2/nullvideo.c ../opieplayer2/om3u.cpp \ ../opieplayer2/alphablend.c ../opieplayer2/yuv2rgb.c \ audiowidget.cpp ../opieplayer2/xinevideowidget.cpp \ videowidget.cpp ../opieplayer2/yuv2rgb_arm2.c ../opieplayer2/yuv2rgb_arm4l.S TARGET = opie-mediaplayer3 INCLUDEPATH += $(OPIEDIR)/include diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp index 272a71e..babe8ce 100644 --- a/noncore/multimedia/opieplayer3/playlist.cpp +++ b/noncore/multimedia/opieplayer3/playlist.cpp @@ -29,19 +29,26 @@ Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "playlist.h"
#include "../opieplayer2/lib.h"
+#include "../opieplayer2/om3u.h"
#include <opie2/odebug.h>
#include <opie2/oresource.h>
+#include <opie2/ofiledialog.h>
#include <qpe/resource.h>
#include <qfileinfo.h>
+#include <qmessagebox.h>
+#include <qdir.h>
+
+//#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.pls;*.m3u;*.mp4;*.m4a"
+#define DEFAULT_FILE_TYPES "*.mp3;*.ogg;*.ogm;*.wma;*.wav;*.asf;*.au;*.avi;*.mpeg;*.mpg;*.mv1;*.mov;*.wmv;*.mp4;*.m4a"
PlaylistItem::PlaylistItem(const DocLnk& aLink,PlaylistView*parent)
:QListViewItem(parent),m_Content(aLink),m_video(false)
{
}
@@ -82,12 +89,13 @@ PlaylistView::PlaylistView(QWidget *parent, const char *name) }
m_Infolib=0;
setAllColumnsShowFocus(true);
setSelectionMode(Single);
setSorting(-1);
m_lastItem = 0;
+ m_lastDir = QDir::homeDirPath();
}
PlaylistView::~PlaylistView()
{
if (m_Infolib) delete m_Infolib;
}
@@ -99,30 +107,62 @@ void PlaylistView::checkLib() m_Infolib->ensureInitialized();
}
}
void PlaylistView::slotAddFile(const DocLnk&aLink)
{
- QFileInfo fileInfo(aLink.file());
+ addFile(aLink.file(),aLink.name());
+ emit contentChanged(childCount());
+}
+
+void PlaylistView::addFile(const QString&aFile,const QString&aName)
+{
+ QFileInfo fileInfo(aFile);
if (!fileInfo.exists()) return;
checkLib();
-
m_Infolib->stop();
- if (m_lastItem) {
- m_lastItem = new PlaylistItem(aLink,this,m_lastItem);
- } else {
- m_lastItem = new PlaylistItem(aLink,this);
+ QString name = aName;
+ if (name.isEmpty()) {
+ name = fileInfo.fileName();
}
- m_lastItem->setExpandable(false);
- m_lastItem->setText(1,aLink.name());
- int i = m_Infolib->setfile(aLink.file());
- odebug << "File set: " << i << oendl;
+ int i = m_Infolib->setfile(aFile.utf8().data());
+ odebug << "File set: " << i << " ("<<aFile.utf8().data()<<")"<<oendl;
if (i<1) {
+ i = m_Infolib->error();
+ odebug << "Errorcode: " << i << oendl;
+ QString msg;
+ msg = QString(tr("Error open file %1: ")).arg(name);
+ switch (i) {
+ case 1:
+ msg += tr("No input plugin");
+ break;
+ case 2:
+ msg += tr("No demuxer plugin");
+ break;
+ case 3:
+ msg += tr("Demuxer failed");
+ break;
+ case 4:
+ msg+=tr("Malformed mrl");
+ break;
+ default:
+ msg += tr("Unknown error");
+ break;
+ }
+ QMessageBox::warning(0,tr("Error reading fileheader"),msg);
return;
}
+ m_lastItem = m_items.last();
+ if (m_lastItem) {
+ m_lastItem = new PlaylistItem(aFile,this,m_lastItem);
+ } else {
+ m_lastItem = new PlaylistItem(aFile,this);
+ }
+ m_lastItem->setExpandable(false);
+ m_lastItem->setText(1,name);
QString codec = m_Infolib->metaInfo(6);
if (codec.isEmpty()) {
codec = m_Infolib->metaInfo(7);
}
// codec
@@ -151,23 +191,92 @@ void PlaylistView::slotAddFile(const DocLnk&aLink) codec+=QString("%1 s").arg(l);
}
// time
m_lastItem->setText(COL_TIME,codec);
m_lastItem->Video(m_Infolib->hasVideo());
m_items.append(m_lastItem);
+ setSelected(m_lastItem,true);
+}
+
+void PlaylistView::slotAppendDir()
+{
+ QString _dir = Opie::Ui::OFileDialog::getDirectory(Opie::Ui::OFileSelector::Extended,m_lastDir,0,m_lastDir);
+ if (_dir.isEmpty()) return;
+ m_lastDir = _dir;
+ QDir sDir(_dir);
+ QStringList list = sDir.entryList(DEFAULT_FILE_TYPES,QDir::Files,QDir::Name | QDir::IgnoreCase);
+ for (unsigned i = 0; i < list.count();++i) {
+ addFile(_dir+QString("/")+list[i]);
+ }
+ emit contentChanged(childCount());
+}
+
+void PlaylistView::slotOpenM3u()
+{
+ QStringList types;
+ QMap<QString, QStringList> mimeTypes;
+ types << "audio/x-mpegurl";
+ mimeTypes.insert("Playlists",types);
+ mimeTypes.insert("All",types);
+ QString fileName= Opie::Ui::OFileDialog::getOpenFileName(Opie::Ui::OFileSelector::EXTENDED,
+ m_lastDir,"playlist.m3u", mimeTypes);
+ if (fileName.isEmpty()) {
+ return;
+ }
+ QFileInfo f(fileName);
+
+ Om3u _om3u(fileName, IO_ReadOnly);
+ if (f.extension(FALSE).lower()=="m3u") {
+ _om3u.readM3u();
+ } else if (f.extension(FALSE).lower()=="pls") {
+ _om3u.readPls();
+ }
+ for (unsigned int j=0; j<_om3u.count();++j) {
+ addFile(_om3u[j]);
+ }
+ emit contentChanged(childCount());
+}
+
+void PlaylistView::slotSaveAsM3u()
+{
+ QStringList types;
+ QMap<QString, QStringList> mimeTypes;
+ types << "audio/x-mpegurl";
+ mimeTypes.insert("Playlists",types);
+ mimeTypes.insert("All",types);
+ QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED,
+ m_lastDir,"playlist.m3u", mimeTypes);
+ if (fileName.isEmpty()) {
+ return;
+ }
+ Om3u _om3u(fileName, IO_ReadWrite | IO_Truncate);
+ for (unsigned j=0; j<m_items.count();++j) {
+ _om3u.add(m_items[j]->Lnk().file());
+ }
+ _om3u.write();
}
void PlaylistView::removeFromList(PlaylistItem*Item)
{
if (!Item)return;
- t_itemlist::Iterator iter;
+ t_itemlist::Iterator iter,it2;
iter = m_items.find(Item);
+ it2 = m_items.end();
if (iter!=m_items.end()) {
+ it2 = iter;
+ ++it2;
m_items.remove(iter);
}
delete Item;
+ if (it2!=m_items.end()) {
+ setSelected((*it2),true);
+ } else if (m_items.count()) {
+ QListViewItem * it = m_items.last();
+ setSelected(it,true);
+ }
+ emit contentChanged(childCount());
}
XINE::Lib*PlaylistView::getXine()
{
checkLib();
return m_Infolib;
diff --git a/noncore/multimedia/opieplayer3/playlist.h b/noncore/multimedia/opieplayer3/playlist.h index ad4c472..4a9268c 100644 --- a/noncore/multimedia/opieplayer3/playlist.h +++ b/noncore/multimedia/opieplayer3/playlist.h @@ -83,18 +83,26 @@ public: COL_ARTIST=3,
COL_ALBUM=4,
COL_TITLE=5,
COL_TYPE=6,
COL_SIZE=7
};
+ void addFile(const QString&aFile,const QString&aName="");
+signals:
+ void contentChanged(int);
+
public slots:
virtual void slotAddFile(const DocLnk&);
+ virtual void slotAppendDir();
+ virtual void slotOpenM3u();
+ virtual void slotSaveAsM3u();
protected:
void checkLib();
QStringList columnLabels;
XINE::Lib*m_Infolib;
PlaylistItem*m_lastItem;
t_itemlist m_items;
+ QString m_lastDir;
};
#endif
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp index c5c63c7..a28d47d 100644 --- a/noncore/multimedia/opieplayer3/videowidget.cpp +++ b/noncore/multimedia/opieplayer3/videowidget.cpp @@ -16,22 +16,26 @@ VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f) {
m_xineLib = 0;
m_MainLayout = new QVBoxLayout(this);
m_MainLayout->setAutoAdd(true);
m_Videodisplay = new XineVideoWidget(this,"videodisp");
+#if 0
m_PosSlider = new QSlider(QSlider::Horizontal,this);
m_PosSlider->setTickInterval(60);
connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
+#endif
connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&)));
connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked()));
+#if 0
m_pressed = false;
m_uppos=0;
+#endif
}
VideoWidget::~VideoWidget()
{
}
@@ -42,59 +46,76 @@ void VideoWidget::slotClicked() }
void VideoWidget::closeEvent(QCloseEvent*e)
{
}
-void VideoWidget::slotNewPos(int pos)
+void VideoWidget::slotNewPos(int /*pos*/)
{
+#if 0
if (!m_xineLib) return;
if (m_uppos==pos) return;
m_xineLib->seekTo(pos);
+#endif
}
void VideoWidget::sliderPressed()
{
+#if 0
m_pressed = true;
+#endif
}
void VideoWidget::sliderReleased()
{
+#if 0
m_pressed = false;
+#endif
}
-void VideoWidget::fullScreen(bool how)
+void VideoWidget::fullScreen(bool /* how */)
{
+#if 0
if (how) {
m_PosSlider->hide();
} else {
m_PosSlider->show();
}
+#endif
}
-void VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
+int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
{
m_current = aLnk;
+ bool recon;
if (m_xineLib != aLib) {
- disconnect(m_xineLib);
+ if (m_xineLib) disconnect(m_xineLib);
m_xineLib = aLib;
if (aLib) m_xineLib->setWidget(m_Videodisplay);
}
if (!m_xineLib) {
- return;
+ return -1;
}
connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
+#if 0
m_uppos=0;
m_PosSlider->setValue(0);
+#endif
m_xineLib->setWidget(m_Videodisplay);
m_xineLib->setShowVideo(true);
m_xineLib->resize(m_Videodisplay->size());
- m_xineLib->play(m_current.file());
- int l = m_xineLib->length();
+ int res = m_xineLib->play(m_current.file());
+ odebug << "Xine play: " << res << oendl;
+ if (res != 1) {
+ return -2;
+ }
+ return m_xineLib->length();
+#if 0
m_PosSlider->setRange(0,l);
m_PosSlider->setPageStep(l/10);
+#endif
}
void VideoWidget::stopPlaying()
{
if (m_xineLib) {
m_xineLib->stop();
@@ -111,12 +132,14 @@ void VideoWidget::slot_Videoresized(const QSize&s) odebug << "Videoresized: " << s << oendl;
if (m_xineLib) {
m_xineLib->resize(s);
}
}
-void VideoWidget::updatePos(int val)
+void VideoWidget::updatePos(int /*val*/)
{
+#if 0
if (m_pressed) return;
m_uppos = val;
m_PosSlider->setValue(val);
+#endif
}
diff --git a/noncore/multimedia/opieplayer3/videowidget.h b/noncore/multimedia/opieplayer3/videowidget.h index f181980..935a648 100644 --- a/noncore/multimedia/opieplayer3/videowidget.h +++ b/noncore/multimedia/opieplayer3/videowidget.h @@ -17,13 +17,13 @@ class VideoWidget:public QWidget {
Q_OBJECT
public:
VideoWidget( QWidget * parent=0, const char * name=0, WFlags f=0 );
virtual ~VideoWidget();
- void playFile(const DocLnk&,XINE::Lib*);
+ int playFile(const DocLnk&,XINE::Lib*);
void fullScreen(bool how);
signals:
void videoclicked();
public slots:
@@ -33,15 +33,17 @@ public slots: protected:
XINE::Lib*m_xineLib;
DocLnk m_current;
QVBoxLayout*m_MainLayout;
XineVideoWidget*m_Videodisplay;
QWidget * m_holder;
+#if 0
QSlider*m_PosSlider;
bool m_pressed:1;
int m_uppos;
+#endif
protected slots:
virtual void closeEvent(QCloseEvent*e);
virtual void slotNewPos(int pos);
virtual void sliderPressed();
virtual void sliderReleased();
|