summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.cpp9
-rw-r--r--noncore/multimedia/opieplayer3/mwindow.h1
-rw-r--r--noncore/multimedia/opieplayer3/playlist.cpp6
-rw-r--r--noncore/multimedia/opieplayer3/videowidget.cpp1
4 files changed, 14 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer3/mwindow.cpp b/noncore/multimedia/opieplayer3/mwindow.cpp
index 75d1490..0898c7b 100644
--- a/noncore/multimedia/opieplayer3/mwindow.cpp
+++ b/noncore/multimedia/opieplayer3/mwindow.cpp
@@ -1,410 +1,415 @@
/*
This file is part of the Opie Project
Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
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.
*/
#include "mwindow.h"
#include "playlist.h"
#include "audiowidget.h"
#include "videowidget.h"
#include "../opieplayer2/lib.h"
#include <opie2/oapplicationfactory.h>
#include <opie2/owidgetstack.h>
#include <opie2/ofileselector.h>
#include <opie2/odebug.h>
#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
#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)
{
checkLib();
- setCaption( QObject::tr("Opie Mediaplayer 3" ) );
+ setCaption(appTitle());
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);
m_l->addWidget(m_stack);
m_PosSlider = new QSlider(QSlider::Horizontal,m_MainBox);
m_l->addWidget(m_PosSlider);
m_PosSlider->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)));
m_VideoPlayer = new VideoWidget(m_stack);
m_stack->addWidget(m_VideoPlayer,stack_video);
connect(this,SIGNAL(sigPos(int)),m_VideoPlayer,SLOT(updatePos(int)));
connect(m_VideoPlayer,SIGNAL(videoclicked()),this,SLOT(slotVideoclicked()));
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;
m_stack->raiseWidget(stack_list);
m_LastItem = 0;
setupActions();
setupToolBar();
setupMenu();
setCentralWidget(m_MainBox );
}
void PMainWindow::slotListChanged(int count)
{
playersGroup->setEnabled(count>0);
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::InitializeInThread);
qApp->processEvents();
// m_PlayLib->ensureInitialized();
connect(m_PlayLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
}
}
PMainWindow::~PMainWindow()
{
if (m_PlayLib) {
m_PlayLib->stop();
delete m_PlayLib;
}
}
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::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_PosSlider->setEnabled(false);
hideVideo();
slotShowList();
+ setCaption(appTitle());
}
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->hide();
}
}
void PMainWindow::slotPlayCurrent()
{
if (!m_LastItem) {
if (m_PlayLib) m_PlayLib->stop();
m_PosSlider->setEnabled(false);
a_playAction->setOn(false);
hideVideo();
slotShowList();
+ setCaption(appTitle());
return;
}
m_CurrentPos = 0;
m_playList->setCurrentItem(m_LastItem);
m_uppos = 0;
m_PosSlider->setValue(0);
int result = 0;
if (!m_LastItem->isVideo()) {
hideVideo();
m_playing = true;
m_stack->raiseWidget(stack_audio);
result = m_AudioPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
} else {
m_playing = true;
setupVideo(a_ShowFull->isOn());
result = m_VideoPlayer->playFile(m_LastItem->Lnk(),m_PlayLib);
}
if (result<0) {
// fehler
return;
}
mediaWindowraised();
+ setCaption(appTitle()+" - "+m_LastItem->Lnk().name());
odebug << "Range: " << result << oendl;
m_PosSlider->setEnabled(true);
m_PosSlider->setRange(0,m_PlayLib->length());
m_PosSlider->setValue(m_PlayLib->currentTime());
QTimer::singleShot( 500, this, SLOT( slotCheckPos() ) );
}
void PMainWindow::slotPlayNext()
{
PlaylistItem*item = m_playList->nextItem(m_LastItem);
if (!item) return;
m_LastItem = item;
slotPlayCurrent();
}
void PMainWindow::slotGoNext()
{
m_LastItem = m_playList->nextItem(m_LastItem);
slotPlayCurrent();
}
void PMainWindow::slotPlayPrevious()
{
PlaylistItem*item = m_playList->prevItem(m_LastItem);
if (!item) return;
m_LastItem = item;
slotPlayCurrent();
}
void PMainWindow::slotStopped()
{
if (!m_playing) return;
odebug << "Slot stopped" << oendl;
m_playing = false;
slotGoNext();
}
void PMainWindow::slotCheckPos()
{
if (!m_playing) return;
if (!m_pressed) {
m_uppos = m_PlayLib->currentTime();
emit sigPos(m_uppos);
m_PosSlider->setValue(m_PlayLib->currentTime());
}
- QTimer::singleShot( 1000, this, SLOT( slotCheckPos() ) );
+ qApp->processEvents(100);
+ QTimer::singleShot( 900, this, SLOT( slotCheckPos() ) );
}
void PMainWindow::slotRemoveFiles()
{
if (m_playing||!m_playList->isVisible()) return;
PlaylistItem* Item = m_playList->currentItem();
slotShowList();
m_playList->removeFromList(Item);
}
void PMainWindow::setupActions()
{
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 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 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, 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)));
playersGroup->insert(a_playPrevious);
playersGroup->insert(a_playAction);
playersGroup->insert(a_playNext);
/* initial states of actions */
a_showPlaylist->setEnabled(false);
a_removeFiles->setEnabled(false);
a_ShowMedia->setEnabled(false);
playersGroup->setEnabled(false);
settingsGroup = new QActionGroup(this,"configgroup",false);
a_Scaleup = new QAction(tr("Scale videos larger"),Resource::loadIconSet( "fullscreen" ), 0, 0, this, 0, true );
connect(a_Scaleup,SIGNAL(toggled(bool)),this,SLOT(slot_scaleupToggled(bool)));
settingsGroup->insert(a_Scaleup);
}
void PMainWindow::setupToolBar()
{
setToolBarsMovable( false );
m_toolBar = new QToolBar( this );
//m_menuBar = new QMenuBar(m_toolBar);
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);
}
diff --git a/noncore/multimedia/opieplayer3/mwindow.h b/noncore/multimedia/opieplayer3/mwindow.h
index 5d011d5..3ea9a52 100644
--- a/noncore/multimedia/opieplayer3/mwindow.h
+++ b/noncore/multimedia/opieplayer3/mwindow.h
@@ -1,138 +1,139 @@
/*
This file is part of the Opie Project
Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
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 _mwindow_h
#define _mwindow_h
#include <qmainwindow.h>
#include <qpe/applnk.h>
#include <qaction.h>
namespace Opie {
namespace Ui {
class OWidgetStack;
class OFileSelector;
}
}
namespace XINE {
class Lib;
}
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" ); }
+ static QString appTitle() {return QString::fromLatin1("Opie Mediaplayer 3" ); }
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_PosSlider;
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;
QAction*a_Scaleup;
QActionGroup*playersGroup,*playlistOnly,*settingsGroup;
QToolBar*m_toolBar;
QPopupMenu *fileMenu,*dispMenu,*playMenu,*configMenu;
QMenuBar*m_menuBar;
XINE::Lib*m_PlayLib;
void setupActions();
void setupToolBar();
void setupMenu();
void checkLib();
void setupVideo(bool full);
void hideVideo();
bool m_playing:1;
bool m_pressed:1;
int m_uppos;
int m_CurrentPos;
PlaylistItem*m_LastItem;
void mediaWindowraised();
protected slots:
virtual void fileSelected(const DocLnk&);
virtual void slotAppendFiles();
virtual void slotRemoveFiles();
virtual void slotShowList();
virtual void slotPlayList();
virtual void slotPlayNext();
virtual void slotPlayPrevious();
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);
virtual void slotNewPos(int pos);
virtual void sliderPressed();
virtual void sliderReleased();
virtual void slot_scaleupToggled(bool);
signals:
void sigPos(int);
};
#endif
diff --git a/noncore/multimedia/opieplayer3/playlist.cpp b/noncore/multimedia/opieplayer3/playlist.cpp
index 2eb40e3..6f2e668 100644
--- a/noncore/multimedia/opieplayer3/playlist.cpp
+++ b/noncore/multimedia/opieplayer3/playlist.cpp
@@ -71,228 +71,232 @@ PlaylistItem::~PlaylistItem()
{
}
/* PlaylistView Methods */
PlaylistView::PlaylistView(QWidget *parent, const char *name)
: QListView(parent,name)
{
// columnLabels << tr("FullName");
columnLabels << tr(""); // icon
columnLabels << tr("File");
columnLabels << tr("Playtime");
columnLabels << tr("Artist");
columnLabels << tr("Album");
columnLabels << tr("Title");
columnLabels << tr("Type");
columnLabels << tr("Size");
for (QStringList::Iterator it = columnLabels.begin(); it != columnLabels.end(); ++it) {
addColumn(*it);
}
m_Infolib=0;
setAllColumnsShowFocus(true);
setSelectionMode(Single);
setSorting(-1);
m_lastItem = 0;
m_lastDir = QDir::homeDirPath();
}
PlaylistView::~PlaylistView()
{
if (m_Infolib) delete m_Infolib;
}
void PlaylistView::checkLib()
{
if (!m_Infolib) {
m_Infolib = new XINE::Lib(XINE::Lib::InitializeImmediately);
connect(m_Infolib,SIGNAL(stopped()),this,SLOT(slotDummyStop()));
m_Infolib->ensureInitialized();
}
}
void PlaylistView::slotDummyStop()
{
odebug << "void PlaylistView::slotDummyStop()" << oendl;
}
void PlaylistView::slotAddFile(const DocLnk&aLink)
{
QFileInfo f(aLink.file());
if (f.extension(FALSE).lower()=="m3u"||f.extension(FALSE).lower()=="pls") {
readPlayList(aLink.file());
} else {
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();
QString name = aName;
if (name.isEmpty()) {
name = fileInfo.fileName();
}
int i = m_Infolib->setfile(aFile.utf8().data());
/* realy! otherwise we get an "stopped" signal when playing! - I don't know why */
m_Infolib->stop();
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();
+ PlaylistItem*_it = currentItem();
+
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
m_lastItem->setText(COL_TYPE,codec);
// title
m_lastItem->setText(COL_TITLE,m_Infolib->metaInfo(0));
// artist
m_lastItem->setText(COL_ARTIST,m_Infolib->metaInfo(2));
// album
m_lastItem->setText(COL_ALBUM,m_Infolib->metaInfo(4));
int l = m_Infolib->length();
int h = l/3600;
l-=h*3600;
int m = l/60;
l-=m*60;
codec = "";
if (h>0) {
codec.sprintf("%2i:%2i:%2i h",h,m,l);
} else {
codec.sprintf("%02i:%02i m",m,l);
}
// time
m_lastItem->setText(COL_TIME,codec);
m_lastItem->Video(m_Infolib->hasVideo());
m_items.append(m_lastItem);
- setSelected(m_lastItem,true);
+ if (_it==NULL) {
+ 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;
}
readPlayList(fileName);
emit contentChanged(childCount());
}
void PlaylistView::readPlayList(const QString&fileName)
{
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]);
}
}
void PlaylistView::slotSaveAsM3u()
{
QStringList types;
QMap<QString, QStringList> mimeTypes;
types << "audio/x-mpegurl";
mimeTypes.insert("Playlists",types);
QString fileName= Opie::Ui::OFileDialog::getSaveFileName(Opie::Ui::OFileSelector::EXTENDED,
m_lastDir,"playlist.m3u", mimeTypes);
odebug << "Save as " << fileName << oendl;
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,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;
}
void PlaylistView::setCurrentItem(PlaylistItem*aItem)
{
setSelected(aItem,true);
}
diff --git a/noncore/multimedia/opieplayer3/videowidget.cpp b/noncore/multimedia/opieplayer3/videowidget.cpp
index 833ecb4..414400b 100644
--- a/noncore/multimedia/opieplayer3/videowidget.cpp
+++ b/noncore/multimedia/opieplayer3/videowidget.cpp
@@ -1,100 +1,101 @@
#include "videowidget.h"
#include "../opieplayer2/lib.h"
#include "../opieplayer2/threadutil.h"
#include "../opieplayer2/xinevideowidget.h"
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qlayout.h>
#include <qslider.h>
#include <qlabel.h>
VideoWidget::VideoWidget( QWidget * parent, const char * name, WFlags f)
:QWidget(parent,name,f)
{
m_xineLib = 0;
m_scaleUp = false;
m_MainLayout = new QVBoxLayout(this);
m_MainLayout->setAutoAdd(true);
m_Videodisplay = new XineVideoWidget(this,"videodisp");
connect(m_Videodisplay,SIGNAL(videoResized ( const QSize & )),this,SLOT(slot_Videoresized(const QSize&)));
connect(m_Videodisplay,SIGNAL(clicked()),this,SLOT(slotClicked()));
}
VideoWidget::~VideoWidget()
{
}
void VideoWidget::slotClicked()
{
emit videoclicked();
}
void VideoWidget::closeEvent(QCloseEvent*e)
{
}
void VideoWidget::fullScreen(bool /* how */)
{
}
int VideoWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
{
m_current = aLnk;
bool recon;
if (m_xineLib != aLib) {
if (m_xineLib) disconnect(m_xineLib);
m_xineLib = aLib;
if (aLib) m_xineLib->setWidget(m_Videodisplay);
}
if (!m_xineLib) {
return -1;
}
connect(m_xineLib,SIGNAL(stopped()),this,SLOT(slotStopped()));
m_xineLib->setWidget(m_Videodisplay);
m_xineLib->setShowVideo(true);
int res = m_xineLib->play(m_current.file());
vSize = m_xineLib->videoSize();
+
slot_Videoresized(m_Videodisplay->size());
odebug << "Xine play: " << res << oendl;
if (res != 1) {
return -2;
}
return m_xineLib->length();
}
void VideoWidget::stopPlaying()
{
if (m_xineLib) {
m_xineLib->stop();
}
}
void VideoWidget::slotStopped()
{
}
void VideoWidget::slot_Videoresized(const QSize&s)
{
if (m_xineLib) {
if (vSize.width()<s.width()&&vSize.height()<s.height()&&!m_scaleUp) {
m_xineLib->resize(vSize);
} else {
m_xineLib->resize(s);
}
}
}
void VideoWidget::scaleUp(bool how)
{
if (how == m_scaleUp) return;
m_scaleUp = how;
slot_Videoresized(m_Videodisplay->size());
m_Videodisplay->repaint();
}
void VideoWidget::updatePos(int /*val*/)
{
}