summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer3/audiowidget.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer3/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer3/audiowidget.cpp125
1 files changed, 125 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer3/audiowidget.cpp b/noncore/multimedia/opieplayer3/audiowidget.cpp
new file mode 100644
index 0000000..7ba6274
--- a/dev/null
+++ b/noncore/multimedia/opieplayer3/audiowidget.cpp
@@ -0,0 +1,125 @@
1#include "audiowidget.h"
2#include "../opieplayer2/lib.h"
3#include "../opieplayer2/threadutil.h"
4
5#include <opie2/odebug.h>
6
7#include <qlayout.h>
8#include <qtextview.h>
9#include <qslider.h>
10#include <qlabel.h>
11
12AudioWidget::AudioWidget( QWidget * parent, const char * name, WFlags f)
13 :QWidget(parent,name,f)
14{
15 m_xineLib = 0;
16
17 m_MainLayout = new QVBoxLayout(this);
18 m_MainLayout->setAutoAdd(true);
19 m_InfoBox = new QTextView(this);
20 m_PosSlider = new QSlider(QSlider::Horizontal,this);
21 m_PosSlider->setTickInterval(60);
22 connect(m_PosSlider,SIGNAL(valueChanged(int)),this,SLOT(slotNewPos(int)));
23 connect(m_PosSlider,SIGNAL(sliderMoved(int)),this,SLOT(slotNewPos(int)));
24 connect(m_PosSlider,SIGNAL(sliderPressed()),this,SLOT(sliderPressed()));
25 connect(m_PosSlider,SIGNAL(sliderReleased()),this,SLOT(sliderReleased()));
26 m_pressed = false;
27 m_uppos=0;
28}
29
30AudioWidget::~AudioWidget()
31{
32}
33
34void AudioWidget::slotNewPos(int pos)
35{
36 if (!m_xineLib) return;
37 if (m_uppos==pos) return;
38 m_xineLib->seekTo(pos);
39}
40
41void AudioWidget::sliderPressed()
42{
43 m_pressed = true;
44}
45
46void AudioWidget::sliderReleased()
47{
48 m_pressed = false;
49}
50
51void AudioWidget::closeEvent(QCloseEvent*e)
52{
53 odebug << "AudioWidget::closeEvent(QCloseEvent*e)" << oendl;
54 if (m_xineLib) {
55 m_xineLib->stop();
56 }
57 QWidget::closeEvent(e);
58}
59
60void AudioWidget::playFile(const DocLnk&aLnk,XINE::Lib*aLib)
61{
62 m_current = aLnk;
63 if (m_xineLib != aLib) {
64 disconnect(m_xineLib);
65 m_xineLib = aLib;
66 }
67 if (!m_xineLib) {
68 return;
69 }
70 m_uppos=0;
71 m_PosSlider->setValue(0);
72 m_xineLib->setShowVideo(false);
73 m_xineLib->play(m_current.file());
74 // title
75 QString title = m_xineLib->metaInfo(0);
76 // artist
77 QString artist = m_xineLib->metaInfo(2);
78 // album
79 QString album = m_xineLib->metaInfo(4);
80
81 int l = m_xineLib->length();
82 m_PosSlider->setRange(0,l);
83 QString laenge="";
84 int h = l/3600;
85 l-=h*3600;
86 int m = l/60;
87 l-=m*60;
88 if (h>0) {
89 laenge+=QString("%1 h").arg(h);
90 }
91 if (m>0) {
92 if (!laenge.isEmpty()) laenge+=" ";
93 laenge+=QString("%1 m").arg(m);
94 }
95 if (l>0) {
96 if (!laenge.isEmpty()) laenge+=" ";
97 laenge+=QString("%1 s").arg(l);
98 }
99 QString text = "<qt>";
100 if (artist.length()) {
101 text+="<H2><center>"+artist+"</center></h2>";
102 }
103 if (title.length()) {
104 text+="<H2><center>"+title+"</center></h2>";
105 }
106 if (album.length()) {
107 text+="<H2><center>"+album+"</center></h2>";
108 }
109 text+="<h3><center>"+laenge+"</center></h3>";
110 m_InfoBox->setText(text);
111}
112
113void AudioWidget::stopPlaying()
114{
115 if (m_xineLib) {
116 m_xineLib->stop();
117 }
118}
119
120void AudioWidget::updatePos(int val)
121{
122 if (m_pressed) return;
123 m_uppos = val;
124 m_PosSlider->setValue(val);
125}