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 "HTML5VideoPlugin.h"
25 HTML5FullScreenVideoHandler::HTML5FullScreenVideoHandler()
29 , m_savedOrientation(CAknAppUi::EAppUiOrientationUnspecified)
33 void HTML5FullScreenVideoHandler::enterFullScreen(QMediaPlayer *player)
38 m_videoWidget = new HTML5VideoWidget();
42 m_videoWidget->setDuration(player->duration() / 1000);
44 CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
46 m_savedOrientation = appUi->Orientation();
47 appUi->SetOrientationL(CAknAppUi::EAppUiOrientationLandscape);
50 m_mediaPlayer = player;
51 connect(m_mediaPlayer, SIGNAL(positionChanged(qint64)), m_videoWidget, SLOT(onPositionChanged(qint64)));
52 connect(m_mediaPlayer, SIGNAL(durationChanged(qint64)), m_videoWidget, SLOT(setDuration(qint64)));
53 connect(m_mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(onPlayerStateChanged(QMediaPlayer::State)));
54 connect(m_mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(onPlayerError(QMediaPlayer::Error)));
55 connect(m_mediaPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(onMediaStatusChanged(QMediaPlayer::MediaStatus)));
56 connect(m_videoWidget, SIGNAL(positionChangedByUser(qint64)), m_mediaPlayer, SLOT(setPosition(qint64)));
57 connect(m_videoWidget, SIGNAL(closeClicked()), this, SIGNAL(fullScreenClosed()));
58 connect(m_videoWidget, SIGNAL(muted(bool)), m_mediaPlayer, SLOT(setMuted(bool)));
59 connect(m_videoWidget, SIGNAL(volumeChanged(int)), m_mediaPlayer, SLOT(setVolume(int)));
60 connect(m_videoWidget, SIGNAL(pauseClicked()), m_mediaPlayer, SLOT(pause()));
61 connect(m_videoWidget, SIGNAL(playClicked()), m_mediaPlayer, SLOT(play()));
63 m_mediaPlayer->setVideoOutput(m_videoWidget);
65 m_videoWidget->setVolume(m_mediaPlayer->volume());
66 m_videoWidget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
67 m_videoWidget->showFullScreen();
70 // Handle current Media Status and Media Player error.
71 onMediaStatusChanged(m_mediaPlayer->mediaStatus());
72 onPlayerError(m_mediaPlayer->error());
75 void HTML5FullScreenVideoHandler::exitFullScreen()
77 m_videoWidget->hide();
78 m_mediaPlayer->disconnect(m_videoWidget);
79 m_mediaPlayer->disconnect(this);
82 if (m_mediaPlayer->state() == QMediaPlayer::PlayingState)
83 m_mediaPlayer->pause();
86 CAknAppUi* appUi = dynamic_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
88 appUi->SetOrientationL(m_savedOrientation);
91 void HTML5FullScreenVideoHandler::onPlayerError(QMediaPlayer::Error error)
94 case QMediaPlayer::NoError:
97 m_videoWidget->onPlayerError();
101 void HTML5FullScreenVideoHandler::onPlayerStateChanged(QMediaPlayer::State state)
103 if (state == QMediaPlayer::StoppedState)
104 m_videoWidget->onPlayerStopped();
107 void HTML5FullScreenVideoHandler::onMediaStatusChanged(QMediaPlayer::MediaStatus status)
110 case QMediaPlayer::EndOfMedia:
111 m_videoWidget->onEndOfMedia();
113 case QMediaPlayer::StalledMedia:
114 case QMediaPlayer::LoadingMedia:
115 case QMediaPlayer::BufferingMedia:
116 m_videoWidget->onBufferingMedia();
118 case QMediaPlayer::LoadedMedia:
119 case QMediaPlayer::BufferedMedia:
120 m_videoWidget->onBufferedMedia();
128 bool HTML5VideoPlugin::supportsExtension(Extension extension) const
131 case FullScreenVideoPlayer:
138 QObject* HTML5VideoPlugin::createExtension(Extension extension) const
140 HTML5FullScreenVideoHandler* videoHandler = 0;
142 case FullScreenVideoPlayer:
143 videoHandler = new HTML5FullScreenVideoHandler;