2 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
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.
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.
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.
21 #include "PlayerLabel.h"
23 PlayerLabel::PlayerLabel(QWidget* parent)
25 , m_bufferingAnimationIterator(m_bufferingAnimation)
26 , m_animationTimer(this)
28 m_bufferingAnimation.append(QPixmap(":/images/loading_buffering_1.png").scaled(QSize(80, 80)));
29 m_bufferingAnimation.append(QPixmap(":/images/loading_buffering_2.png").scaled(QSize(80, 80)));
30 m_bufferingAnimation.append(QPixmap(":/images/loading_buffering_3.png").scaled(QSize(80, 80)));
31 m_bufferingAnimation.append(QPixmap(":/images/loading_buffering_4.png").scaled(QSize(80, 80)));
32 m_bufferingAnimationIterator = m_bufferingAnimation;
33 m_animationTimer.setSingleShot(false);
34 m_animationTimer.setInterval(200);
35 connect(&m_animationTimer, SIGNAL(timeout()), this, SLOT(onAnimationTimeout()));
37 m_cannotplay = QPixmap(":/images/button_cannotplay.png").scaled(QSize(80, 80));
40 void PlayerLabel::onPlayerError()
42 setPixmap(m_cannotplay);
46 void PlayerLabel::startBufferingAnimation()
48 m_bufferingAnimationIterator.toFront();
49 setPixmap(m_bufferingAnimationIterator.next());
51 m_animationTimer.start();
54 void PlayerLabel::stopBufferingAnimation()
57 m_animationTimer.stop();
60 void PlayerLabel::onAnimationTimeout()
62 if (!m_bufferingAnimationIterator.hasNext())
63 m_bufferingAnimationIterator.toFront();
64 setPixmap(m_bufferingAnimationIterator.next());