diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 84da08d7b7fcda12c85caeb5a10b4903770a6f69 (patch) | |
tree | 2a6aea76f2dfffb4cc04bb907c4725af94f70e72 /konq-plugins/sidebar/mediaplayer | |
download | tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.tar.gz tdeaddons-84da08d7b7fcda12c85caeb5a10b4903770a6f69.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konq-plugins/sidebar/mediaplayer')
23 files changed, 2151 insertions, 0 deletions
diff --git a/konq-plugins/sidebar/mediaplayer/AUTHORS b/konq-plugins/sidebar/mediaplayer/AUTHORS new file mode 100644 index 0000000..12b5dc2 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/AUTHORS @@ -0,0 +1,13 @@ +konqsidebarmediaplayer: +Joseph Wenninger <[email protected]> + + + +For the parts I took from kaboodle/noatun/...: + +Neil Stevens <[email protected]> +Charles Samuels <[email protected]> +Stefan Schimanski <[email protected]> +Malte Starostik <[email protected]> +Stefan Westerfeld <[email protected]> +Nikolas Zimmermann <[email protected]> diff --git a/konq-plugins/sidebar/mediaplayer/COPYING b/konq-plugins/sidebar/mediaplayer/COPYING new file mode 100644 index 0000000..5714d40 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/COPYING @@ -0,0 +1,12 @@ +There are some licenses involved in this small plugin: +1) konqsidebarplugin.h: LGPL +2) player.*, engine.* are taken from noatun/kaboodle/arts and have there own licenes. + Look in these projects for their licenses (At the time I write this I think they are licencesed under the BSD + license) + +3) All other files are copyrighted under the GPL + + +Joseph Wenninger <[email protected]> + +June 23rd 2001 diff --git a/konq-plugins/sidebar/mediaplayer/Makefile.am b/konq-plugins/sidebar/mediaplayer/Makefile.am new file mode 100644 index 0000000..12ba913 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/Makefile.am @@ -0,0 +1,33 @@ +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out +SUBDIRS = . pics + +# set the include path for X, qt and KDE +INCLUDES = -I$(kde_includes)/kio -I$(kde_includes)/arts $(all_includes) + +# these are the headers for your project +noinst_HEADERS = +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = konqsidebar_mediaplayer.la + +# the Part's source, library search path, and link libraries +konqsidebar_mediaplayer_la_SOURCES = mediawidget_skel.ui engine.cpp player.cpp mediawidget.cpp mediaplayer.cpp controls.cpp +konqsidebar_mediaplayer_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +konqsidebar_mediaplayer_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) -lkonqsidebarplugin -lqtmcop -lkmedia2_idl -lsoundserver_idl -lartskde + +globaladddir = $(kde_datadir)/konqsidebartng/add +globaladd_DATA = mplayer_add.desktop + +appsdir = $(kde_appsdir)/.hidden +apps_DATA = mediaplayerplugin.desktop + +mediawidget_skel.ui: mediawidget_skel_designer.ui + perl -p -e "s/QSlider/L33tSlider/" mediawidget_skel_designer.ui >mediawidget_skel.ui + +extendedclean: + rm mediawidget_skel.* + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/konqsidebar_mediaplayer.pot diff --git a/konq-plugins/sidebar/mediaplayer/controls.cpp b/konq-plugins/sidebar/mediaplayer/controls.cpp new file mode 100644 index 0000000..76671d5 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/controls.cpp @@ -0,0 +1,138 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#include "controls.h" + +L33tSlider::L33tSlider(QWidget * parent, const char * name) : + QSlider(parent,name), pressed(false) +{} +L33tSlider::L33tSlider(Orientation o, QWidget * parent, const char * name) : + QSlider(o,parent,name), pressed(false) +{} +L33tSlider::L33tSlider(int minValue, int maxValue, int pageStep, int value, + Orientation o, QWidget * parent, const char * name) : + QSlider(minValue, maxValue, pageStep, value, o, parent,name), pressed(false) +{} + +bool L33tSlider::currentlyPressed() const +{ + return pressed; +} + +void L33tSlider::setValue(int i) +{ + if (!pressed) + QSlider::setValue(i); +} + +void L33tSlider::mousePressEvent(QMouseEvent*e) +{ + if (e->button()!=RightButton) + { + pressed=true; + QSlider::mousePressEvent(e); + } +} + +void L33tSlider::mouseReleaseEvent(QMouseEvent*e) +{ + pressed=false; + QSlider::mouseReleaseEvent(e); + emit userChanged(value()); +} + +void L33tSlider::wheelEvent(QWheelEvent *e) +{ + QSlider::wheelEvent(e); + int newValue = value(); + + if(newValue < minValue()) + newValue = minValue(); + else if(newValue > maxValue()) + newValue = maxValue(); + + setValue(newValue); + emit userChanged(newValue); +} + +SliderAction::SliderAction(const QString& text, int accel, const QObject *receiver, + const char *member, QObject* parent, const char* name ) + : KAction( text, accel, parent, name ) +{ + m_receiver = receiver; + m_member = member; +} + +int SliderAction::plug( QWidget *w, int index ) +{ + if (!w->inherits("KToolBar")) return -1; + + KToolBar *toolBar = (KToolBar *)w; + int id = KAction::getToolButtonID(); + + //Create it. + m_slider=new L33tSlider(0, 1000, 100, 0, Horizontal, toolBar); + m_slider->setMinimumWidth(10); + toolBar->insertWidget(id, 10, m_slider, index ); + + + addContainer( toolBar, id ); + connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); + toolBar->setItemAutoSized( id, true ); + + if (w->inherits( "KToolBar" )) + connect(toolBar, SIGNAL(moved(KToolBar::BarPosition)), this, SLOT(toolbarMoved(KToolBar::BarPosition))); + + emit plugged(); + + return containerCount() - 1; +} + +void SliderAction::toolbarMoved(KToolBar::BarPosition) +{ +// I wish this worked :) +return; +/* + if (pos == KToolBar::Left || pos == KToolBar::Right) + { + m_slider->setOrientation(Vertical); + m_slider->setFixedWidth(m_slider->height()); + } + else + { + m_slider->setOrientation(Horizontal); + m_slider->resize(m_slider->height(), m_slider->height()); + } +*/ +} + +void SliderAction::unplug( QWidget *w ) +{ + KToolBar *toolBar = (KToolBar *)w; + int idx = findContainer( w ); + + toolBar->removeItem( itemId( idx ) ); + removeContainer( idx ); +} + +#include "controls.moc" diff --git a/konq-plugins/sidebar/mediaplayer/controls.h b/konq-plugins/sidebar/mediaplayer/controls.h new file mode 100644 index 0000000..d05a977 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/controls.h @@ -0,0 +1,93 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef __CONTROLS_H +#define __CONTROLS_H + +#include <qguardedptr.h> + +#include <kaction.h> +#include <ktoolbar.h> +#include <qslider.h> +#include <qstringlist.h> + +class QComboBox; +class QLabel; + +/** + * A slider that can be moved around while being + * changed internally + **/ +class L33tSlider : public QSlider +{ +Q_OBJECT +public: + L33tSlider(QWidget * parent, const char * name=0); + L33tSlider(Orientation, QWidget * parent, const char * name=0); + L33tSlider(int minValue, int maxValue, int pageStep, int value, + Orientation, QWidget * parent, const char * name=0); + + bool currentlyPressed() const; +signals: + /** + * emmited only when the user changes the value by hand + **/ + void userChanged(int value); + +public slots: + virtual void setValue(int); +protected: + virtual void mousePressEvent(QMouseEvent*); + virtual void mouseReleaseEvent(QMouseEvent*); + virtual void wheelEvent(QWheelEvent *e); + +private: + bool pressed; +}; + +/** + * A slider for your toolbar + **/ +class SliderAction : public KAction +{ +Q_OBJECT +public: + SliderAction(const QString& text, int accel, const QObject *receiver, + const char *member, QObject* parent, const char* name ); + virtual int plug( QWidget *w, int index = -1 ); + virtual void unplug( QWidget *w ); + QSlider* slider() const { return m_slider; } + +signals: + void plugged(); + +public slots: + void toolbarMoved(KToolBar::BarPosition pos); +private: + QGuardedPtr<QSlider> m_slider; + QStringList m_items; + const QObject *m_receiver; + const char *m_member; +}; + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/engine.cpp b/konq-plugins/sidebar/mediaplayer/engine.cpp new file mode 100644 index 0000000..cdb9486 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/engine.cpp @@ -0,0 +1,207 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +extern "C" +{ +#include <sys/wait.h> +} + +#include <kconfig.h> +#include <kdebug.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kmimetype.h> +#include <kstandarddirs.h> +#include <kurl.h> +#include <qtimer.h> +#include <qfile.h> +#include <qdir.h> + +#include <connect.h> +#include <dynamicrequest.h> +#include <flowsystem.h> +#include <kartsdispatcher.h> +#include <kartsserver.h> +#include <kplayobjectfactory.h> +#include <soundserver.h> + +#include "engine.h" +#include <string.h> + +using namespace std; + +class Engine::EnginePrivate +{ +public: + EnginePrivate() + : playobj(0) + , dispatcher() + , server() + { + } + + ~EnginePrivate() + { + delete playobj; + } + + KDE::PlayObject *playobj; + KArtsDispatcher dispatcher; + KArtsServer server; + KURL file; +}; + +Engine::Engine(QObject *parent) + : QObject(parent) + , d(new EnginePrivate) +{ +} + +Engine::~Engine() +{ + stop(); + delete d; +} + +bool Engine::load(const KURL &file) +{ + if(file.path().length()) + { + d->file = file; + return reload(); + } + else return false; +} + +bool Engine::reload(void) +{ + // Only You can prevent memory leaks + delete d->playobj; + d->playobj = 0; + + KDE::PlayObjectFactory factory(d->server.server()); + d->playobj = factory.createPlayObject(d->file, true); + + needReload = false; + + return !d->playobj->isNull(); +} + +void Engine::play() +{ + if(d->playobj) + { + switch(d->playobj->state()) + { + case Arts::posIdle: + if(needReload) + reload(); + d->playobj->play(); + break; + case Arts::posPaused: + d->playobj->play(); + break; + default: + break; + } + } +} + +void Engine::pause() +{ + if(d->playobj && !d->playobj->isNull()) + d->playobj->pause(); +} + +void Engine::stop() +{ + if(d->playobj && !d->playobj->isNull()) + { + d->playobj->halt(); + needReload = true; + } +} + +// pass time in msecs +void Engine::seek(unsigned long msec) +{ + Arts::poTime t; + + t.ms = (long) msec % 1000; + t.seconds = (long) ((long)msec - t.ms) / 1000; + + if(d->playobj && !d->playobj->isNull()) + d->playobj->seek(t); +} + +// return position in milliseconds +long Engine::position() +{ + if(!d->playobj || d->playobj->isNull()) return 0; + + Arts::poTime time(d->playobj->currentTime()); + return (time.ms + (time.seconds*1000)); +} + +// return track-length in milliseconds +unsigned long Engine::length() +{ + if(!d->playobj || d->playobj->isNull()) return 0; + + Arts::poTime time(d->playobj->overallTime()); + return (time.ms + (time.seconds*1000)); +} + +KMediaPlayer::Player::State Engine::state() +{ + if(!d->playobj || d->playobj->isNull()) return KMediaPlayer::Player::Empty; + + switch(d->playobj->state()) + { + case Arts::posIdle: + return KMediaPlayer::Player::Stop; + break; + case Arts::posPlaying: + return KMediaPlayer::Player::Play; + break; + case Arts::posPaused: + return KMediaPlayer::Player::Pause; + break; + default: + return KMediaPlayer::Player::Stop; + break; + } +} + +bool Engine::seekable(void) +{ + if(!d->playobj || d->playobj->isNull()) return false; + return d->playobj->capabilities() & Arts::capSeek; +} + +Arts::PlayObject Engine::playObject() const +{ + return d->playobj ? d->playobj->object() : Arts::PlayObject::null(); +} + +#include "engine.moc" diff --git a/konq-plugins/sidebar/mediaplayer/engine.h b/konq-plugins/sidebar/mediaplayer/engine.h new file mode 100644 index 0000000..1a5638f --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/engine.h @@ -0,0 +1,97 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef _ENGINE_H +#define _ENGINE_H + +#include <qobject.h> +#include <kmedia2.h> +#include <kmediaplayer/player.h> +#include <kurl.h> + +namespace Arts +{ +class PlayObject; +class SoundServerV2; +} + +/** + * Handles all playing, connecting to aRts. + * Does almost everything related to multimedia. + * Most interfacing should be done with Player + **/ +class Engine : public QObject +{ +Q_OBJECT + +public: + Engine(QObject *parent=0); + ~Engine(); + + Arts::PlayObject playObject() const; + +public slots: + /** + * Load a file + **/ + bool load(const KURL &file); + + /** + * Pause while playing + **/ + void pause(); + + /** + * Start + **/ + void play(); + + /** + * stops, and unloads + **/ + void stop(); + + /** + * skips to a time + **/ + void seek(unsigned long msec); + +public: + KMediaPlayer::Player::State state(); + long position(); // NOT unsigned + unsigned long length(); + + /** + * returns if the current track is seekable + */ + bool seekable(void); + +private: + bool reload(void); + bool needReload; + + class EnginePrivate; + EnginePrivate *d; +}; + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/mediaplayer.cpp b/konq-plugins/sidebar/mediaplayer/mediaplayer.cpp new file mode 100644 index 0000000..ce8d1af --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediaplayer.cpp @@ -0,0 +1,74 @@ +/*************************************************************************** + mediaplayer.cpp - The real sidebar plugin + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mediaplayer.h" +#include <klocale.h> +#include "mediaplayer.moc" +#include <kdebug.h> +#include <ksimpleconfig.h> +#include <kconfig.h> +#include <kstandarddirs.h> +#include <kmessagebox.h> +#include <kglobal.h> +#include <kdemacros.h> +#include "mediawidget.h" + +KonqSidebar_MediaPlayer::KonqSidebar_MediaPlayer(KInstance *instance,QObject *parent,QWidget *widgetParent, QString &desktopName_, const char* name): + KonqSidebarPlugin(instance,parent,widgetParent,desktopName_,name) + { + widget=new KSB_MediaWidget(widgetParent); + } + + +KonqSidebar_MediaPlayer::~KonqSidebar_MediaPlayer(){;} + +void* KonqSidebar_MediaPlayer::provides(const QString &) {return 0;} + +void KonqSidebar_MediaPlayer::emitStatusBarText (const QString &) {;} + +QWidget *KonqSidebar_MediaPlayer::getWidget(){return widget;} + +void KonqSidebar_MediaPlayer::handleURL(const KURL &/*url*/) + { + } + + + + +extern "C" +{ + KDE_EXPORT void* create_konqsidebar_mediaplayer(KInstance *instance,QObject *par,QWidget *widp,QString &desktopname,const char *name) + { + KGlobal::locale()->insertCatalogue("konqsidebar_mediaplayer"); + return new KonqSidebar_MediaPlayer(instance,par,widp,desktopname,name); + } +} + +extern "C" +{ + KDE_EXPORT bool add_konqsidebar_mediaplayer(QString* fn, QString* /*param*/, QMap<QString,QString> *map) + { + map->insert("Type","Link"); + map->insert("Icon","konqsidebar_mediaplayer"); + map->insert("Name",i18n("Media Player")); + map->insert("Open","false"); + map->insert("X-KDE-KonqSidebarModule","konqsidebar_mediaplayer"); + fn->setLatin1("mplayer%1.desktop"); + return true; + } +} + diff --git a/konq-plugins/sidebar/mediaplayer/mediaplayer.h b/konq-plugins/sidebar/mediaplayer/mediaplayer.h new file mode 100644 index 0000000..c563e20 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediaplayer.h @@ -0,0 +1,43 @@ +/*************************************************************************** + mediaplayer.h - The real sidebar plugin + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _konq_sidebar_mediaplayer_h_ +#define _konq_sidebar_mediaplayer_h_ +#include <konqsidebarplugin.h> +#include <kparts/part.h> +#include <kparts/factory.h> +#include <kparts/browserextension.h> + +class KSB_MediaWidget; + +class KonqSidebar_MediaPlayer: public KonqSidebarPlugin + { + Q_OBJECT + public: + KonqSidebar_MediaPlayer(KInstance *instance,QObject *parent,QWidget *widgetParent, QString &desktopName_, const char* name=0); + ~KonqSidebar_MediaPlayer(); + virtual void *provides(const QString &); + void emitStatusBarText (const QString &); + virtual QWidget *getWidget(); + protected: + virtual void handleURL(const KURL &url); + private: + KSB_MediaWidget *widget; + }; + + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/mediaplayerplugin.desktop b/konq-plugins/sidebar/mediaplayer/mediaplayerplugin.desktop new file mode 100644 index 0000000..110fd36 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediaplayerplugin.desktop @@ -0,0 +1,115 @@ +[Desktop Entry] +Name=Mediaplayer +Name[ar]=مشغل الوسائط المتعددة +Name[az]=Mediya çalğıcısı +Name[bg]=Медия плеър +Name[br]=Soner liesvedia +Name[ca]=Reproductor Multimèdia +Name[cs]=Přehrávač médií +Name[cy]=Chwaraewr Cyfryngau +Name[da]=Medieafspiller +Name[de]=Medienabspieler +Name[el]=Αναπαραγωγέας μέσων +Name[eo]=Medioludilo +Name[es]=Reproductor de medios +Name[et]=Meediafailide mängija +Name[eu]=Multimedia-erreproduzigailua +Name[fa]=پخشکنندۀ رسانه +Name[fi]=Mediasoitin +Name[fr]=Lecteur multimédia +Name[fy]=Mediaspiler +Name[he]=נגן מדיה +Name[hi]=मीडिया-प्लेयर +Name[hr]=Medijski program +Name[hu]=Médialejátszó +Name[is]=Margmiðlunarspilari +Name[it]=Multimedia +Name[ja]=メディアプレーヤ +Name[kk]=Медиа ойнатқышы +Name[km]=កម្មវិធីចាក់មេឌៀ +Name[mk]=Медијаплеер +Name[nb]=Mediaspiller +Name[nds]=Medienafspeler +Name[ne]=मिडियाप्लेएर +Name[nl]=Mediaspeler +Name[nn]=Mediespelar +Name[nso]=Sebapadi sa Media +Name[pa]=ਮੀਡਿਆਪਲੇਅਰ +Name[pl]=Odtwarzacz multimedialny +Name[pt_BR]=Reprodutor de Mídia +Name[ro]=Redare multimedia +Name[ru]=Медиаплеер +Name[sk]=Prehrávač médií +Name[sv]=Mediaspelare +Name[ta]=ஊடக இயக்கி +Name[tg]=Медиаплеер +Name[tr]=Çokluortam oynatıcı +Name[uz]=Media-pleyer +Name[uz@cyrillic]=Медиа-плейер +Name[vi]=Bộ phát nhạc/ảnh +Name[xh]=Umdlali wosasazo lwendaba +Name[zh_CN]=媒体播放器 +Name[zh_TW]=媒體播放器 +Comment=Mediaplayer plugin in Konqueror's navigation panel +Comment[ar]=ملحق يشغل الوسائط المتعددة في لوحة التنقل في كونكيورر +Comment[az]=Konqueror-un naviqasiya panelindəki mediya çalğıcı əlavəsi +Comment[bg]=Навигационен панел за плеър за мултимедийни файлове +Comment[bs]=Mediaplayer dodatak za Konqueror-ov navigatorski panel +Comment[ca]=Connector del reproductor multimèdia en el plafó de navegació de Konqueror +Comment[cs]=Přehrávací modul pro postranní lištu Konqueroru +Comment[cy]=Ategyn chwarae cyfryngau yn y panel morlywio Konqueror +Comment[da]=Medieafspiller-plugin i Konquerors navigationspanel +Comment[de]=Medienabspieler-Modul im Navigationsbereich von Konqueror +Comment[el]=Πρόσθετο αναπαραγωγέα μέσων στο πλαίσιο πλοήγησης του Konqueror +Comment[eo]=Medioludila kromaĵo en foliuma panelo de Konkeranto +Comment[es]=Complemento del reproductor de medios en el panel de navegación de Konqueror +Comment[et]=Meediafailide mängija plugin Konquerori navigeerimispaneelil +Comment[eu]=Konquerorren arakatze paneleko multimedia-erreproduzigailuaren plugina +Comment[fa]=وصلۀ پخشکنندۀ رسانه در تابلوی ناوش Konqueror +Comment[fi]=Mediasoitinsovelma Konquerorin navigaatiopaneeliin +Comment[fr]=Le module de lecteur multimédia pour la barre de navigation de Konqueror +Comment[fy]=Mediaspiler-plugin foar Konqueror's navigaasjepaneel +Comment[ga]=Breiseán Mediaplayer i bpainéal nascleanúna Konqueror +Comment[gl]=Un plugin de reproduición multimédia no painel de navegación de Konqueror +Comment[he]=תוסף נגן מדיה ללוח הניווט של Konqueror +Comment[hi]=कॉन्करर के नेविगेशन फलक में मीडियाप्लेयर प्लगइन +Comment[hr]=Medijski dodatak u navigacijskoj ploči Konquerora +Comment[hu]=Médialejátszó bővítőmodul a Konqueror navigációs paneljéhez +Comment[is]=Margmiðlunareining fyrir spjaldið í Konqueror +Comment[it]=Plugin multimediale nella barra di navigazione di Konqueror +Comment[ja]=Konqueror のナビゲーションパネル内のメディアプレーヤプラグイン +Comment[ka]=Mediaplayer მოდული Konqueror-ის ნავიგაციის პანელზე +Comment[kk]=Konqueror панеліндегі медиа ойнатқыш плагин модулі +Comment[km]=កម្មវិធីជំនួយរបស់កម្មវិធីចាក់មេឌៀនៅក្នុងបន្ទះរុករករបស់ Konqueror +Comment[lt]=Mediaplayer priedas Konqueror navigacijos pulte +Comment[mk]=Приклучок за медијаплеер во панелот за навигација на Konqueror +Comment[ms]=Plugin Mediaplayer dalam panel Pandu Arah Konqueror +Comment[nb]=Mediaspiller-modul til Konquerors navigasjonspanel +Comment[nds]=Medienafspeler-Moduul för dat Sietpaneel vun Konqueror +Comment[ne]=कन्क्वेररको नेभिगेसन प्यानलको मिडियाप्लेएर प्लगइन +Comment[nl]=Mediaspeler-plugin voor Konqueror's navigatiepaneel +Comment[nn]=Mediespelar-programtillegg til navigasjonspanelet i Konqueror +Comment[pl]=Wtyczka odtwarzacza multimediów w panelu nawigacyjnym Konquerora +Comment[pt]=Um 'plugin' de reprodução multimédia no painel de navegação do Konqueror +Comment[pt_BR]=plug-ins do reprodutor de mídia no painel de navegação do Konqueror +Comment[ro]=Modul de redare multimedia în panoul de navigare Konqueror +Comment[ru]=Модуль Konqueror для проигрывания мультимедиа +Comment[sk]=Mediaplayer modul v navigačnom panely Konquerora +Comment[sl]=Vstavek večpredstavnostnega predvajalnika v Konquerorjevi navigacijski plošči +Comment[sr]=Прикључак за медија плејер у Konqueror-овом навигационом панелу +Comment[sr@Latn]=Priključak za medija plejer u Konqueror-ovom navigacionom panelu +Comment[sv]=Instickprogram för mediaspelare i Konquerors sidopanel +Comment[ta]=கான்கொரர்ரின் நாவிகேஷன் பலகத்தில் உள்ள ஊடக இயக்கி சொருகுப்பொருள் +Comment[tg]=Модули Konqueror барои бозӣ кардани мултимедиа +Comment[tr]=Konqueror çokluortam oynatıcısı +Comment[uk]=Втулок програвача в панелі навігації Konqueror +Comment[uz]=Konqueror yon paneli uchun multimediya fayllarini oʻynash vositasi +Comment[uz@cyrillic]=Konqueror ён панели учун мультимедия файлларини ўйнаш воситаси +Comment[vi]=Bổ sung phát nhạc/ảnh trên bảng duyệt qua Konqueror +Comment[xh]=Umdlali wosasazo lwendaba zeplagi yangaphakathi seqela lenjongo ethile lolawulo lwe Konqueror +Comment[zh_CN]=Konqueror 的导航面板中的媒体播放器插件 +Comment[zh_TW]=在 Konqueror 導覽面板上的媒體播放器外掛程式 +Icon=konqsidebar_mediaplayer +X-KDE-ParentApp=konqueror +X-KDE-KonqSidebarUniversal=true +DocPath=konq-plugins/mediaplayer/index.html diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget.cpp b/konq-plugins/sidebar/mediaplayer/mediawidget.cpp new file mode 100644 index 0000000..c460c3c --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget.cpp @@ -0,0 +1,169 @@ +/*************************************************************************** + mediawidget.cpp - The main widget + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "mediawidget.h" +#include "mediawidget.moc" +#include "player.h" + +#include <kdebug.h> +#include <kurl.h> +#include <kurldrag.h> +#include <klocale.h> + +#include <qlabel.h> +#include <qwidget.h> +#include <qpushbutton.h> +#include <qlcdnumber.h> +#include <qpopupmenu.h> +#include <qslider.h> +#include <qtooltip.h> + +KSB_MediaWidget::KSB_MediaWidget(QWidget *parent):KSB_MediaWidget_skel(parent) +{ + player = new Player(this); + empty(); + + QFont labelFont = time->font(); + labelFont.setPointSize(18); + labelFont.setBold(true); + time->setFont(labelFont); + + connect(Play, SIGNAL(clicked()), player, SLOT(play())); + connect(Pause, SIGNAL(clicked()), player, SLOT(pause())); + connect(Stop, SIGNAL(clicked()), player, SLOT(stop())); + + connect(player, SIGNAL(timeout()), this, SLOT(playerTimeout())); + connect(player, SIGNAL(finished()), this, SLOT(playerFinished())); + connect(player, SIGNAL(playing()), this, SLOT(playing())); + connect(player, SIGNAL(paused()), this, SLOT(paused())); + connect(player, SIGNAL(stopped()), this, SLOT(stopped())); + connect(player, SIGNAL(empty()), this, SLOT(empty())); + + connect(Position, SIGNAL(userChanged(int)), this, SLOT(skipToWrapper(int))); + connect(this, SIGNAL(skipTo(unsigned long)), player, SLOT(skipTo(unsigned long))); + setAcceptDrops(true); + + pretty=""; + needLengthUpdate=false; + + QToolTip::add(Play,i18n("Play")); + QToolTip::add(Pause,i18n("Pause")); + QToolTip::add(Stop,i18n("Stop")); +} + +void KSB_MediaWidget::skipToWrapper(int second) +{ + emit skipTo((unsigned long)(second*1000)); +} + +void KSB_MediaWidget::dragEnterEvent ( QDragEnterEvent * e) +{ + e->accept(KURLDrag::canDecode(e)); +} + +void KSB_MediaWidget::dropEvent ( QDropEvent * e) +{ + m_kuri_list.clear(); + if (KURLDrag::decode(e, m_kuri_list)) + { + playerFinished(); + } +} + + +void KSB_MediaWidget::playerTimeout() +{ + if(player->current().isEmpty()) + return; + + if(Position->currentlyPressed()) + return; + +// update the scrollbar length + if(player->getLength()) + { + int range = (int)(player->getLength() / 1000); + Position->setRange(0, range); + if (needLengthUpdate) + { + int counter = player->lengthString().length() - (player->lengthString().find("/")+1); + QString length=player->lengthString().right(counter); + needLengthUpdate=false; + } + } + else + { + Position->setRange(0, 1); + } + // set the position + Position->setValue((int)(player->getTime() / 1000)); + + // update the time label + // catch files with duration > 99mins correctly + time->setText(player->lengthString()); +} + +void KSB_MediaWidget::playerFinished() +{ + if( m_kuri_list.count() > 0 ) + { + KURL kurl = m_kuri_list.first(); + m_kuri_list.remove( kurl ); + bool validFile = player->openFile( kurl ); + if (validFile) { + currentFile->setText( kurl.fileName() ); + player->play(); + needLengthUpdate=true; + pretty=kurl.prettyURL(); + } else { + currentFile->setText( i18n("Not a sound file") ); + playerFinished(); + } + } +} + +void KSB_MediaWidget::playing() +{ + Play->setEnabled(false); + Pause->setEnabled(true); + Stop->setEnabled(true); +} + +void KSB_MediaWidget::paused() +{ + Play->setEnabled(true); + Pause->setEnabled(false); + Stop->setEnabled(true); +} + +void KSB_MediaWidget::stopped() +{ + Position->setValue(0); + time->setText("00:00/00:00"); + Play->setEnabled(true); + Pause->setEnabled(false); + Stop->setEnabled(false); +} + +void KSB_MediaWidget::empty() +{ + Position->setValue(0); + time->setText("00:00/00:00"); + Play->setEnabled(false); + Pause->setEnabled(false); + Stop->setEnabled(false); +} diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget.h b/konq-plugins/sidebar/mediaplayer/mediawidget.h new file mode 100644 index 0000000..ff2137b --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget.h @@ -0,0 +1,57 @@ +/*************************************************************************** + mediawidget.h - The main widget + ------------------- + begin : Sat June 23 13:35:30 CEST 2001 + copyright : (C) 2001 Joseph Wenninger + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef _MEDIAWIDGET_H_ +#define _MEDIAWIDGET_H_ + +#include <kurl.h> +#include "mediawidget_skel.h" + +class KSB_MediaWidget: public KSB_MediaWidget_skel +{ + Q_OBJECT +public: + KSB_MediaWidget(QWidget *parent); + ~KSB_MediaWidget(){;} + +private: + class Player *player; + QString pretty; + bool needLengthUpdate; + KURL::List m_kuri_list; + +protected: + virtual void dragEnterEvent ( QDragEnterEvent * ); + virtual void dropEvent ( QDropEvent * ); + +private slots: + void playerTimeout(); + void playerFinished(); + void playing(); + void paused(); + void stopped(); + void empty(); + +public slots: + void skipToWrapper(int); + +signals: + void skipTo(unsigned long); + +}; + +#endif diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget_skel.ui b/konq-plugins/sidebar/mediaplayer/mediawidget_skel.ui new file mode 100644 index 0000000..8780a72 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget_skel.ui @@ -0,0 +1,340 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>KSB_MediaWidget_skel</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KSB_MediaWidget_skel</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>277</width> + <height>151</height> + </rect> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout6</cstring> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer5_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>Play</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Pause</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image1</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Stop</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image2</pixmap> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="L33tSlider"> + <property name="name"> + <cstring>Position</cstring> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>time</cstring> + </property> + <property name="text"> + <cstring>00:00/00:00</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>currentFile</cstring> + </property> + <property name="text"> + <cstring>Drag sound files here</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer17</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<images> + <image name="image0"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141ac02ba68c4d4c199b98323631656c62cad8c494891423ce0ee2dc4c6418208bd55a7301009c7f45ef</data> + </image> + <image name="image1"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08698b2b23294189c6254f36fad351700741b45ad</data> + </image> + <image name="image2"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa0869832140c5631aaf9b7d69a0b00046344fd</data> + </image> + <image name="image3"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08d98321280ab431682eb45124298871042b2032e846c2f4c8846fe4013abb5e602007fec45ef</data> + </image> +</images> +<includes> + <include location="global" impldecl="in declaration">controls.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/konq-plugins/sidebar/mediaplayer/mediawidget_skel_designer.ui b/konq-plugins/sidebar/mediaplayer/mediawidget_skel_designer.ui new file mode 100644 index 0000000..a88dfde --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mediawidget_skel_designer.ui @@ -0,0 +1,340 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>KSB_MediaWidget_skel</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KSB_MediaWidget_skel</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>277</width> + <height>151</height> + </rect> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout6</cstring> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>1</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer5_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>Play</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Pause</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image1</pixmap> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>Stop</cstring> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image2</pixmap> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QSlider"> + <property name="name"> + <cstring>Position</cstring> + </property> + <property name="maxValue"> + <number>1000</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>time</cstring> + </property> + <property name="text"> + <cstring>00:00/00:00</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>Frame4</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <property name="layoutMargin" stdset="0"> + </property> + <property name="layoutSpacing" stdset="0"> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel"> + <property name="name"> + <cstring>currentFile</cstring> + </property> + <property name="text"> + <cstring>Drag sound files here</cstring> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer6_3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer17</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<images> + <image name="image0"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141ac02ba68c4d4c199b98323631656c62cad8c494891423ce0ee2dc4c6418208bd55a7301009c7f45ef</data> + </image> + <image name="image1"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08698b2b23294189c6254f36fad351700741b45ad</data> + </image> + <image name="image2"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa0869832140c5631aaf9b7d69a0b00046344fd</data> + </image> + <image name="image3"> + <data format="XPM.GZ" length="394">789cd3d7528808f055d0d2e72a2e492cc94c5648ce482c52d04a29cdcdad8c8eb5ade6523234530022230543251d2e253d856405bffcbc54105b19c856360003b0141aa08d98321280ab431682eb45124298871042b2032e846c2f4c8846fe4013abb5e602007fec45ef</data> + </image> +</images> +<includes> + <include location="global" impldecl="in declaration">controls.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/konq-plugins/sidebar/mediaplayer/mplayer_add.desktop b/konq-plugins/sidebar/mediaplayer/mplayer_add.desktop new file mode 100644 index 0000000..1632ec4 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/mplayer_add.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Type=Link +URL= +Icon=konqsidebar_mediaplayer +Name=Media Player +Name[bg]=Медия плеър +Name[br]=Soner liesvedia +Name[ca]=Reproductor Multimèdia +Name[cs]=Přehrávač médií +Name[cy]=Chwaraewr Cyfryngau +Name[da]=Medieafspiller +Name[de]=Medienabspieler +Name[el]=Αναπαραγωγέας μέσων +Name[eo]=Medioludilo +Name[es]=Reproductor de medios +Name[et]=Meediafailide mängija +Name[eu]=Multimedia erreproduzigailua +Name[fa]=پخشکنندۀ رسانه +Name[fi]=Mediasoitin +Name[fr]=Lecteur multimédia +Name[fy]=Mediaspiler +Name[ga]=Seinnteoir Meán +Name[gl]=Reprodutor Multimédia +Name[he]=נגן מדיה +Name[hi]=मीडिया-प्लेयर +Name[hr]=Multimedijski program +Name[hu]=Médialejátszó +Name[is]=Margmiðlunarspilari +Name[it]=Lettore multimediale +Name[ja]=メディアプレーヤ +Name[ka]=მედია დამკვრელი +Name[kk]=Медиа ойнатқышы +Name[km]=កម្មវិធីចាក់មេឌៀ +Name[lt]=Media grotuvas +Name[mk]=Медијаплеер +Name[nb]=Mediaspiller +Name[nds]=Medienafspeler +Name[ne]=मिडिया प्लेएर +Name[nl]=Mediaspeler +Name[nn]=Mediespelar +Name[pa]=ਮੀਡਿਆ ਪਲੇਅਰ +Name[pl]=Odtwarzacz multimedialny +Name[pt]=Reprodutor Multimédia +Name[pt_BR]=Reprodutor de Mídia +Name[ru]=Медиаплеер +Name[sk]=Prehrávač médií +Name[sl]=Večpredstavnostni predvajalnik +Name[sv]=Mediaspelare +Name[ta]=ஊடகங்கள் இயக்கி +Name[tg]=Медиаплеер +Name[tr]=Çokluortam Oynatıcı +Name[uk]=Медіа-програвач +Name[uz]=Media-pleyer +Name[uz@cyrillic]=Медиа-плейер +Name[vi]=Bộ phát nhạc và ảnh +Name[zh_CN]=媒体播放器 +Name[zh_TW]=媒體播放器 + +Open=false +X-KDE-KonqSidebarAddModule=konqsidebar_mediaplayer +X-KDE-KonqSidebarUniversal=true diff --git a/konq-plugins/sidebar/mediaplayer/pics/Makefile.am b/konq-plugins/sidebar/mediaplayer/pics/Makefile.am new file mode 100644 index 0000000..e5515a8 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/Makefile.am @@ -0,0 +1 @@ +KDE_ICON = AUTO diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr16-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr16-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..71e4dd5 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr16-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr22-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr22-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..838cf9d --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr22-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr32-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr32-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..87ac58b --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr32-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/cr48-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/cr48-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..509c022 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/cr48-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/pics/lo32-app-konqsidebar_mediaplayer.png b/konq-plugins/sidebar/mediaplayer/pics/lo32-app-konqsidebar_mediaplayer.png Binary files differnew file mode 100644 index 0000000..db177a9 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/pics/lo32-app-konqsidebar_mediaplayer.png diff --git a/konq-plugins/sidebar/mediaplayer/player.cpp b/konq-plugins/sidebar/mediaplayer/player.cpp new file mode 100644 index 0000000..360f8e8 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/player.cpp @@ -0,0 +1,180 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#include <kdebug.h> +#include <klocale.h> +#include <kurl.h> +#include <kmediaplayer/player.h> + +#include "engine.h" +#include "player.h" + +Player::Player(QObject *parent) + : QObject(parent) + , position(0) + , unfinished(false) +{ + mEngine = new Engine; + mLooping = false; + connect(&ticker, SIGNAL(timeout()), SLOT(tickerTimeout())); + ticker.start(500); + stop(); +} + +Player::~Player() +{ + delete mEngine; +} + +bool Player::isPlaying()const +{ + return mEngine->state() == KMediaPlayer::Player::Play; +} + +bool Player::isPaused()const +{ + return mEngine->state() == KMediaPlayer::Player::Pause; +} + +bool Player::isStopped()const +{ + return mEngine->state() == KMediaPlayer::Player::Stop || mEngine->state() == KMediaPlayer::Player::Empty; +} + +void Player::handleButtons() +{ + switch(mEngine->state()) + { + case KMediaPlayer::Player::Play: + emit playing(); + break; + case KMediaPlayer::Player::Pause: + emit paused(); + break; + case KMediaPlayer::Player::Stop: + emit stopped(); + break; + case KMediaPlayer::Player::Empty: + emit empty(); + break; + } +} + +void Player::stop(void) +{ + unfinished = false; + position = 0; + mEngine->stop(); +} + +void Player::play() +{ + mEngine->play(); +} + +void Player::pause() +{ + if(mEngine->state() == KMediaPlayer::Player::Play) + { + mEngine->pause(); + } +} + +// skip to a certain time in the track +void Player::skipTo(unsigned long msec) +{ + if(!mCurrent.isEmpty()) + mEngine->seek(msec); +} + +void Player::tickerTimeout() +{ + position = mEngine->position(); + mLength = mEngine->length(); + + handleButtons(); + + if(mEngine->state() == KMediaPlayer::Player::Stop && unfinished) + { + if(mLooping) + { + play(); + } + else + { + stop(); + emit finished(); + } + } + else if(mEngine->state() != KMediaPlayer::Player::Stop) + { + emit timeout(); + unfinished = true; + } + +} + +QString Player::lengthString(long _position) +{ + if(_position == -1) _position = position; + + int posSecs = (int)(_position / 1000); + int posSeconds = posSecs % 60; + int posMinutes = (posSecs - posSeconds) / 60; + + int totSecs = (int)(mLength / 1000); + int totSeconds = totSecs % 60; + int totMinutes = (totSecs - totSeconds) / 60; + + QString result; + result.sprintf("%.2d:%.2d/%.2d:%.2d", posMinutes, posSeconds, totMinutes, totSeconds); + return result; +} + +bool Player::openFile(const KURL &f) +{ + stop(); + mCurrent = f; + + bool work = mEngine->load(mCurrent); + + if(!work) + { + mCurrent = KURL(); + return false; + } + else + { + emit opened(mCurrent); + tickerTimeout(); + return true; + } +} + +void Player::setLooping(bool b) +{ + mLooping = b; + emit loopingChange(mLooping); +} + +#include "player.moc" diff --git a/konq-plugins/sidebar/mediaplayer/player.h b/konq-plugins/sidebar/mediaplayer/player.h new file mode 100644 index 0000000..6acf146 --- /dev/null +++ b/konq-plugins/sidebar/mediaplayer/player.h @@ -0,0 +1,178 @@ +/***************************************************************** + +Copyright (c) 2000-2001 the noatun authors. See file AUTHORS. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIAB\ILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef PLAYER_H +#define PLAYER_H + +#include <qobject.h> +#include <qtimer.h> +#include <kurl.h> + +class Engine; + +/** + * This class has slots for all the common media player buttons + **/ +class Player : public QObject +{ +Q_OBJECT + +friend class KaboodlePart; +public: + Player(QObject *parent = 0); + ~Player(); + + /** + * returns a string with the time that can + * be used in the UI: + * CC:CC/LL:LL (mm:ss) + **/ + QString lengthString(long _position = -1); + + bool looping(void) const { return mLooping; } + + /** + * the position in milliseconds + **/ + long getTime() const { return position; } + + /** + * the track-length in milliseconds + **/ + unsigned long getLength() const { return mLength; } + + /** + * true if we're playing + **/ + bool isPlaying()const; + + /** + * true if paused + **/ + bool isPaused()const; + + /** + * true if stopped + **/ + bool isStopped()const; + + /** + * get the current opened URL + * this may be empty + **/ + KURL current() const { return mCurrent; } + + /** + * Change the file to have open + * @return true if file is playable, false otherwise + */ + bool openFile(const KURL &f); + +public slots: + /** + * force the playing/paused/stopped/playlist shown signals to + * be sent out + **/ + void handleButtons(); + + /** + * stop playing + **/ + void stop(void); + + /** + * start playing + **/ + void play(); + + /** + * pause playing + **/ + void pause(); + + /** + * skip to the position + **/ + void skipTo(unsigned long msec); + + /** + * Set whether to restart playing when the playing is done + */ + void setLooping(bool); + +signals: + /** + * Tells you to update display information + **/ + void timeout(); + + /** + * State is to Empty + */ + void empty(); + + /** + * State is to Stopped + */ + void stopped(); + + /** + * State is to Playing + */ + void playing(); + + /** + * State is to Paused + */ + void paused(); + + /** + * The file ended, and looping was off + */ + void finished(); + + void loopingChange(bool); + + /** + * The current URL changed + */ + void opened(const KURL &); + +private slots: + void tickerTimeout(); + +protected: + Engine *engine()const { return mEngine; } + +private: + Engine *mEngine; + QTimer ticker; + long position; + bool mLooping; + unsigned long mLength; + KURL mCurrent; + bool unfinished; +}; + +#endif + |