Example #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground);

    ui->horizontalSlider->setRange(0, 0);
    ui->tableWidget->hide();
    ui->tableWidget->hideColumn(2);
    volume=80;

    createContextMenu();
    createSystemTrayIcon();

    playList=new QMediaPlaylist;
    playList->setPlaybackMode(QMediaPlaylist::Loop);
    player=new QMediaPlayer;
    player->setPlaylist(playList);
    player->setVolume(volume);

    connect(ui->horizontalSlider, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));
    connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(playTo(int, int)));

    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(playList, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSongList(int)));

    connect(ui->action_SongList, SIGNAL(triggered()), this, SLOT(showOrHideSongList()));
    connect(ui->action_Import, SIGNAL(triggered()), this, SLOT(importSongs()));
    connect(ui->action_Last, SIGNAL(triggered()), this, SLOT(playLast()));
    connect(ui->action_Play, SIGNAL(triggered()), this, SLOT(playOrPause()));
    connect(ui->action_Stop, SIGNAL(triggered()), player, SLOT(stop()));
    connect(ui->action_Next, SIGNAL(triggered()), this, SLOT(playNext()));
    connect(ui->action_SoundPlus, SIGNAL(triggered()), this, SLOT(plusSound()));
    connect(ui->action_SoundReduce, SIGNAL(triggered()), this, SLOT(reduceSound()));
    connect(ui->action_Mode1, SIGNAL(triggered()), this, SLOT(setPlaybackMode1()));
    connect(ui->action_Mode2, SIGNAL(triggered()), this, SLOT(setPlaybackMode2()));
    connect(ui->action_Mode3, SIGNAL(triggered()), this, SLOT(setPlaybackMode3()));
    connect(ui->action_Mode4, SIGNAL(triggered()), this, SLOT(setPlaybackMode4()));
    connect(ui->action_Support, SIGNAL(triggered()), this, SLOT(support()));
    connect(ui->action_About, SIGNAL(triggered()), this, SLOT(aboutUs()));
    connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close()));

    connect(ui->toolButton_Last, SIGNAL(clicked()), this, SLOT(playLast()));
    connect(ui->toolButton_Play, SIGNAL(clicked()), this, SLOT(playOrPause()));
    connect(ui->toolButton_Stop, SIGNAL(clicked()), player, SLOT(stop()));
    connect(ui->toolButton_Next, SIGNAL(clicked()), this, SLOT(playNext()));
}
Example #2
0
Widget::Widget(QWidget *parent) :
		QWidget(parent),
		ui(new Ui::Widget)
{
		ui->setupUi(this);

		this->playStatus = false;
		this->pauseStatus = true;

		ui->videoSlider->setRange(0, 100);
		ui->listWidget->setVisible(false);
		ui->addFileButton->setVisible(false);

		connect(ui->playButton, SIGNAL(clicked()), this, SLOT(playOrPause()));
		connect(ui->videoSlider,SIGNAL(sliderMoved(int)),this, SLOT(seek(int)));
		connect(ui->openButton, SIGNAL(toggled(bool)), this,SLOT(openVideo(bool)));
		connect(ui->stopButton, SIGNAL(clicked()),this,SLOT(stop()));
		connect(ui->kuaijinButton, SIGNAL(clicked()), this, SLOT(kuaijin()));
		connect(ui->kuaituiButton,SIGNAL(clicked()), this,SLOT(kuaitui()));
		connect(ui->addFileButton,SIGNAL(clicked()), this, SLOT(addFileList()));
		connect(ui->listWidget,SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectFile()));
		connect(ui->prevButton, SIGNAL(clicked()), this,SLOT(prevVideo()));
		connect(ui->nextButton, SIGNAL(clicked()), this, SLOT(nextVideo()));
		connect(ui->muteButton, SIGNAL(toggled(bool)), this, SLOT(MuteOrNot(bool)));
		connect(ui->soundAddButton, SIGNAL(clicked()), this, SLOT(soundAdd()));
		connect(ui->soundSubButton, SIGNAL(clicked()), this, SLOT(soundSub()));

		timer = new QTimer(this);
		connect(timer,SIGNAL(timeout()),this,SLOT(get_time_pos()));
		timer->start(1000);

}
void QGstreamerPlayerControl::pause()
{
#ifdef DEBUG_PLAYBIN
    qDebug() << Q_FUNC_INFO;
#endif
    m_userRequestedState = QMediaPlayer::PausedState;

    playOrPause(QMediaPlayer::PausedState);
}
void QGstreamerPlayerControl::play()
{
#ifdef DEBUG_PLAYBIN
    qDebug() << Q_FUNC_INFO;
#endif
    //m_userRequestedState is needed to know that we need to resume playback when resource-policy
    //regranted the resources after lost, since m_currentState will become paused when resources are
    //lost.
    m_userRequestedState = QMediaPlayer::PlayingState;
    playOrPause(QMediaPlayer::PlayingState);
}
Example #5
0
void ControlBar::setupConnection(){
    connect(timer,SIGNAL(timeout()),this,SLOT(timerout()));
    connect(playSlider,SIGNAL(sliderPressed()),this,SLOT(playSliderPressed()));
    connect(playSlider,SIGNAL(sliderReleased()),this,SLOT(playSliderReleased()));
    connect(volumeSlider,SIGNAL(valueChanged(int)),player,SLOT(changeVolume(int)));
    connect(player,SIGNAL(volumeChanged(int)),volumeSlider,SLOT(setValue(int)));
    connect(playBtn,SIGNAL(clicked()),player,SLOT(playOrPause()));
    connect(player,SIGNAL(stateChanged(MPlayerState)),this,SLOT(stateChanged(MPlayerState)));
    connect(player,SIGNAL(streamPositionChanged(double)),this,SLOT(changePlaySliderPosisition(double)));
    connect(fullScreenBtn,SIGNAL(clicked()),parent,SLOT(toggleFullScreen()));
    connect(subtitleBtn,SIGNAL(clicked()),this,SLOT(loadSubtitle()));
}
Example #6
0
void VideoPlayer::createConnections()
{
    connect(mediaObject, SIGNAL(tick(qint64)),
            this, SLOT(tick(qint64)));
    connect(mediaObject,
            SIGNAL(stateChanged(Phonon::State, Phonon::State)),
            this, SLOT(stateChanged(Phonon::State)));
    connect(mediaObject, SIGNAL(finished()), this, SLOT(stop()));
    connect(fullScreenAction, SIGNAL(triggered()),
            videoWidget, SLOT(enterFullScreen()));
    connect(stopAction, SIGNAL(triggered()), this, SLOT(stop()));
    connect(playOrPauseAction, SIGNAL(triggered()),
            this, SLOT(playOrPause()));
}
void QGstreamerPlayerControl::handleResourcesGranted()
{
    pushState();

    //This may be triggered when there is an auto resume
    //from resource-policy, we need to take action according to m_userRequestedState
    //rather than m_currentState
    m_currentState = m_userRequestedState;
    if (m_currentState != QMediaPlayer::StoppedState)
        playOrPause(m_currentState);
    else
        updateMediaStatus();

    popAndNotifyState();
}
Example #8
0
void MainWindow::createActions()
{
    chooseVideoAction = new QAction(QIcon(":/video_folder.png"),
#ifdef Q_WS_MAC
                                    tr("Open Videos"), this);
#else
                                    tr("Open a Video to Play (Ctrl+O)"), this);
    chooseVideoAction->setShortcut(tr("Ctrl+O"));
