AudioPlaybackBlock::AudioPlaybackBlock(MainController* controller, QString uid)
    : BlockBase(controller, uid)
    , m_playNode(nullptr)
    , m_pauseNode(nullptr)
    , m_toggleNode(nullptr)
    , m_activeNode(nullptr)
    , m_endNode(nullptr)
    , m_positionNode(nullptr)
    , m_filePath("")
    , m_lastPlayNodeValue(0.0)
    , m_lastPauseNodeValue(0.0)
    , m_lastToggleNodeValue(0.0)
    , m_alwaysStartAtBegin(false)
    , m_loop(false)
    , m_toggleMode(true)
    , m_player(this)
{
    m_widthIsResizable = true;

    m_playNode = createInputNode("playNode");
    m_pauseNode = createInputNode("pauseNode");
    m_toggleNode = createInputNode("toggleNode");
    connect(m_playNode, SIGNAL(dataChanged()), this, SLOT(onPlayNodeValueChanged()));
    connect(m_pauseNode, SIGNAL(dataChanged()), this, SLOT(onPauseNodeValueChanged()));
    connect(m_toggleNode, SIGNAL(dataChanged()), this, SLOT(onToggleNodeValueChanged()));

    m_activeNode = createOutputNode("activeNode");
    m_endNode = createOutputNode("endNode");
    m_positionNode = createOutputNode("positionNode");

    // setup Timer to be able to send a short pulse when end of file is reached:
    m_endPulseTimer.setSingleShot(true);
    m_endPulseTimer.setInterval(100);
    connect(&m_endPulseTimer, SIGNAL(timeout()), this, SLOT(onEndPulseTimeout()));

    connect(&m_player, SIGNAL(endOfFile()), this, SLOT(onEndOfFile()));
    connect(&m_player, SIGNAL(isPlayingChanged()), this, SIGNAL(isPlayingChanged()));
    connect(&m_player, SIGNAL(isPlayingChanged()), this, SLOT(onIsPlayingChanged()));
    connect(&m_player, SIGNAL(positionChanged()), this, SIGNAL(playbackPositionChanged()));
    connect(&m_player, SIGNAL(positionChanged()), this, SLOT(onPlaybackPositionChanged()));
    connect(&m_player, SIGNAL(lengthChanged()), this, SIGNAL(lengthChanged()));

    connect(&m_waveform, SIGNAL(pointsChanged()), this, SIGNAL(waveformChanged()));
    connect(&m_waveform, SIGNAL(availableChanged()), this, SIGNAL(waveformChanged()));
}
Example #2
0
void QSpotifySession::beginPlayBack(bool notifyThread)
{
    qDebug() << "QSpotifySession::beginPlayBack";
    sp_session_player_play(m_sp_session, true);
    m_isPlaying = true;
    emit isPlayingChanged();

    if(notifyThread)
        QCoreApplication::postEvent(g_audioWorker, new QEvent(QEvent::Type(ResumeEventType)));
}
Example #3
0
void QSpotifySession::pause(bool notifyThread)
{
    qDebug() << "QSpotifySession::pause";
    if (!m_isPlaying)
        return;

    sp_session_player_play(m_sp_session, false);
    m_isPlaying = false;
    emit isPlayingChanged();

    if(notifyThread)
        QCoreApplication::postEvent(g_audioWorker, new QEvent(QEvent::Type(SuspendEventType)));
}
Example #4
0
void QSpotifySession::stop(bool dontEmitSignals)
{
    qDebug() << "QSpotifySession::stop";
    if (!m_isPlaying && !m_currentTrack)
        return;

    sp_session_player_unload(m_sp_session);
    m_isPlaying = false;
    m_currentTrack.reset();
    m_currentTrackPosition = 0;
    m_currentTrackPlayedDuration = 0;

    if (!dontEmitSignals) {
        emit isPlayingChanged();
        emit currentTrackChanged();
        emit currentTrackPositionChanged();
    }

    QCoreApplication::postEvent(g_audioWorker, new QEvent(QEvent::Type(AudioStopEventType)));
}
Example #5
0
MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
{
    m_c = Core::instance();
    m_c->loadPlugins();
    connect(m_c, SIGNAL(isPlayingChanged()), this, SLOT(changeIconState()));
    connect(m_c, SIGNAL(posChanged(int)), this, SLOT(changeIconPercent(int)));
    connect(m_c, SIGNAL(mainColorChanged()), this, SLOT(repaint()));
    setWindowTitle(QString("Xound - What's a life without music?"));
    setWindowIcon(QIcon(QString(":/Icon.png")));
    setMinimumSize(600, 400);
    setMouseTracking(true);
    setGeometry(m_c->geometry());

    m_mc = new MusicControl(this);
    connect(m_c, SIGNAL(videoAppearanceChanged(bool)), this, SLOT(videoAppearanceChanged(bool))); // It has to be called after the creation of m_mc
    m_wz = new WorkZone(this);

    m_video = new Video(this);
    m_video->hide();
    m_c->setVideoWidget(m_video);

    m_sizeGrip = new QSizeGrip(this);
    m_sizeGrip->setGeometry(width() - 32, height() - 32, 32, 32);
    m_sizeGrip->hide();

    m_menu = new QMenu("Xound", this);
    m_menu->setTitle("Xound");
    m_menu->addAction(QIcon(":/Systray_Player_Play.png"), tr("Play/Pause"), m_mc, SLOT(play()));
    m_menu->addAction(QIcon(":/Systray_Maximize.png"), tr("Show"), this, SLOT(show()));
    m_menu->addAction(QIcon(":/Systray_Close.png"), tr("Quit"), this, SLOT(quit()));
    m_menu->setIcon(QIcon(QString(":/Icon.png")));

    m_icon = new QSystemTrayIcon(QIcon(":/Icon.png"), this);
    m_icon->setVisible(true);
    m_icon->setContextMenu(m_menu);
    connect(m_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivities(QSystemTrayIcon::ActivationReason)));
}
Example #6
0
MusicControl::MusicControl(QWidget *parent) : QWidget(parent)
{
    setStyleSheet("QPushButton{ background-color: transparent; border: none; color:white; }"
                  "QPushButton:pressed{ background-color: qradialgradient(spread:pad, cx:0.468355, cy:0.472, radius:0.449, fx:0.472658, fy:0.477045, stop:0.261603 rgba(255, 255, 255, 130), stop:1 rgba(255, 255, 255, 0));}"
                  "QPushButton:checked{ background-color: qradialgradient(spread:pad, cx:0.468355, cy:0.472, radius:0.449, fx:0.472658, fy:0.477045, stop:0.261603 rgba(255, 255, 255, 130), stop:1 rgba(255, 255, 255, 0));}"
                  "QLabel{ color:white; }");

    m_c = Core::instance();
    connect(m_c, SIGNAL(lengthChanged()), this, SLOT(updateTime()));
    connect(m_c, SIGNAL(posChanged(int)), this, SLOT(updateTime()));
    connect(m_c, SIGNAL(tagsChanged()), this, SLOT(showTags()));
    connect(m_c, SIGNAL(currentMusicChanged()), this, SLOT(musicChanged()));
    connect(m_c, SIGNAL(videoAppearanceChanged(bool)), this, SLOT(moveWidgets()));
    connect(m_c, SIGNAL(isPlayingChanged()), this, SLOT(isPlayingChanged()));

    m_cover = new Cover(this);

    m_musicTagsLabel = new QLabel(this);
    m_musicTagsLabel->setAlignment(Qt::AlignCenter);
    m_musicTagsLabel->setText(QString(tr("<b>Welcome!</b>")));
    QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect();
    shadowEffect->setOffset(1, 1);
    m_musicTagsLabel->setGraphicsEffect(shadowEffect);

//Player button, slider and label
    m_previousButton = new QPushButton(this);
    m_previousButton->setIcon(QIcon(QString(":/Player_Previous.png")));
    m_previousButton->setIconSize(QSize(32, 32));
    m_previousButton->setShortcut(QKeySequence(Qt::Key_Left));
    m_previousButton->setToolTip(tr("Previous media in the playlist"));
    connect(m_previousButton, SIGNAL(clicked()), this, SLOT(previous()));

    m_playButton = new QPushButton(this);
    m_playButton->setIcon(QIcon(QString(":/Player_Play.png")));
    m_playButton->setIconSize(QSize(50, 50));
    m_playButton->setShortcut(QKeySequence(Qt::Key_Space));
    m_playButton->setToolTip(tr("Play/Pause"));
    connect(m_playButton, SIGNAL(clicked()), this, SLOT(play()));

    m_nextButton = new QPushButton(this);
    m_nextButton->setIcon(QIcon(QString(":/Player_Next.png")));
    m_nextButton->setIconSize(QSize(32, 32));
    m_nextButton->setShortcut(QKeySequence(Qt::Key_Right));
    m_nextButton->setToolTip(tr("Next media in the playlist"));
    connect(m_nextButton, SIGNAL(clicked()), this, SLOT(next()));

    m_volumeIcon = new QPushButton(this);
    m_volumeIcon->setIcon(QIcon(":/Volume.png"));
    m_volumeIcon->setIconSize(m_volumeIcon->size());
    m_volumeIcon->setToolTip(tr("Mute or not"));
    connect(m_volumeIcon, SIGNAL(clicked()), this, SLOT(mute()));
    m_volumeIcon->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));

    m_volumeSlider = new QSlider(this);
    m_volumeSlider->setOrientation(Qt::Vertical);
    m_volumeSlider->setToolTip(tr("Change the volume"));
    m_volumeSlider->setValue(m_c->volume());
    m_volumeSlider->setMaximum(200);
    connect(m_volumeSlider, SIGNAL(valueChanged(int)), m_c, SLOT(setVolume(int)));

    m_seekSlider = new QSlider(this);
    m_seekSlider->setOrientation(Qt::Horizontal);
    m_seekSlider->setToolTip(tr("Change the position in the media"));
    connect(m_seekSlider, SIGNAL(sliderMoved(int)), m_c, SLOT(setPosition(int)));

    m_timeLabel = new QLabel(this);
    m_timeLabel->setMinimumSize(150, 0);
    m_timeLabel->setAlignment(Qt::AlignRight);
    m_timeLabel->setText("0:00 / 0:00");

    m_randButton = new QPushButton(this);
    m_randButton->setIconSize(QSize(22, 22));
    m_randButton->setIcon(QIcon(QString(":/Random.png")));
    m_randButton->setCheckable(true);
    m_randButton->setToolTip(tr("Random medias in the playlist or not"));
    m_randButton->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));

    m_repeatButton = new QPushButton(this);
    m_repeatButton->setIconSize(QSize(22, 22));
    m_repeatButton->setIcon(QIcon(QString(":/Repeat.png")));
    m_repeatButton->setCheckable(true);
    m_repeatButton->setToolTip(tr("Repeat the media or not"));
    m_repeatButton->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));

    moveWidgets();
}