summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer3/videowidget.cpp
blob: a28d47dc6f521f2eee79dc2c68ccf7022e34662d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#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_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()
{
}

void VideoWidget::slotClicked()
{
    odebug << "clicked " << oendl;
    emit videoclicked();
}

void VideoWidget::closeEvent(QCloseEvent*e)
{
}

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 */)
{
#if 0
    if (how) {
        m_PosSlider->hide();
    } else {
        m_PosSlider->show();
    }
#endif
}

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()));
#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());
    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();
    }
}

void VideoWidget::slotStopped()
{
// check fullscreen here!
}

void VideoWidget::slot_Videoresized(const QSize&s)
{
    odebug << "Videoresized: " << s << oendl;
    if (m_xineLib) {
        m_xineLib->resize(s);
    }
}

void VideoWidget::updatePos(int /*val*/)
{
#if 0
    if (m_pressed) return;
    m_uppos = val;
    m_PosSlider->setValue(val);
#endif
}