Controller::Controller(QWidget *parent) : TWidget(parent)
, _playPauseResume(this, st::mediaviewPlayButton)
, _playbackSlider(this, st::mediaviewPlayback)
, _playback(std::make_unique<Playback>())
, _volumeController(this)
, _fullScreenToggle(this, st::mediaviewFullScreenButton)
, _playedAlready(this, st::mediaviewPlayProgressLabel)
, _toPlayLeft(this, st::mediaviewPlayProgressLabel)
, _fadeAnimation(std::make_unique<Ui::FadeAnimation>(this)) {
	_fadeAnimation->show();
	_fadeAnimation->setFinishedCallback([this] { fadeFinished(); });
	_fadeAnimation->setUpdatedCallback([this](float64 opacity) { fadeUpdated(opacity); });

	_volumeController->setVolume(Global::VideoVolume());

	connect(_playPauseResume, SIGNAL(clicked()), this, SIGNAL(playPressed()));
	connect(_fullScreenToggle, SIGNAL(clicked()), this, SIGNAL(toFullScreenPressed()));
	connect(_volumeController, SIGNAL(volumeChanged(float64)), this, SIGNAL(volumeChanged(float64)));

	_playback->setInLoadingStateChangedCallback([this](bool loading) {
		_playbackSlider->setDisabled(loading);
	});
	_playback->setValueChangedCallback([this](float64 value) {
		_playbackSlider->setValue(value);
	});
	_playbackSlider->setChangeProgressCallback([this](float64 value) {
		_playback->setValue(value, false);
		handleSeekProgress(value); // This may destroy Controller.
	});
	_playbackSlider->setChangeFinishedCallback([this](float64 value) {
		_playback->setValue(value, false);
		handleSeekFinished(value);
	});
}
Esempio n. 2
0
GuitarTuner::GuitarTuner(QWidget *parent) :
    QMainWindow(parent)
{

    // Set up the QML.
    m_guitarTunerUI = new QDeclarativeView(QUrl("qrc:/src/application.qml"), this);
    setCentralWidget(m_guitarTunerUI);
    m_guitarTunerUI->setResizeMode(QDeclarativeView::SizeRootObjectToView);
    qmlObject = m_guitarTunerUI->rootObject();

    // Init audio output and input.
    initAudioOutput();
    initAudioInput();

    // Connect the quit signal of m_guitarTunerUI
    // into the close slot of this.
    connect(m_guitarTunerUI->engine(), SIGNAL(quit()), SLOT(close()));

    // Connect the signals from qmlObject into proper slots
    // of this and m_voicegenerator.
    connect(qmlObject, SIGNAL(muteStateChanged(bool)),
            SLOT(muteStateChanged(bool)));
    connect(qmlObject, SIGNAL(volumeChanged(qreal)),
            m_voicegenerator, SLOT(setAmplitude(qreal)));
    connect(qmlObject, SIGNAL(volumeChanged(qreal)),
            SLOT(setMaxVolumeLevel(qreal)));

    // Connect the modeChanged signal from qmlObject
    // into modeChanged slot of this class.
    connect(qmlObject, SIGNAL(modeChanged(bool)),
            SLOT(modeChanged(bool)));

    // Connect the microphoneSensitivityChanged signal from
    // m_guitarTunerUI into setCutOffPercentage slot of m_analyzer class.
    connect(qmlObject, SIGNAL(microphoneSensitivityChanged(qreal)),
            m_analyzer, SLOT(setCutOffPercentage(qreal)));

    // Connect the signals from m_analyzer into slots of qmlObject.
    connect(m_analyzer, SIGNAL(lowVoice()),
            qmlObject, SLOT(lowVoice()));
    connect(m_analyzer, SIGNAL(correctFrequency()),
            qmlObject, SLOT(correctFrequencyObtained()));
    connect(m_analyzer, SIGNAL(voiceDifference(QVariant)),
            qmlObject, SLOT(voiceDifferenceChanged(QVariant)));

    // Initialise the MaximumVoiceDifference
    // value of qmlObject with the value obtained from m_analyzer.
    qmlObject->setProperty("maxVoiceDifference",
                           m_analyzer->getMaximumVoiceDifference());

    // Connect the targetFrequencyChanged signal of qmlObject
    // into targetFrequencyChanged slot of this class.
    connect(qmlObject, SIGNAL(targetFrequencyChanged(qreal)),
            SLOT(targetFrequencyChanged(qreal)));

    // Start voice output or input by using the modeChanged function,
    // depending of the current mode.
    modeChanged(qmlObject->property("isInput").toBool());

}
Esempio n. 3
0
QmlVlcPlayerProxy::QmlVlcPlayerProxy( const std::shared_ptr<vlc::player>& player,
                                      QObject* parent /*= 0*/ )
    : QObject( parent ), m_player( player ), m_audio( *player ), m_input( *player ),
      m_playlist( this ), m_subtitle( *player ), m_video( *player ),
      m_currentMediaDesc( this )
{
    qRegisterMetaType<QmlVlcPlayerProxy::State>( "QmlVlcPlayerProxy::State" );

    m_errorTimer.setInterval( 1000 );
    m_errorTimer.setSingleShot( true );

    connect( this, SIGNAL( mediaPlayerEncounteredError() ),
             &m_errorTimer, SLOT( start() ) );
    connect( &m_errorTimer, SIGNAL( timeout() ),
             this, SLOT( currentItemEndReached() ) );

    connect( this, SIGNAL( mediaPlayerEndReached() ),
             &m_errorTimer, SLOT( stop() ) );
    connect( this, SIGNAL( mediaPlayerEndReached() ),
             this, SLOT( currentItemEndReached() ) );

    connect( this, SIGNAL( mediaPlayerMediaChanged() ),
             &m_errorTimer, SLOT( stop() ) );
    connect( this, &QmlVlcPlayerProxy::mediaPlayerMediaChanged,
             get_subtitle(), &QmlVlcSubtitle::eraseLoaded );

    connect( get_audio(), SIGNAL( volumeChanged() ),
             this, SIGNAL( volumeChanged() ) );
}
Esempio n. 4
0
void VolumeSlider::setPlayer(Player *player)
{
    m_player = player;

    connect(m_player, SIGNAL(mutedChanged(bool)), SLOT(mutedChanged(bool)));
    connect(m_player, SIGNAL(volumeChanged(qreal)), SLOT(setVolume(qreal)));
    connect(this, SIGNAL(volumeChanged(qreal)), m_player, SLOT(setVolume(qreal)));
}
Esempio n. 5
0
MediaPlayer2Player::MediaPlayer2Player(QObject* parent) : QDBusAbstractAdaptor(parent)
{
    connect(Dragon::engine(), SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
    connect(Dragon::engine(), SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(currentSourceChanged()));
    connect(Dragon::engine(), SIGNAL(metaDataChanged()), this, SLOT(emitMetadataChange()));
    connect(Dragon::engine(), SIGNAL(stateUpdated(Phonon::State,Phonon::State)), this, SLOT(stateUpdated()));
    connect(Dragon::engine(), SIGNAL(totalTimeChanged(qint64)), this, SLOT(emitMetadataChange()));
    connect(Dragon::engine(), SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
    connect(Dragon::engine(), SIGNAL(volumeChanged(qreal)), this, SLOT(volumeChanged()));
}
void DirectShowPlayerControl::setVolume(int volume)
{
    int boundedVolume = qBound(0, volume, 100);

    if (m_muteVolume >= 0) {
        m_muteVolume = boundedVolume;

        emit volumeChanged(m_muteVolume);
    } else if (m_audio) {
        m_audio->put_Volume(volumeToDecibels(volume));

        emit volumeChanged(boundedVolume);
    }
}
Esempio n. 7
0
void SliderWidget::onSliderMove(int v)
{
	changing = true;
	snd->setVolume(v);
	changing = false;
	emit volumeChanged(v);
}
Esempio n. 8
0
int VolumeDialogImpl::setVolume( bool up)
{
    int ret = (volumeWidget->value() == m_oldValue);
    m_oldValue = volumeWidget->value();
    volumeWidget->setCurrent( up ? m_oldValue + 1 : m_oldValue - 1 );
    int value = volumeWidget->value();

    if ( m_oldValue < value )
        emit volumeChanged( true );
    else if ( m_oldValue > value )
        emit volumeChanged( false );

    resetTimer();

    return ret;
}
Esempio n. 9
0
VolumeSlider::VolumeSlider(AudioOutput *output, QWidget *parent)
    : QWidget(parent),
    k_ptr(new VolumeSliderPrivate(this))
{
    K_D(VolumeSlider);
#ifndef QT_NO_TOOLTIP
    setToolTip(tr("Volume: %1%").arg(100));
#endif
#ifndef QT_NO_WHATSTHIS
    setWhatsThis(tr("Use this slider to adjust the volume. The leftmost position is 0%, the rightmost is %1%").arg(100));
#endif

    connect(&d->slider, SIGNAL(valueChanged(int)), SLOT(_k_sliderChanged(int)));
    connect(&d->muteButton, SIGNAL(clicked()), SLOT(_k_buttonClicked()));

    if (output) {
        d->output = output;
        d->slider.setValue(qRound(100 * output->volume()));
        d->slider.setEnabled(true);
        d->muteButton.setEnabled(true);
        connect(output, SIGNAL(volumeChanged(qreal)), SLOT(_k_volumeChanged(qreal)));
        connect(output, SIGNAL(mutedChanged(bool)), SLOT(_k_mutedChanged(bool)));
    }

    setFocusProxy(&d->slider);
}
Esempio n. 10
0
int Playengine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: volume((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: statusChanged((*reinterpret_cast< Playengine::STATUS(*)>(_a[1]))); break;
        case 2: buffering((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: tick((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: togglePause(); break;
        case 5: play((*reinterpret_cast< const QUrl(*)>(_a[1]))); break;
        case 6: stop(); break;
        case 7: setVolume((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: stateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 9: tickslot((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 10: sourceChanged((*reinterpret_cast< const Phonon::MediaSource(*)>(_a[1]))); break;
        case 11: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 12: aboutToFinish(); break;
        case 13: bufferPercent((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 14: volumeChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 15;
    }
    return _id;
}
Esempio n. 11
0
STDMETHODIMP CVolumeNotification::OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA NotificationData)
{
	int volumeValue = (int)round(NotificationData->fMasterVolume*100);

	//if(_currVolume < 0)
	//{
	//	_currVolume = volumeValue;
	//	_mute = NotificationData->bMuted;
	//	emit volumeChanged(volumeValue);
	//	emit volumeMuted(NotificationData->bMuted);
	//	return S_OK;
	//}

	//
	//if(abs(_currVolume - volumeValue) >= 1)
	//{
	//	emit volumeChanged(volumeValue);
	//}
	//if(_mute != NotificationData->bMuted)
	//{
	//	emit volumeMuted(NotificationData->bMuted);
	//}

	_currVolume = volumeValue;
	_mute = NotificationData->bMuted;


	//if(!InlineIsEqualGUID(NotificationData->guidEventContext, GUID_NULL))
	{
		emit volumeChanged(_currVolume);
		emit volumeMuted(_mute);
	}

	return S_OK;
}
Esempio n. 12
0
HRESULT PlaybackControls::LoadFile()
{
	QPixmap picture;
	picture = getPicture(mFile);
	if (!picture.isNull())
	{
		mpParentWindow->id3Art->setPixmap(picture.scaledToHeight(128));
	}

	HRESULT hr = 0;
	if (!mpGraph)
	{
		if (FAILED(hr = InitialiseFilterGraph()))
			return hr;
	}

	if (!mGraphValid)
	{
		hr = mpGraph->RenderFile(mFile.toStdWString().c_str(), NULL);
		if (SUCCEEDED(hr))
		{
			QString metadata = getArtist(mFile);
			mpParentWindow->artistLabel->setText("Artist : " + metadata);
			metadata = getAlbum(mFile);
			mpParentWindow->albumLabel->setText("Album : " + metadata);
			metadata = getTitle(mFile);
			mpParentWindow->titleLabel->setText("Title : " + metadata);
			mGraphValid = true;
			setVolume(mVolume);
			emit volumeChanged(mVolume);
		}
		return hr;
	}
	return S_OK;
}
Esempio n. 13
0
void
Amarok::OSD::muteStateChanged( bool mute )
{
    Q_UNUSED( mute )

    volumeChanged( The::engineController()->volume() );
}
Esempio n. 14
0
void VolumeControl::setVolume(int volume, int maximumVolume)
{
    int clampedMaxVolume = maximumVolume < 0 ? 0 : maximumVolume;
    int clampedVolume = qBound(0, volume, maximumVolume);

    bool volumeUpdated = false;
    bool maxVolumeUpdated = false;

    if (maximumVolume_ != clampedMaxVolume) {
        maximumVolume_ = clampedMaxVolume;
        maxVolumeUpdated = true;
    }

    if (volume_ != clampedVolume) {
        volume_ = clampedVolume;
        volumeUpdated = true;
    }

    if (maxVolumeUpdated) {
        emit maximumVolumeChanged();
    }

    if (volumeUpdated) {
        emit volumeChanged();
    }
}
int MPlayerProcess::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QProcess::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: mediaPosition((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: volumeChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: durationChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: volumeLevelChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: fileNameChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 5: paused(); break;
        case 6: sizeChanged(); break;
        case 7: openStream((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 8: togglePlayPause(); break;
        case 9: setMediaPosition((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 10: setVolume((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: setLoop((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 12: setSpeed((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 13: setAudioDelay((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 14: readStandardOutput(); break;
        default: ;
        }
        _id -= 15;
    }
    return _id;
}
Esempio n. 16
0
static void onPropertiesChanged(GDBusProxy          *proxy,
                                GVariant            *changed_properties,
                                const gchar* const  *invalidated_properties,
                                gpointer             pp)
{
  if (g_variant_n_children(changed_properties) > 0) {
    GVariantIter *iter;
    gchar *key;
    GVariant *value;

    debug(" *** Properties Changed:\n");
    g_variant_get(changed_properties, "a{sv}", &iter);
    while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) {
      gchar *value_str;
      value_str = g_variant_print(value, TRUE);
      g_print("      %s -> %s\n", key, value_str);
      g_free(value_str);
      if (strncmp(key, "Metadata",8) == 0) {
        trackChanged(value);
      } else if (strcmp(key, "PlaybackStatus") == 0) {
        playbackChanged(g_variant_dup_string(value, NULL));
      } else if (strcmp(key, "LoopStatus") == 0) {
        loopChanged(g_variant_dup_string(value, NULL));
      } else if (strcmp(key, "Shuffle") == 0) {
        shuffleChanged(g_variant_get_boolean(value));
      } else if (strcmp(key, "Position") == 0) {
        positionChanged(g_variant_get_int64(value));
      } else if (strcmp(key, "Volume") == 0) {
        volumeChanged(g_variant_get_double(value));
      }
    }

    g_variant_iter_free (iter);
  }
}
Esempio n. 17
0
views::actionMenu::actionMenu()
{
    repeatPlaylistA=0;
    clearPlaylistA = new QAction( KIcon("edit-clear-list"),tr("clear"), this );
    connect(clearPlaylistA,SIGNAL(triggered( bool)),core::npList(),SLOT(clear() ) );

    sufflePlaylistA = new QAction( KIcon("roll"),tr("suffle"), this );    
    connect(sufflePlaylistA,SIGNAL(triggered( bool)),core::npList(),SLOT(suffle() ) );    
    
    nextA = new QAction(  views::decor->next(),"play next", this );
    connect(nextA,SIGNAL(triggered( bool)),core::engine(),SLOT(next() ) );
    
    previousA = new QAction(  views::decor->previous() ,"play previous", this );    
    connect(previousA,SIGNAL(triggered( bool)),core::engine(),SLOT(previous() ) );

    playPauseA = new QAction(  views::decor->play(),"play-pause", this );
    connect(playPauseA,SIGNAL(triggered( bool)),core::engine(),SLOT(playPause() ) );
    connect(core::engine(),SIGNAL(stateChanged(Phonon::State)),this,SLOT(stateChanged() ) );
    
    volumeAction = new QAction(  decor->volumeMedium(),tr("mute"), this );    
    connect(volumeAction,SIGNAL(triggered( bool)),core::engine(),SLOT(muteToggle() ) );
    connect(core::engine()->getAudio(),SIGNAL(volumeChanged(qreal)),this,SLOT(volumeC(qreal)));
    volumeC(core::engine()->getAudio()->volume() );
    
    quitAction = new QAction(KIcon("application-exit"), tr("&Quit"), this);    
    connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
}
Esempio n. 18
0
void PlayerController::setView(AbstractPlayerView *view)
{
    if (m_view == view)
        return;

    if (m_view) {
        m_view->disconnect(this);
    }

    m_view = view;

    if (m_view) {
        connect(m_view, SIGNAL(playClicked()), SLOT(play()));
        connect(m_view, SIGNAL(pauseClicked()), SLOT(pause()));
        connect(m_view, SIGNAL(stopClicked()), SLOT(stop()));
        connect(m_view, SIGNAL(nextClicked()), SLOT(next()));
        connect(m_view, SIGNAL(previousClicked()), SLOT(previous()));
        connect(m_view, SIGNAL(shuffleClicked()), SLOT(toggleShuffle()));
        connect(m_view, SIGNAL(muteClicked()), SLOT(toggleMute()));
        connect(m_view, SIGNAL(repeatClicked()), SLOT(toggleRepeat()));
        connect(m_view, SIGNAL(volumeChanged(qreal)), SLOT(setVolume(qreal)));
        connect(m_view, SIGNAL(songSelected(int)), SLOT(play(int)));
    }

    initializeView();
}
Esempio n. 19
0
void PlayerControls::onVolumeChanged(int volume)
{
    double val = volume / 100.0;
    setVolume(val);

    Q_EMIT volumeChanged(val);
}
Esempio n. 20
0
ClipRenderer::ClipRenderer() :
    GenericRenderer(),
    m_clipLoaded( false ),
    m_vlcMedia( NULL ),
    m_selectedClip( NULL ),
    m_begin( 0 ),
    m_end( -1 ),
    m_mediaChanged( false )
{
    connect( m_mediaPlayer,     SIGNAL( stopped() ),            this,   SLOT( __videoStopped() ) );
    connect( m_mediaPlayer,     SIGNAL( paused() ),             this,   SIGNAL( paused() ) );
    connect( m_mediaPlayer,     SIGNAL( playing() ),            this,   SIGNAL( playing() ) );
    connect( m_mediaPlayer,     SIGNAL( volumeChanged() ),      this,   SIGNAL( volumeChanged() ) );
    connect( m_mediaPlayer,     SIGNAL( timeChanged( qint64 ) ),this,   SLOT( __timeChanged( qint64 ) ) );
    connect( m_mediaPlayer,     SIGNAL( endReached() ),         this,   SLOT( __endReached() ) );
}
void QVolumeSlider::updateVolume(int value)
{
    double volumeInDB = (static_cast<double>(value)) / 10;
    volumeInDB = 50*log10(volumeInDB) - 100;
    double volumeInPower = pow(10, (volumeInDB)/(20));
    emit volumeChanged(volumeInPower);
}
Esempio n. 22
0
void
Amarok::OSD::engineMuteStateChanged( bool mute )
{
    Q_UNUSED( mute )

    volumeChanged( m_volume );
}
Esempio n. 23
0
VideoItem::VideoItem()
{
    core = new Core();

    texture = nullptr;
    m_libcore = "";
    m_stretch_video = false;
    m_filtering = 2;
    m_aspect_ratio = 0.0;
    m_fps = 0;

    audio = new Audio();
    Q_CHECK_PTR(audio);
    audio->start();
    core->audio_buf = audio->abuf();
    m_volume = 1.0;

    connect(&fps_timer, SIGNAL(timeout()), this, SLOT(updateFps()));
    frame_timer.invalidate();
    fps_deviation = 0;
    fps_count = 0;

    connect(this, SIGNAL(runChanged(bool)), audio, SLOT(runChanged(bool)));
    connect(this, SIGNAL(volumeChanged(qreal)), audio, SLOT(setVolume(qreal)));
    connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*)));
}
Esempio n. 24
0
void KgSound::setVolume(qreal volume)
{
	if (d->m_volume == volume)
		return;
	d->m_volume = volume;
	emit volumeChanged(volume);
}
Esempio n. 25
0
void SliderWidget::updateVolume()
{
	if (changing) // do not auto update when moving slider, it is done already
		return;
	int v = snd->volume();
	slider->setValue(v);
	emit volumeChanged(v);
}
void UnitsSettings::setVolume(int value)
{
	QSettings s;
	s.beginGroup(group);
	s.setValue("volume", value);
	prefs.units.volume = (units::VOLUME) value;
	emit volumeChanged(value);
}
Esempio n. 27
0
void
MediaOutput::onVolumeChanged( qreal volume )
{
    // Only update the volume slider
    // if the fading is not used for volume control
    if (!fadingAvailable)
        emit volumeChanged( volume );
}
Esempio n. 28
0
void MidiDecoder::setVolume(int volume)
{
    d->volume = volume;
    if (d->initialized && !d->muted)
        mid_song_set_volume(d->song, d->volume * 2);

    emit volumeChanged(d->volume);
}
void MusicCoreMPlayer::setVolume(int value)
{
    if(!m_process)
    {
        return;
    }
    emit volumeChanged(value);
    m_process->write(QString("volume %1 1\n").arg(value).toUtf8());
}
Esempio n. 30
0
void MprisPlayer::setVolume(double volume)
{
    if (m_volume == volume) {
        return;
    }

    m_volume = volume;
    emit volumeChanged();
}