#endif
    playOrPauseAction = new QAction(playIcon,
#ifdef Q_WS_MAC
                                    tr("Play/Pause"), this);
#else
                                    tr("Play/Pause (Spacebar)"), this);
    (void) new QShortcut(QKeySequence("Space"),
                         this, SLOT(playOrPause()));
#endif
    playOrPauseAction->setDisabled(true);
    stopAction = new QAction(QIcon(":/stop.png"),
#ifdef Q_WS_MAC
                             tr("Stop"), this);
#else
                             tr("Stop (Ctrl+S)"), this);
    stopAction->setShortcut(tr("Ctrl+S"));
#endif
    stopAction->setDisabled(true);
    fullScreenAction = new QAction(QIcon(":/fullscreen.png"),
#ifdef Q_WS_MAC
                                   tr("Full-screen"), this);
#else
                                   tr("Show Full-screen (Ctrl+F). "
                                      "Press Esc or click the mouse to cancel"), this);
    fullScreenAction->setShortcut(tr("Ctrl+F"));
#endif
    videoWidget->installEventFilter(this);
    (void) new QShortcut(QKeySequence("Escape"),
                         videoWidget, SLOT(exitFullScreen()));
#if QT_VERSION >= 0x040600
    QKeySequence quitKeySequence(QKeySequence::Quit);
