~phablet-team/phablet-extras/qt-gstreamer

« back to all changes in this revision

Viewing changes to examples/player/player.cpp

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-06-15 15:03:26 UTC
  • mfrom: (1.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120615150326-pkmdog620pkytcgt
Tags: 0.10.2-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Enable unit tests.
    + Build-depend on gstreamer0.10-plugins-base.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    This program is distributed in the hope that it will be useful,
12
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
 
14
    GNU Lesser General Public License for more details.
15
15
 
16
16
    You should have received a copy of the GNU Lesser General Public License
17
17
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
#include "player.h"
20
20
#include <QtCore/QDir>
 
21
#include <QtCore/QUrl>
21
22
#include <QGlib/Connect>
22
23
#include <QGlib/Error>
23
24
#include <QGst/Pipeline>
27
28
#include <QGst/Query>
28
29
#include <QGst/ClockTime>
29
30
#include <QGst/Event>
 
31
#include <QGst/StreamVolume>
30
32
 
31
33
Player::Player(QWidget *parent)
32
34
    : QGst::Ui::VideoWidget(parent)
50
52
 
51
53
    //if uri is not a real uri, assume it is a file path
52
54
    if (realUri.indexOf("://") < 0) {
53
 
        realUri = "file://" + QFileInfo(realUri).absoluteFilePath();
 
55
        realUri = QUrl::fromLocalFile(realUri).toEncoded();
54
56
    }
55
57
 
56
58
    if (!m_pipeline) {
97
99
    m_pipeline->sendEvent(evt);
98
100
}
99
101
 
 
102
int Player::volume() const
 
103
{
 
104
    if (m_pipeline) {
 
105
        QGst::StreamVolumePtr svp =
 
106
            m_pipeline.dynamicCast<QGst::StreamVolume>();
 
107
 
 
108
        if (svp) {
 
109
            return svp->volume(QGst::StreamVolumeFormatCubic) * 10;
 
110
        }
 
111
    }
 
112
 
 
113
    return 0;
 
114
}
 
115
 
 
116
 
 
117
void Player::setVolume(int volume)
 
118
{
 
119
    if (m_pipeline) {
 
120
        QGst::StreamVolumePtr svp =
 
121
            m_pipeline.dynamicCast<QGst::StreamVolume>();
 
122
 
 
123
        if(svp) {
 
124
            svp->setVolume((double)volume / 10, QGst::StreamVolumeFormatCubic);
 
125
        }
 
126
    }
 
127
}
 
128
 
100
129
QTime Player::length() const
101
130
{
102
131
    if (m_pipeline) {
181
210
    Q_EMIT stateChanged();
182
211
}
183
212
 
184
 
#include "player.moc"
 
213
#include "moc_player.cpp"