initial import
[vuplus_webkit] / Source / WebKit / qt / symbian / platformplugin / HTML5VideoWidget.cpp
1 /*
2  * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20
21 #include "HTML5VideoWidget.h"
22
23 HTML5VideoWidget::HTML5VideoWidget(QWidget *parent)
24     : QVideoWidget(parent)
25     , m_overlayWidget(new OverlayWidget(this))
26 {
27     connect(m_overlayWidget, SIGNAL(controlClicked(bool)), this, SLOT(onControlClicked(bool)));
28     connect(m_overlayWidget, SIGNAL(sliderMoved(int)), this, SLOT(onSliderMoved(int)));
29     connect(m_overlayWidget, SIGNAL(closeClicked()), this, SLOT(onCloseClicked()));
30     connect(m_overlayWidget, SIGNAL(muted(bool)), this, SIGNAL(muted(bool)));
31     connect(m_overlayWidget, SIGNAL(volumeChanged(int)), this, SIGNAL(volumeChanged(int)));
32     m_overlayWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
33 }
34
35 void HTML5VideoWidget::setDuration(qint64 duration)
36 {
37     m_overlayWidget->setDuration(duration / 1000);
38 }
39
40 void HTML5VideoWidget::mousePressEvent(QMouseEvent *)
41 {
42     m_overlayWidget->showFullScreen();
43 }
44
45 void HTML5VideoWidget::onPlayerStopped()
46 {
47     m_overlayWidget->onPlayerStopped();
48 }
49
50 void HTML5VideoWidget::onPlayerError()
51 {
52     m_overlayWidget->onPlayerError();
53 }
54
55 void HTML5VideoWidget::onEndOfMedia()
56 {
57     m_overlayWidget->onEndOfMedia();
58 }
59
60 void HTML5VideoWidget::onBufferingMedia()
61 {
62     m_overlayWidget->onBufferingMedia();
63 }
64
65 void HTML5VideoWidget::onBufferedMedia()
66 {
67     m_overlayWidget->onBufferedMedia();
68 }
69
70 void HTML5VideoWidget::onControlClicked(bool isPaused)
71 {
72     if (isPaused)
73         emit pauseClicked();
74     else
75         emit playClicked();
76 }
77
78 void HTML5VideoWidget::onPositionChanged(qint64 position)
79 {
80     m_overlayWidget->setPosition(position / 1000);
81 }
82
83 void HTML5VideoWidget::onSliderMoved(int value)
84 {
85     emit positionChangedByUser(((qint64)value)*1000);
86 }
87
88 void HTML5VideoWidget::onCloseClicked()
89 {
90     hide();
91     emit closeClicked();
92 }
93
94 void HTML5VideoWidget::showFullScreen()
95 {
96     setFullScreen(true);
97     m_overlayWidget->showFullScreen();
98 }
99
100 void HTML5VideoWidget::setVolume(int volume)
101 {
102     m_overlayWidget->setVolume(volume);
103 }