#else
    QKeySequence quitKeySequence(tr("Ctrl+Q"));
#endif
    quitAction = new QAction(QIcon(":/exit.png"),
                             tr("Quit (%1)").arg(quitKeySequence.toString(
                                         QKeySequence::NativeText)), this);
    quitAction->setShortcut(quitKeySequence);
}
/**
 * @brief SingleFrameVideoViewer::SingleFrameVideoViewer Constructs a SingleFrameVideoViewer.
 */
SingleFrameVideoViewer::SingleFrameVideoViewer() : ViewerPageWidget(), mIsPlaying(false),
    mSFVideo("", QList<QPair<int, Annotation*>>()), mFrameIndex(-1), mIsLooping(false)
{
    Q_INIT_RESOURCE(application);
    connect(ui->mPlayOrPauseButton, SIGNAL(clicked()), this, SLOT(playOrPause()));
    connect(ui->mStopButton, SIGNAL(clicked()), this, SLOT(stop()));
    connect(ui->mLoopButton, SIGNAL(clicked()), this, SLOT(loop()));

    connect(&mTimer, SIGNAL(timeout()), this, SLOT(showFrame()));
    mVideoTime.setInterval(1000);
    connect(&mVideoTime, SIGNAL(timeout()), this, SLOT(showTime()));

    ui->mSlider->setSingleStep(1);
    connect(ui->mSlider, SIGNAL(sliderPressed()), this, SLOT(pause()));
    connect(ui->mSlider, SIGNAL(sliderMoved(int)), this, SLOT(slide(int)));
    connect(ui->mSlider, SIGNAL(sliderReleased()), this, SLOT(play()));
}
Example #10
0
void VideoPlayer::createActions()
{
//    chooseVideoAction = new QAction(QIcon(":/video_folder.png"),
//#ifdef Q_WS_MAC
//            tr("Open Videos"), this);
//#else
//            tr("Open a Video to Play (Ctrl+O)"), this);
//    chooseVideoAction->setShortcut(tr("Ctrl+O"));
//#endif
    playOrPauseAction = new QAction(playIcon,
#ifdef Q_WS_MAC
            tr("Play/Pause"), this);
#else
            tr("Play/Pause (Spacebar)"), this);
    (void) new QShortcut(QKeySequence("Space"),
                         this, SLOT(playOrPause()));
#endif
    playOrPauseAction->setDisabled(false);
    stopAction = new QAction(QIcon(":/images/stop.png"),
#ifdef Q_WS_MAC
            tr("Stop"), this);
#else
            tr("Stop (Ctrl+S)"), this);
    stopAction->setShortcut(tr("Ctrl+S"));
#endif
    stopAction->setDisabled(true);
    fullScreenAction = new QAction(QIcon(":/images/fullscreen.png"),
#ifdef Q_WS_MAC
            tr("Full-screen"), this);
#else
            tr("Show Full-screen (Ctrl+F). "
               "Press Esc or click the mouse to cancel"), this);
    fullScreenAction->setShortcut(tr("Ctrl+F"));
