Exemplo n.º 1
0
BuzzerLive::BuzzerLive() {
    soundPlayer = new QMediaPlayer();
    inWin = false;
    buzzDir = new QDir("media/buzzer/sounds/");
    mp3Files = buzzDir->entryList(QDir::Files);

    textTimeout = new QTimer;
    textTimeout->setInterval(3000);
    connect(textTimeout, SIGNAL(timeout()), this, SLOT(killText()));

    dTeamName = new QLabel();
    dTeamName->setWordWrap(true);
    dTeamName->setAlignment(Qt::AlignCenter);
    dTeamName->setStyleSheet("margin: 0; padding: 0; background-color: black; color: white; font: 100pt;");

    videoPlayer = new QMediaPlayer();
    videoWidget = new QVideoWidget();
    videoPlayer->setVideoOutput(videoWidget);
    connect(videoPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this , SLOT(videoStateChanged(QMediaPlayer::State)));
    connect(videoPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this , SLOT(videoStatusChanged(QMediaPlayer::MediaStatus)));

    layout = new QStackedLayout();
    layout->addWidget(dTeamName);
    layout->addWidget(videoWidget);
    layout->setCurrentWidget(dTeamName);
    connect(layout, SIGNAL(currentChanged(int)), this, SLOT(checkVideoHidden(int)));

    setLayout(layout);
}
BbCameraMediaRecorderControl::BbCameraMediaRecorderControl(BbCameraSession *session, QObject *parent)
    : QMediaRecorderControl(parent)
    , m_session(session)
{
    connect(m_session, SIGNAL(videoStateChanged(QMediaRecorder::State)), this, SIGNAL(stateChanged(QMediaRecorder::State)));
    connect(m_session, SIGNAL(videoStatusChanged(QMediaRecorder::Status)), this, SIGNAL(statusChanged(QMediaRecorder::Status)));
    connect(m_session, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64)));
    connect(m_session, SIGNAL(actualLocationChanged(QUrl)), this, SIGNAL(actualLocationChanged(QUrl)));
    connect(m_session, SIGNAL(videoError(int,QString)), this, SIGNAL(error(int,QString)));
}
void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput)
{
    if (videoOutput == m_videoOutput)
        return;

    S60VideoWidgetControl *newWidgetControl = qobject_cast<S60VideoWidgetControl *>(videoOutput);
    S60VideoWidgetControl *oldWidgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput);

    if (oldWidgetControl) {
        disconnect(oldWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay()));
        disconnect(oldWidgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess()));
        disconnect(oldWidgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess()));
        disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), oldWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State)));
    }
    if (newWidgetControl) {
        connect(newWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay()));
        connect(newWidgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess()));
        connect(newWidgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess()));
        connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), newWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State)));
    }
    m_videoOutput = videoOutput;
    resetVideoDisplay();
}
void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput)
{
    if (videoOutput == m_videoOutput)
        return;

    S60VideoWidgetControl *newWidgetControl = qobject_cast<S60VideoWidgetControl *>(videoOutput);
    S60VideoWidgetControl *oldWidgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput);

    if (oldWidgetControl) {
        disconnect(oldWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay()));
        disconnect(oldWidgetControl, SIGNAL(widgetResized()), this, SLOT(resizeVideoWindow()));
        disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), oldWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State)));
    }
    if (newWidgetControl) {
        connect(newWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay()));
        connect(newWidgetControl, SIGNAL(widgetResized()), this, SLOT(resizeVideoWindow()));
        connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), newWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State)));
    }

    m_videoOutput = videoOutput;
    resetVideoDisplay();
}