#endif
    videoWidget->installEventFilter(this);
    (void) new QShortcut(QKeySequence("Escape"),
                         videoWidget, SLOT(exitFullScreen()));
}
Example #11
0
Tracker::Tracker(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags), reading_sequence_of_images(false)
{
	ui.setupUi(this);

	connect(ui.actionLoad, SIGNAL(triggered()), this, SLOT(loadFiles()));
	connect(ui.play_pause_button, SIGNAL(clicked()), this, SLOT(playOrPause()));
	connect(ui.stop_button, SIGNAL(clicked()), this, SLOT(restart()));

	// initialize trackers and detector
	detector = new Detector();
	trackers.push_back(new DummyTracker());
	trackers.push_back(new FragTrack());
	

	// Update the UI
	timer = new QTimer(this);
	timer->setInterval(1000/Constants::FPS);
	connect(timer, SIGNAL(timeout()), this, SLOT(nextFrame()));

	frame_number = 0;
	state = STOPPED;
}
Example #12
0
void
SoundCTRL::setView(Ui_meta *view)
{
	this->view = view;
	connect(view, SIGNAL(playSound()), this, SLOT(playOrPauseCTRL()));
	connect(view, SIGNAL(pauseSound()), this, SLOT(playOrPauseCTRL()));
	
	connect(this, SIGNAL(soundPlayed()), this->view, SLOT(playOrPause()));
	connect(this, SIGNAL(soundPlayed()), this->view, SLOT(resetMarkLabels()));
	connect(this, SIGNAL(soundPlayed()), this->view, SLOT(resetClockAndSlider()));
	
	connect(this, SIGNAL(changeAllMarks()), this->view, SLOT(changeMarksLabels()));
	
	connect(view, SIGNAL(nextMark(uint32_t, Format*)), this, SLOT(forward(uint32_t, Format*)));
	connect(view, SIGNAL(prevMark(uint32_t, Format*)), this, SLOT(rewind(uint32_t, Format*)));
	
	connect(view, SIGNAL(forwardTime(Format *)), this, SLOT(fastForward(Format *)));
	connect(view, SIGNAL(rewindTime(Format *)), this, SLOT(fastRewind(Format *)));
	
	connect(this, SIGNAL(clock(int)), this->view, SLOT(updateClock(int)));
	
	connect(view, SIGNAL(update_m_position(uint32_t, Format*)), this, SLOT(set_m_position(uint32_t, Format*)));
	
}
Example #13
0
bool Application::configure()
{
    if ( !QSystemTrayIcon::isSystemTrayAvailable() )
    {
        LOG_ERROR( "application", tr( "No system tray available!" ) );
        QMessageBox::critical( 0, tr( "Error" ), tr( "No system tray available!" ) );
        return false;
    }

    if ( !QSystemTrayIcon::supportsMessages() )
    {
        LOG_ERROR( "application", tr( "System tray not support messages!" ) );
        QMessageBox::critical( 0, tr( "Error" ), tr( "System tray not support messages!" ) );
        return false;
    }

    // Tray icons set.
    trayIconList.append( ":/images/radio-active-2.png" );
    trayIconList.append( ":/images/radio-active-1.png" );
    trayIconList.append( ":/images/radio-active.png"   );
    currTrayIcon = 0;

    // Setup player.    
    connect( &player, SIGNAL( playerTick( quint64 ) ), SLOT( animateIcon( quint64 ) ) );
    connect( &player, SIGNAL( playing() ), SLOT( onPlayerPlay() ) );
    connect( &player, SIGNAL( paused() ), SLOT( onPlayerPause() ) );
    connect( &player, SIGNAL( stopped() ), SLOT( onPlayerStop() ) );
    connect( &player, SIGNAL( errorOccured() ), SLOT( onPlayerError() ) );
    connect( &player, SIGNAL( buffering( int ) ), SLOT( onPlayerBuffering( int ) ) );
    connect( &player, SIGNAL( volumeChanged( int ) ), SLOT( onPlayerVolumeChanged( int ) ) );
    connect( &player, SIGNAL( metaDataChanged( const QMultiMap< QString, QString > ) ),
                      SLOT ( onMetaDataChange( const QMultiMap< QString, QString > ) ) );

    // Setup global shortcuts.
    QxtGlobalShortcut * globalShortcut;
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( pauseHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( playOrPause() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( stopHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( stopPlay() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( volumeUpHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( volumeUp() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( volumeDownHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), &player, SLOT( volumeDown() ) );
    }
    globalShortcut = new QxtGlobalShortcut( &trayItem );
    if ( globalShortcut )
    {
        globalShortcut->setShortcut( QKeySequence( quitHotkey ) );
        connect( globalShortcut, SIGNAL( activated() ), this, SLOT( quit()) );
    }

    // Create stations menu.
    stationsMenu.setTitle( tr( "Stations" ) );
    stationsMenu.setIcon( QIcon( ":/images/radio-passive.png" ) );
    stationsGroup = new QActionGroup( &stationsMenu );
    if ( stationsGroup )
    {
        stationsGroup->setExclusive( true );
        updateStationsMenu();
        connect( stationsGroup, SIGNAL( triggered( QAction * ) ),
                                SLOT( processStationAction( QAction * ) ) );
    }

    // Create base menu.
    trayMenu.addMenu( &stationsMenu );
    trayMenu.addSeparator();
    QAction * action;
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/audio-volume-up.png" ) );
        action->setText( tr( "Volume up" ) );
        action->setShortcut( QKeySequence( volumeUpHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( volumeUp() ) );
        trayMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/audio-volume-down.png" ) );
        action->setText( tr( "Volume down" ) );
        action->setShortcut( QKeySequence( volumeDownHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( volumeDown() ) );
        trayMenu.addAction( action );
    }
    trayMenu.addSeparator();
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/media-playback-start.png" ) );
        action->setText( tr( "Play|Pause" ) );
        action->setShortcut( QKeySequence( pauseHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( playOrPause() ) );
        trayMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/media-playback-stop.png" ) );
        action->setText( tr( "Stop" ) );
        action->setShortcut( QKeySequence( stopHotkey ) );
        connect( action, SIGNAL( triggered() ), &player, SLOT( stopPlay() ) );
        trayMenu.addAction( action );
    }
    trayMenu.addSeparator();
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-info.png" ) );
        action->setText( tr( "Info" ) );
        action->setMenuRole( QAction::AboutRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( about() ) );
        trayMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-exit.png" ) );
        action->setText( tr( "Exit" ) );
        action->setShortcut( QKeySequence( quitHotkey ) );
        action->setMenuRole( QAction::QuitRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( quit() ) );
        trayMenu.addAction( action );
    }

    // Create settings menu.
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-settings.png" ) );
        action->setText( tr( "Settings" ) );
        action->setMenuRole( QAction::PreferencesRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( manageSettings() ) );
        settingsMenu.addAction( action );
    }
    action = new QAction( &trayMenu );
    if ( action )
    {
        action->setIcon( QIcon( ":/images/application-exit.png" ) );
        action->setText( tr( "Exit" ) );
        action->setShortcut( QKeySequence( quitHotkey ) );
        action->setMenuRole( QAction::QuitRole );
        connect( action, SIGNAL( triggered() ), this, SLOT( quit() ) );
        settingsMenu.addAction( action );
    }

    // Setup tray item.
    trayItem.setIcon( QIcon( ":/images/radio-passive.png" ) );
    trayItem.show();
    trayItem.showMessage( tr( "QRadioTray" ), tr( "Program started!" ), QSystemTrayIcon::Information );    
    connect( &trayItem, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
                        SLOT( processTrayActivation( QSystemTrayIcon::ActivationReason ) ) );
    return true;
}
Example #14
0
MainWidget::MainWidget(const QString &token, const QString &user_id, QWidget *parent)
    : QWidget(parent), m_token(token), m_user_id(user_id), m_playState(false)
{
    m_removeCurrent = false;
    m_player = new QMediaPlayer;
    m_player->setVolume(100);

    m_mediaWebPlaylist = new QMediaPlaylist(m_player);
    m_mediaWebPlaylist->setObjectName("web");
    m_player->setPlaylist(m_mediaWebPlaylist);

    loadUserPlaylist();
    this->resize(800, 600);
    this->setWindowTitle("VK Music Player");


    QDir dir("./cache/");
    if(!dir.exists())
        dir.mkpath(".");

    QGridLayout* mainLayout = new QGridLayout;

    m_currentLabel = new QLabel;
    m_currentLabel->setFont(QFont("Arial", 16));
    m_currentLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    mainLayout->addWidget(m_currentLabel, 0, 0, 1, 9, Qt::AlignCenter);

    ImageButton *prevButton = new ImageButton("prevbutton.png");
    mainLayout->addWidget(prevButton, 2, 3, 1, 1, Qt::AlignTop | Qt::AlignRight);

    m_playPauseButton = new ImageButton("playbutton.png");
    mainLayout->addWidget(m_playPauseButton, 2, 4, 1, 1, Qt::AlignTop);

    ImageButton *nextButton = new ImageButton("nextbutton.png");
    mainLayout->addWidget(nextButton, 2, 5, 1, 1, Qt::AlignTop | Qt::AlignLeft);

    m_playlistWidget = new PlaylistWidget;
    mainLayout->addWidget(m_playlistWidget, 3, 0, 3, 9);

    m_seekslider = new QSlider;
    m_seekslider->setOrientation(Qt::Horizontal);
    mainLayout->addWidget(m_seekslider, 1, 0, 1, 7);

    m_volumeSlider = new QSlider;
    m_volumeSlider->setOrientation(Qt::Horizontal);
    m_volumeSlider->setMaximum(100);
    m_volumeSlider->setValue(100);
    m_volumeSlider->setSingleStep(1);
    mainLayout->addWidget(m_volumeSlider, 1, 7, 1, 2);

    m_timeLabel = new QLabel;
    m_timeLabel->setText("0:00");
    mainLayout->addWidget(m_timeLabel, 2, 0, 1, 2, Qt::AlignTop);

    m_volumeLabel = new QLabel;
    m_volumeLabel->setText(QString::number(m_player->volume())+"%");
    mainLayout->addWidget(m_volumeLabel, 2, 7, 1, 2, Qt::AlignTop | Qt::AlignHCenter);

    m_cacheCurrent = new QCheckBox(tr("&Save"));
    mainLayout->addWidget(m_cacheCurrent, 2, 7, 1, 2, Qt::AlignBottom | Qt::AlignRight);

    m_searchEdit = new QLineEdit;
    m_searchEdit->setPlaceholderText(tr("Search"));
    mainLayout->addWidget(m_searchEdit, 2, 0, 1, 8, Qt::AlignBottom);

    this->setLayout(mainLayout);

    connect(this, SIGNAL(playlistReady()),
            SLOT(fillPlaylistWidget_slot()));
    connect(this, SIGNAL(playStateChanged(bool)),
            SLOT(playStateChanged_slot(bool)));

    connect(m_playPauseButton, SIGNAL(pressed()), this, SLOT(playOrPause()));

    connect(nextButton, &ImageButton::pressed,
            [=](){
                m_playlistWidget->setCurrent(m_playlistWidget->getCurrentId()+1);
                m_player->play();
                emit playStateChanged(true);
            });

    connect(prevButton, &ImageButton::pressed,
            [=](){
                m_playlistWidget->setCurrent(m_playlistWidget->getCurrentId()-1);
                m_player->play();
                emit playStateChanged(true);
            });


    connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(mediaStatusChanged_slot(QMediaPlayer::MediaStatus)));

    connect(m_playlistWidget, SIGNAL(currentChanged(PlaylistMember*)),
            this, SLOT(currentChanged_slot(PlaylistMember*)));

    connect(m_player, SIGNAL(positionChanged(qint64)),
            this, SLOT(updateSlider(qint64)));

    connect(m_player, &QMediaPlayer::volumeChanged,
            [=](int v){ m_volumeLabel->setText(QString::number(v)+"%"); });

    connect(m_seekslider, &QSlider::sliderReleased,
            [=](){ m_player->setPosition(m_seekslider->value()); } );
    connect(m_seekslider, &QSlider::sliderMoved,
            [=](int time){
                m_timeLabel->setText(QString("%1:%2").arg((int)time/1000/60).arg(time/1000-time/1000/60*60 < 10 ?
                                                                                     QString("0")+QString::number(time/1000-time/1000/60*60) : QString::number(time/1000-time/1000/60*60)));
            });

    connect(m_volumeSlider,
            &QSlider::valueChanged,
            [=](int v){ m_player->setVolume(v); });

    connect(m_cacheCurrent, SIGNAL(toggled(bool)),
            this, SLOT(cacheCurrentCheckboxChecked(bool)));

    connect(m_searchEdit, SIGNAL(textChanged(QString)),
            m_playlistWidget, SLOT(searchMembersByName(QString)));
}
void QGstreamerPlayerControl::pause()
{
    playOrPause(QMediaPlayer::PausedState);
}
void QGstreamerPlayerControl::play()
{
    playOrPause(QMediaPlayer::PlayingState);
}