QXAMediaPlayerControl::QXAMediaPlayerControl(QXAPlaySession *session, QObject *parent)
   :QMediaPlayerControl(parent), mSession(session)
{
    QT_TRACE_FUNCTION_ENTRY;
    connect(mSession, SIGNAL(mediaChanged(const QMediaContent &)),
            this, SIGNAL(mediaChanged(const QMediaContent& )));
    connect(mSession, SIGNAL(durationChanged(qint64)),
            this, SIGNAL(durationChanged(qint64)));
    connect(mSession, SIGNAL(positionChanged(qint64)),
            this, SIGNAL(positionChanged(qint64)));
    connect(mSession, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SIGNAL(stateChanged(QMediaPlayer::State)));
    connect(mSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
    connect(mSession, SIGNAL(volumeChanged(int)),
            this, SIGNAL(volumeChanged(int)));
    connect(mSession, SIGNAL(mutedChanged(bool)),
            this, SIGNAL(mutedChanged(bool)));
    connect(mSession, SIGNAL(audioAvailableChanged(bool)),
            this, SIGNAL(audioAvailableChanged(bool)));
    connect(mSession, SIGNAL(videoAvailableChanged(bool)),
            this, SIGNAL(videoAvailableChanged(bool)));
    connect(mSession,SIGNAL(bufferStatusChanged(int)),
            this, SIGNAL(bufferStatusChanged(int)));
    connect(mSession, SIGNAL(seekableChanged(bool)),
            this, SIGNAL(seekableChanged(bool)));
    connect(mSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)),
            this, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)));
    connect(mSession, SIGNAL(playbackRateChanged(qreal)),
            this, SIGNAL(playbackRateChanged(qreal)));
    connect(mSession, SIGNAL(error(int, const QString &)),
            this, SIGNAL(error(int, const QString &)));
    QT_TRACE_FUNCTION_EXIT;
}
Ejemplo n.º 2
0
 Player::Player(QWidget *parent)
     : QWidget(parent)
     , videoWidget(0)
     , coverLabel(0)
     , slider(0)
     , audioEndpointSelector(0)
 #ifdef Q_OS_SYMBIAN
//     , mediaKeysObserver(0)
     , playlistDialog(0)
     , toggleAspectRatio(0)
     , showYoutubeDialog(0)
     , youtubeDialog(0)
 #else
     , colorDialog(0)
 #endif
 {
     player = new QMediaPlayer(this);
     // owned by PlaylistModel
     playlist = new QMediaPlaylist();
     player->setPlaylist(playlist);

     connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
     connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
     connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
     connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
     connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
             this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
     connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
     connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));

     videoWidget = new VideoWidget(this);
     player->setVideoOutput(videoWidget);

     playlistModel = new PlaylistModel(this);
     playlistModel->setPlaylist(playlist);

     playlistView = new QListView(this);
     playlistView->setModel(playlistModel);
     playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0));

     connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex)));

     slider = new QSlider(Qt::Horizontal, this);
     slider->setRange(0, player->duration() / 1000);

     connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));

     QMediaService *service = player->service();
     if (service) {
         QMediaControl *control = service->requestControl(QAudioEndpointSelector_iid);
         if (control) {
             audioEndpointSelector = qobject_cast<QAudioEndpointSelector*>(control);
             if (audioEndpointSelector) {
                 connect(audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)),
                         this, SLOT(handleAudioOutputChangedSignal(const QString&)));
             } else {
                 service->releaseControl(control);
             }
         }
     }
Ejemplo n.º 3
0
ImageProcessing::ImageProcessing(QWidget *parent) : QMainWindow(parent) {
	iImageIndex = 0;
	m_NetTimeout = 0;
	m_ImageTimeout = 0;

	lbImage = new QLabel(this);
    bTurnOff = false;
    m_notRunning = true;
	setWindowState(Qt::WindowFullScreen);

	player = new QMediaPlayer(this);
    playlist = new QMediaPlaylist();
    player->setPlaylist(playlist);

    m_contentList = new FileDownload(this);
    m_imageFile = new FileDownload(this);

	pNextImage = new QTimer();

	connect(pNextImage, SIGNAL(timeout()), this, SLOT(timeout()));
    connect(m_contentList, SIGNAL(downloaded()), this, SLOT(contentListDownloadComplete()));
    connect(m_contentList, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError)));
    connect(m_imageFile, SIGNAL(downloaded()), this, SLOT(fileDownloadComplete()));
    connect(m_imageFile, SIGNAL(downloadError(QNetworkReply::NetworkError)), this, SLOT(fileDownloadError(QNetworkReply::NetworkError)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));
    connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));
    connect(this, SIGNAL(fileDownloadsComplete()), this, SLOT(unlockShowEvent()));

    videoWidget = new QVideoWidget(this);
    player->setVideoOutput(videoWidget);
    videoWidget->hide();
}
Ejemplo n.º 4
0
void QSWindow::preload(){
    //file control buttons and shortcuts
    setAcceptDrops(true);
    ui->tabWidget->setAcceptDrops(true);
    connect(ui->actionOpen_File, SIGNAL(triggered()), SLOT(openFile()));
    ui->actionOpen_File->setShortcut(QKeySequence::Open);
    connect(ui->actionSave_File, SIGNAL(triggered()), SLOT(saveFile()));
    ui->actionSave_File->setShortcut(QKeySequence::Save);
    connect(ui->actionSave_File_as, SIGNAL(triggered()), SLOT(saveFileAs()));
    ui->actionSave_File_as->setShortcut(QKeySequence::SaveAs);
    connect(ui->actionClose, SIGNAL(triggered()), SLOT(closeFile()));
    ui->actionClose->setShortcut(QKeySequence::Close);


    connect(ui->actionPreset, SIGNAL(triggered()), SLOT(changePreset()));
    connect(ui->actionDisplay_Keyboard, SIGNAL(triggered()), SLOT(displayKeyBoard()));
    ui->actionDisplay_Keyboard->setShortcut(QKeySequence("ctrl+K"));
    connect(ui->actionDisplay_specturm,SIGNAL(triggered()), SLOT(displaySpectrum()));
    connect(ui->actionScore_to_wav, SIGNAL(triggered()), SLOT(scoreToWav()));
    connect(ui->actionWav_to_score, SIGNAL(triggered()), SLOT(wavToScore()));
    connect(ui->menuOpened, SIGNAL(triggered(QAction*)), SLOT(switchScene(QAction*)));

    connect(this,SIGNAL(addFromLameSignal(QString)),this, SLOT(addFromLame(QString)), Qt::QueuedConnection);
   //music state management
    connect(mediaPlayer, SIGNAL(positionChanged(qint64)),
            this,SLOT(positionChanged(qint64)),Qt::QueuedConnection);
    connect(mediaPlayer, SIGNAL(durationChanged(qint64)),
            this, SLOT(durationChanged(qint64)),Qt::QueuedConnection);
    connect(mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this,
            SLOT(mediaStateChanged(QMediaPlayer::State)),Qt::QueuedConnection);
    connect(positionSlider, SIGNAL(sliderReleased()), this, SLOT(setPosition()),Qt::QueuedConnection);
    connect(playButton, SIGNAL(clicked()), this, SLOT(musicPlay()),Qt::QueuedConnection);

    connect(recorder->recordButton, SIGNAL(clicked()), this, SLOT(record()));
}
VideoPlayer::VideoPlayer(QWidget *parent)
    : QWidget(parent)
    , mediaPlayer(0, QMediaPlayer::VideoSurface)
    , videoItem(0)
    , playButton(0)
    , positionSlider(0)
{
    videoItem = new QGraphicsVideoItem;
    videoItem->setSize(QSizeF(640, 480));

    QGraphicsScene *scene = new QGraphicsScene(this);
    QGraphicsView *graphicsView = new QGraphicsView(scene);

    scene->addItem(videoItem);

    QSlider *rotateSlider = new QSlider(Qt::Horizontal);
    rotateSlider->setRange(-180,  180);
    rotateSlider->setValue(0);

    connect(rotateSlider, SIGNAL(valueChanged(int)),
            this, SLOT(rotateVideo(int)));

    QAbstractButton *openButton = new QPushButton(tr("Open..."));
    connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));

    playButton = new QPushButton;
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));

    connect(playButton, SIGNAL(clicked()),
            this, SLOT(play()));

    positionSlider = new QSlider(Qt::Horizontal);
    positionSlider->setRange(0, 0);

    connect(positionSlider, SIGNAL(sliderMoved(int)),
            this, SLOT(setPosition(int)));

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(positionSlider);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(graphicsView);
    layout->addWidget(rotateSlider);
    layout->addLayout(controlLayout);

    setLayout(layout);

    mediaPlayer.setVideoOutput(videoItem);
    connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SLOT(mediaStateChanged(QMediaPlayer::State)));
    connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
}
Ejemplo n.º 6
0
VideoPlayer::VideoPlayer(QWidget *parent)
    : QWidget(parent)
    , mediaPlayer(0, QMediaPlayer::VideoSurface)
    , playButton(0)
    , positionSlider(0)
    , errorLabel(0)
{
    QVideoWidget *videoWidget = new QVideoWidget;

    QAbstractButton *openButton = new QPushButton(tr("Open..."));
    connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));

    playButton = new QPushButton;
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));

    connect(playButton, SIGNAL(clicked()),
            this, SLOT(play()));

    positionSlider = new QSlider(Qt::Horizontal);
    positionSlider->setRange(0, 0);

    connect(positionSlider, SIGNAL(sliderMoved(int)),
            this, SLOT(setPosition(int)));

    errorLabel = new QLabel;
    errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(positionSlider);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(videoWidget);
    layout->addLayout(controlLayout);
    layout->addWidget(errorLabel);

    setLayout(layout);

    mediaPlayer.setVideoOutput(videoWidget);
    connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SLOT(mediaStateChanged(QMediaPlayer::State)));
    connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(&mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(handleError()));

    QFileInfo info("C:\\Users\\MichaU\\Desktop\\ResonanceP1.mp4");
    QMediaPlaylist *lista = new QMediaPlaylist;
    lista->addMedia(QUrl::fromLocalFile(info.absoluteFilePath()));

    mediaPlayer.setPlaylist(lista);
    mediaPlayer.play();

    connect(lista,SIGNAL(currentIndexChanged(int)),this,SLOT(ChangePlaylist()));
}
Ejemplo n.º 7
0
void SMActionVideoNative::connectPlayer()
{

    connect(mediaPlayer, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
    connect(mediaPlayer, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
    connect(mediaPlayer,
            SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            SLOT(mediaStatusChanged(QMediaPlayer::MediaStatus)));
}
Ejemplo n.º 8
0
MyPlayer::MyPlayer()
{
    playerState = NOMUSIC;
    connect(&player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(playNext(QMediaPlayer::MediaStatus)));
    connect(&player, SIGNAL(durationChanged(qint64)), this, SIGNAL(durationChanged(qint64)));
    connect(&player, SIGNAL(durationChanged(qint64)), this, SLOT(musicChanged()));
    connect(&player, SIGNAL(positionChanged(qint64)), this, SIGNAL(positionChanged(qint64)));
    connect(this, SIGNAL(playerStateChanged(int)), this, SLOT(stateChanged(int)));
}
QXAMediaRecoderControl::QXAMediaRecoderControl(QXARecordSession *session, QObject *parent)
:QMediaRecorderControl(parent), m_session(session)
{
    connect(m_session, SIGNAL(stateChanged(QMediaRecorder::State)),
            this, SIGNAL(stateChanged(QMediaRecorder::State)));
    connect(m_session, SIGNAL(error(int,QString)),
        this,SIGNAL(error(int,QString)));
    connect(m_session, SIGNAL(durationChanged(qint64)),
        this, SIGNAL(durationChanged(qint64)));
}
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)));
}
Ejemplo n.º 11
0
void QDeclarativeMediaBase::setObject(QObject *object)
{
    m_qmlObject = object;

    if ((m_mediaProvider = QMediaServiceProvider::defaultServiceProvider()) != 0) {
        if ((m_mediaService = m_mediaProvider->requestService(Q_MEDIASERVICE_MEDIAPLAYER)) != 0) {
            m_playerControl = qobject_cast<QMediaPlayerControl *>(
                    m_mediaService->requestControl(QMediaPlayerControl_iid));
            m_metaDataControl = qobject_cast<QMetaDataReaderControl *>(
                    m_mediaService->requestControl(QMetaDataReaderControl_iid));
            m_mediaObject = new QDeclarativeMediaBaseObject(m_mediaService);
        }
    }

    if (m_playerControl) {
        QObject::connect(m_playerControl, SIGNAL(stateChanged(QMediaPlayer::State)),
                object, SLOT(_q_statusChanged()));
        QObject::connect(m_playerControl, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
                object, SLOT(_q_statusChanged()));
        QObject::connect(m_playerControl, SIGNAL(mediaChanged(QMediaContent)),
                object, SIGNAL(sourceChanged()));
        QObject::connect(m_playerControl, SIGNAL(durationChanged(qint64)),
                object, SIGNAL(durationChanged()));
        QObject::connect(m_playerControl, SIGNAL(positionChanged(qint64)),
                object, SIGNAL(positionChanged()));
        QObject::connect(m_playerControl, SIGNAL(volumeChanged(int)),
                object, SIGNAL(volumeChanged()));
        QObject::connect(m_playerControl, SIGNAL(mutedChanged(bool)),
                object, SIGNAL(mutedChanged()));
        QObject::connect(m_playerControl, SIGNAL(bufferStatusChanged(int)),
                object, SIGNAL(bufferProgressChanged()));
        QObject::connect(m_playerControl, SIGNAL(seekableChanged(bool)),
                object, SIGNAL(seekableChanged()));
        QObject::connect(m_playerControl, SIGNAL(playbackRateChanged(qreal)),
                object, SIGNAL(playbackRateChanged()));
        QObject::connect(m_playerControl, SIGNAL(error(int,QString)),
                object, SLOT(_q_error(int,QString)));

        m_animation = new QDeclarativeMediaBaseAnimation(this);
        m_error = QMediaPlayer::NoError;
    } else {
        m_playerControl = new QDeclarativeMediaBasePlayerControl(object);
    }

    if (!m_metaDataControl)
        m_metaDataControl = new QDeclarativeMediaBaseMetaDataControl(object);

    m_metaData.reset(new QDeclarativeMediaMetaData(m_metaDataControl));

    QObject::connect(m_metaDataControl, SIGNAL(metaDataChanged()),
            m_metaData.data(), SIGNAL(metaDataChanged()));
}
QT_BEGIN_NAMESPACE

QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *session, QObject *parent)
    : QMediaPlayerControl(parent)
    , m_ownStream(false)
    , m_session(session)
    , m_userRequestedState(QMediaPlayer::StoppedState)
    , m_currentState(QMediaPlayer::StoppedState)
    , m_mediaStatus(QMediaPlayer::NoMedia)
    , m_bufferProgress(-1)
    , m_pendingSeekPosition(-1)
    , m_setMediaPending(false)
    , m_stream(0)
{
    m_resources = QMediaResourcePolicy::createResourceSet<QMediaPlayerResourceSetInterface>();
    Q_ASSERT(m_resources);

    connect(m_session, SIGNAL(positionChanged(qint64)),
            this, SIGNAL(positionChanged(qint64)));
    connect(m_session, SIGNAL(durationChanged(qint64)),
            this, SIGNAL(durationChanged(qint64)));
    connect(m_session, SIGNAL(mutedStateChanged(bool)),
            this, SIGNAL(mutedChanged(bool)));
    connect(m_session, SIGNAL(volumeChanged(int)),
            this, SIGNAL(volumeChanged(int)));
    connect(m_session, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SLOT(updateSessionState(QMediaPlayer::State)));
    connect(m_session,SIGNAL(bufferingProgressChanged(int)),
            this, SLOT(setBufferProgress(int)));
    connect(m_session, SIGNAL(playbackFinished()),
            this, SLOT(processEOS()));
    connect(m_session, SIGNAL(audioAvailableChanged(bool)),
            this, SIGNAL(audioAvailableChanged(bool)));
    connect(m_session, SIGNAL(videoAvailableChanged(bool)),
            this, SIGNAL(videoAvailableChanged(bool)));
    connect(m_session, SIGNAL(seekableChanged(bool)),
            this, SIGNAL(seekableChanged(bool)));
    connect(m_session, SIGNAL(error(int,QString)),
            this, SIGNAL(error(int,QString)));
    connect(m_session, SIGNAL(invalidMedia()),
            this, SLOT(handleInvalidMedia()));
    connect(m_session, SIGNAL(playbackRateChanged(qreal)),
            this, SIGNAL(playbackRateChanged(qreal)));

    connect(m_resources, SIGNAL(resourcesGranted()), SLOT(handleResourcesGranted()));
    //denied signal should be queued to have correct state update process,
    //since in playOrPause, when acquire is call on resource set, it may trigger a resourcesDenied signal immediately,
    //so handleResourcesDenied should be processed later, otherwise it will be overwritten by state update later in playOrPause.
    connect(m_resources, SIGNAL(resourcesDenied()), this, SLOT(handleResourcesDenied()), Qt::QueuedConnection);
    connect(m_resources, SIGNAL(resourcesLost()), SLOT(handleResourcesLost()));
}
Ejemplo n.º 13
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()));
}
Ejemplo n.º 14
0
void Music::setConnect()
{
    connect(ui->actionAddfile, SIGNAL(triggered()), this, SLOT(add_file_triggered()));
    connect(ui->actionAddFolder, SIGNAL(triggered()), this, SLOT(add_folder_triggered()));
    connect(ui->actionClear, SIGNAL(triggered()), this, SLOT(clear_clicked()));
    connect(ui->action_once, SIGNAL(triggered()), this, SLOT(once_clicked()));
    connect(ui->action_repeat, SIGNAL(triggered()), this, SLOT(repeat_clicked()));
    connect(ui->action_shuffle, SIGNAL(triggered()), this, SLOT(shuffle_clicked()));
    connect(ui->locate, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));

    connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(player, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));

    connect(ui->listMusic,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(listMusic_customContextMenuRequested(QPoint)));
}
Ejemplo n.º 15
0
VideoPlayer::VideoPlayer(QWidget *parent)
    : QWidget(parent)
    , mediaPlayer(0, QMediaPlayer::VideoSurface)
    , playButton(0)
    , positionSlider(0)
 //   , errorLabel(0)
{
    QVideoWidget *videoWidget = new QVideoWidget;

    QAbstractButton *openButton = new QPushButton(tr("Open..."));
    connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));

    playButton = new QPushButton;
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));

    connect(playButton, SIGNAL(clicked()),
            this, SLOT(play()));

    positionSlider = new QSlider(Qt::Horizontal);
    positionSlider->setRange(0, 0);

    connect(positionSlider, SIGNAL(sliderMoved(int)),
            this, SLOT(setPosition(int)));

    //errorLabel = new QLabel;
    //errorLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(positionSlider);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(videoWidget);
    layout->addLayout(controlLayout);
    //layout->addWidget(errorLabel);

    setLayout(layout);

    mediaPlayer.setVideoOutput(videoWidget);
    connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SLOT(mediaStateChanged(QMediaPlayer::State)));
    connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
    connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(durationChanged(qint64)));
    connect(&mediaPlayer, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(handleError()));
}
Ejemplo n.º 16
0
MusicPlayer::MusicPlayer(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MusicPlayer)
{
    ui->setupUi(this);

    Player = new QMediaPlayer(this);
    PlayList = new QMediaPlaylist;

    connect(Player,SIGNAL(positionChanged(qint64)),this,SLOT(PositionChanged(qint64)));
    connect(ui->LengthSlider,SIGNAL(sliderMoved(int)),this,SLOT(SetPosition(int)));
    connect(Player,SIGNAL(durationChanged(qint64)),this,SLOT(DurationChanged(qint64)));
    connect(Player,SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),this,SLOT(StatusChanged(QMediaPlayer::MediaStatus)));
    connect(ui->VolumeSlider,SIGNAL(valueChanged(int)),this,SLOT(SetVolume(int)));

    connect(ui->button_start,SIGNAL(released()),this,SLOT(Play()));
    connect(ui->button_stop,SIGNAL(released()),this,SLOT(Stop()));

    connect(ui->button_next,SIGNAL(released()),this,SLOT(Next()));
    connect(ui->button_prev,SIGNAL(released()),this,SLOT(Prev()));

    connect(ui->button_add,SIGNAL(released()),this,SLOT(Add()));
    connect(ui->button_remove,SIGNAL(released()),this,SLOT(Remove()));

    connect(ui->playlist,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(PlaySelected(QModelIndex)));

    connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(SavePlayList()));
    connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(OpenPlayList()));

    Player->setPlaylist(PlayList);

    ui->VolumeSlider->setRange(0,100);
    ui->VolumeSlider->setValue(100);
}
Ejemplo n.º 17
0
MultimediaWidget::MultimediaWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MultimediaWidget){
  ui->setupUi(this); //load the designer file

  //Add in the special QMultimediaWidgets
  mediaObj = new QMediaPlayer(this);
    mediaObj->setVolume(100);
    mediaObj->setNotifyInterval(500); //only every 1/2 second update
  videoDisplay = new QVideoWidget(this);
    videoDisplay->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    ui->videoLayout->addWidget(videoDisplay);
    mediaObj->setVideoOutput(videoDisplay);
    videoDisplay->setVisible(false);

  UpdateIcons();
  UpdateText();

  //Connect the special signals/slots for the media object
  connect(mediaObj, SIGNAL(durationChanged(qint64)), this, SLOT(playerDurationChanged(qint64)) );
  connect(mediaObj, SIGNAL(seekableChanged(bool)), ui->playerSlider, SLOT(setEnabled(bool)) );
  connect(mediaObj, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(playerStatusChanged(QMediaPlayer::MediaStatus)) );
  connect(mediaObj, SIGNAL(positionChanged(qint64)), this, SLOT(playerTimeChanged(qint64)) );
  connect(mediaObj, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged(QMediaPlayer::State)) );
  connect(mediaObj, SIGNAL(videoAvailableChanged(bool)), this, SLOT(playerVideoAvailable(bool)) );
  connect(mediaObj, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(playerError()) );

  //Disable some of the initial states
  ui->tool_player_stop->setEnabled(false); //nothing to stop yet
  ui->tool_player_pause->setVisible(false); //nothing to pause yet
  ui->playerSlider->setEnabled(false); //nothing to seek yet
}
Ejemplo n.º 18
0
void TestItem::setDuration(int duration){
    if (duration != m_duration){
        m_duration = duration;
        emit durationChanged();
        emit dataChanged();
    }
}
Ejemplo n.º 19
0
void MainWindow::on_actionImport_Song_triggered()
{
    audioFileName = QFileDialog::getOpenFileName(this, tr("Open File"),"/home/matt/Desktop",tr("Audio (*.mp3 *.wav)"));
    if(audioFileName!="")
    {
        if(thePlayer!=NULL)
        {
            delete thePlayer;
            thePlayer=NULL;
        }
        thePlayer = new QMediaPlayer();
        thePlayer->setNotifyInterval(20);
        connect(thePlayer,SIGNAL(durationChanged(qint64)),this,SLOT(updateSongDuration(qint64)));
        connect(thePlayer,SIGNAL(stateChanged(QMediaPlayer::State)),this,SLOT(checkForNextSong(QMediaPlayer::State)));
        connect(thePlayer,SIGNAL(positionChanged(qint64)),ui->label_2,SLOT(playPositionChanged(qint64)));
        connect(ui->label_2,SIGNAL(userChangePlayPosition(qint64)),thePlayer,SLOT(setPosition(qint64)));

        thePlayer->setMedia(QUrl::fromLocalFile(audioFileName));
        if(ui->label_2->isSongAdded())
        {
            tempTrackCount=ui->label_2->getChannelSize();
            ui->label_2->clearAllData();
            ui->label_2->resetSongAdded();
        }

    }
}
Ejemplo n.º 20
0
PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::PlayerWidget()){
  ui->setupUi(this); //load the designer form
  PLAYER = new QMediaPlayer(this);
    PLAYER->setVolume(100);
    PLAYER->setNotifyInterval(1000); //1 second interval (just needs to be a rough estimate)
  PLAYLIST = new QMediaPlaylist(this);
    PLAYLIST->setPlaybackMode(QMediaPlaylist::Sequential);
    PLAYER->setPlaylist(PLAYLIST);
	
  configMenu = new QMenu(this);
    ui->tool_config->setMenu(configMenu);
  addMenu = new QMenu(this);
    ui->tool_add->setMenu(addMenu);
	
  updatinglists = false; //start off as false
	
  LoadIcons();
  playerStateChanged(); //update button visibility
  currentSongChanged();
  //Connect all the signals/slots
  //connect(infoTimer, SIGNAL(timeout()), this, SLOT(rotateTrackInfo()) );
  connect(PLAYER, SIGNAL(positionChanged(qint64)),this, SLOT(updateProgress(qint64)) );
  connect(PLAYER, SIGNAL(durationChanged(qint64)), this, SLOT(updateMaxProgress(qint64)) );
  connect(PLAYLIST, SIGNAL(mediaChanged(int, int)), this, SLOT(playlistChanged()) );
  connect(PLAYER, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged()) );
  connect(PLAYLIST, SIGNAL(currentMediaChanged(const QMediaContent&)), this, SLOT(currentSongChanged()) );
  connect(ui->combo_playlist, SIGNAL(currentIndexChanged(int)), this, SLOT(userlistSelectionChanged()) );
  connect(ui->tool_play, SIGNAL(clicked()), this, SLOT(playClicked()) );
  connect(ui->tool_pause, SIGNAL(clicked()), this, SLOT(pauseClicked()) );
  connect(ui->tool_stop, SIGNAL(clicked()), this, SLOT(stopClicked()) );
  connect(ui->tool_next, SIGNAL(clicked()), this, SLOT(nextClicked()) );
  connect(ui->tool_prev, SIGNAL(clicked()), this, SLOT(prevClicked()) );
  
}
void DirectShowPlayerControl::emitPropertyChanges()
{
    int properties = m_updateProperties;
    m_updateProperties = 0;

    if ((properties & ErrorProperty) && m_error != QMediaPlayer::NoError)
        emit error(m_error, m_errorString);

    if (properties & PlaybackRateProperty)
        emit playbackRateChanged(m_playbackRate);

    if (properties & StreamTypesProperty) {
        emit audioAvailableChanged(m_streamTypes & DirectShowPlayerService::AudioStream);
        emit videoAvailableChanged(m_streamTypes & DirectShowPlayerService::VideoStream);
    }

    if (properties & PositionProperty)
        emit positionChanged(m_position);

    if (properties & DurationProperty)
        emit durationChanged(m_duration);

    if (properties & SeekableProperty)
        emit seekableChanged(m_seekable);

    if (properties & StatusProperty)
        emit mediaStatusChanged(m_status);

    if (properties & StateProperty)
        emit stateChanged(m_state);
}
Ejemplo n.º 22
0
QT_BEGIN_NAMESPACE

/*------------------------------------------------------------------------------
|    OpenMAXILPlayerControl::OpenMAXILPlayerControl
+-----------------------------------------------------------------------------*/
OpenMAXILPlayerControl::OpenMAXILPlayerControl(QObject *parent)
   : QMediaPlayerControl(parent)
   , m_ownStream(false)
   , m_seekToStartPending(false)
	, m_pendingSeekPosition(-1)
	, m_texProvider(make_shared<OMX_EGLBufferProvider>())
	, m_mediaProcessor(new OMX_MediaProcessor(m_texProvider))
   , m_renderer(NULL)
{
	logi_debug_func;

   connect(m_mediaProcessor, SIGNAL(stateChanged(OMX_MediaProcessor::OMX_MediaProcessorState)),
           this, SLOT(onStateChanged(OMX_MediaProcessor::OMX_MediaProcessorState)));
	connect(m_mediaProcessor, SIGNAL(mediaStatusChanged(OMX_MediaProcessor::OMX_MediaStatus)),
			  this, SLOT(onMediaStatusChanged(OMX_MediaProcessor::OMX_MediaStatus)));
   connect(m_mediaProcessor, SIGNAL(metadataChanged(QVariantMap)),
			  this, SIGNAL(metaDataChanged(QVariantMap)));
	connect(m_mediaProcessor, SIGNAL(streamLengthChanged(qint64)),
			  this, SIGNAL(durationChanged(qint64)));
}
Ejemplo n.º 23
0
void PlayerWidget::onBtnOpen_Clicked()
{
	std::unique_ptr<Player> player(MusicSelector::select());
	if (player == nullptr)
		return ;

	if (m_player)
	{
		m_player->disconnect();
		m_player->deleteLater();
	}

	m_player = std::move(player);

	m_ui->le_Title->setText(m_player->metaData(Player::Title).toString());
	m_ui->le_Artist->setText(m_player->metaData(Player::Artist).toString());
	m_ui->le_Album->setText(m_player->metaData(Player::AlbumTitle).toString());

	updateTitle();

	m_ui->btn_PlayPause->setEnabled(true);
	m_ui->slider_Duration->setEnabled(m_player->isSeekable());
	m_ui->slider_Duration->setMaximum(m_player->duration());
	m_ui->slider_Duration->setValue(m_player->position());

	onPlayerPositionChanged(m_player->position());
	onPlayerStateChanged(m_player->state());

	connect(m_player.get(), SIGNAL(stateChanged(Player::State)), this, SLOT(onPlayerStateChanged(Player::State)));
	connect(m_player.get(), SIGNAL(durationChanged(qint64)), this, SLOT(onPlayerDurationChanged(qint64)));
	connect(m_player.get(), SIGNAL(positionChanged(qint64)), this, SLOT(onPlayerPositionChanged(qint64)));
	connect(m_player.get(), SIGNAL(metaDataChanged(Player::MetaData,QVariant)), this, SLOT(onPlayerMetadataChanged(Player::MetaData,QVariant)));
}
Ejemplo n.º 24
0
AudioDecoder::AudioDecoder(bool isPlayback, bool isDelete)
    : m_cout(stdout, QIODevice::WriteOnly)
{
    m_isPlayback = isPlayback;
    m_isDelete = isDelete;

    // Make sure the data we receive is in correct PCM format.
    // Our wav file writer only supports SignedInt sample type.
    QAudioFormat format;
    format.setChannelCount(2);
    format.setSampleSize(16);
    format.setSampleRate(48000);
    format.setCodec("audio/pcm");
    format.setSampleType(QAudioFormat::SignedInt);
    m_decoder.setAudioFormat(format);

    connect(&m_decoder, SIGNAL(bufferReady()), this, SLOT(bufferReady()));
    connect(&m_decoder, SIGNAL(error(QAudioDecoder::Error)), this, SLOT(error(QAudioDecoder::Error)));
    connect(&m_decoder, SIGNAL(stateChanged(QAudioDecoder::State)), this, SLOT(stateChanged(QAudioDecoder::State)));
    connect(&m_decoder, SIGNAL(finished()), this, SLOT(finished()));
    connect(&m_decoder, SIGNAL(positionChanged(qint64)), this, SLOT(updateProgress()));
    connect(&m_decoder, SIGNAL(durationChanged(qint64)), this, SLOT(updateProgress()));

    connect(&m_soundEffect, SIGNAL(statusChanged()), this, SLOT(playbackStatusChanged()));
    connect(&m_soundEffect, SIGNAL(playingChanged()), this, SLOT(playingChanged()));

    m_progress = -1.0;
}
Ejemplo n.º 25
0
void QAndroidMediaPlayerControl::onMediaPlayerInfo(qint32 what, qint32 extra)
{
    switch (what) {
    case JMediaPlayer::MEDIA_PLAYER_INVALID_STATE:
        setError(what, QStringLiteral("Error: Invalid state"));
        break;
    case JMediaPlayer::MEDIA_PLAYER_PREPARING:
        setMediaStatus(QMediaPlayer::LoadingMedia);
        setState(QMediaPlayer::StoppedState);
        break;
    case JMediaPlayer::MEDIA_PLAYER_READY:
        setMediaStatus(QMediaPlayer::LoadedMedia);
        if (mBuffering) {
            setMediaStatus(mBufferPercent == 100 ? QMediaPlayer::BufferedMedia
                                                 : QMediaPlayer::BufferingMedia);
        } else {
            onBufferChanged(100);
        }
        setAudioAvailable(true);
        mMediaPlayerReady = true;
        flushPendingStates();
        break;
    case JMediaPlayer::MEDIA_PLAYER_DURATION:
        Q_EMIT durationChanged(extra);
        break;
    case JMediaPlayer::MEDIA_PLAYER_PROGRESS:
        Q_EMIT positionChanged(extra);
        break;
    case JMediaPlayer::MEDIA_PLAYER_FINISHED:
        stop();
        setMediaStatus(QMediaPlayer::EndOfMedia);
        break;
    }
}
Ejemplo n.º 26
0
/*!
 Sets the song \a duration.
*/
void MpPlaybackData::setDuration( int duration )
{
    TX_ENTRY_ARGS( "duration = " << duration )
    mDuration = duration;
    emit durationChanged();
    TX_EXIT
}
Ejemplo n.º 27
0
inline void KNMusicBackendMpvThread::checkStartAndEndPosition()
{
    //Check out the start position.
    if(m_startPosition==-1)
    {
        //Start position is invalid, then play the whole file.
        m_startPosition=0;
        //Set the whole file as the end position.
        m_duration=m_totalDuration;
        m_endPosition=m_totalDuration;
    }
    else
    {
        //Check out the end position and the start position.
        if(m_endPosition>m_totalDuration)
        {
            //The end position cannot the greater than the total duration.
            m_endPosition=m_totalDuration;
        }
        //Check out the start position to the end position.
        if(m_startPosition > m_endPosition)
        {
            //Set the start position lesser than the end position.
            m_startPosition=m_endPosition;
        }
        //Calculate the duration.
        m_duration=m_endPosition-m_startPosition;
    }
    //Emit the duration changed signal.
    emit durationChanged(m_duration);
    //Move the player to the start position.
    setPosition(0);
}
Ejemplo n.º 28
0
void MFPlayerControl::handleDurationUpdate(qint64 duration)
{
    if (m_duration == duration)
        return;
    m_duration = duration;
    emit durationChanged(m_duration);
}
Ejemplo n.º 29
0
Transcribe::Transcribe(QObject* parent) :
  QObject(parent),
  m_player(new AudioPlayer(this), std::mem_fn(&AudioPlayer::deleteLater)),
  m_keeper(m_player),
  m_engine(this) {

  connect(m_player.get(), SIGNAL(error(const QString&)),
          this,           SLOT(errorDetected(const QString&)));
  connect(m_player.get(), SIGNAL(durationChanged()),
          this,           SLOT(mediaDurationChanged()));

  // Expose the various objects to the gui for setting and getting properties
  // and such
  m_engine.rootContext()->setContextProperty("app",            this);
  m_engine.rootContext()->setContextProperty("player",         m_player.get());
  m_engine.rootContext()->setContextProperty("typingtimelord", &m_keeper);
  m_engine.rootContext()->setContextProperty("history",        &m_history);

  // This is a bit of quirkiness of Qt; you can't declare an enum as a QML type,
  // but you can declare a C++ class with a public enum as a QML library, and
  // then access the enum values as properties. So we expose the "AudioPlayer"
  // (the class) as "PlayerState" in QML.
  qmlRegisterType<AudioPlayer>("AudioPlayer", 1, 0, "PlayerState");

  m_engine.addImageProvider(QLatin1String("translatedicon"),
                            new IconTranslationMatrix);

  // Load the GUI. When it is ready, the guiReady() method takes over.
  connect(&m_engine, SIGNAL(objectCreated(QObject*, QUrl)),
          this,      SLOT(guiReady(QObject*)));
  m_engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
}
Ejemplo n.º 30
0
//! [6]
void MusicPlayer::createThumbnailToolBar()
{
    thumbnailToolBar = new QWinThumbnailToolBar(this);
    thumbnailToolBar->setWindow(windowHandle());

    playToolButton = new QWinThumbnailToolButton(thumbnailToolBar);
    playToolButton->setEnabled(false);
    playToolButton->setToolTip(tr("Play"));
    playToolButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
    connect(playToolButton, SIGNAL(clicked()), this, SLOT(togglePlayback()));

    forwardToolButton = new QWinThumbnailToolButton(thumbnailToolBar);
    forwardToolButton->setEnabled(false);
    forwardToolButton->setToolTip(tr("Fast forward"));
    forwardToolButton->setIcon(style()->standardIcon(QStyle::SP_MediaSeekForward));
    connect(forwardToolButton, SIGNAL(clicked()), this, SLOT(seekForward()));

    backwardToolButton = new QWinThumbnailToolButton(thumbnailToolBar);
    backwardToolButton->setEnabled(false);
    backwardToolButton->setToolTip(tr("Rewind"));
    backwardToolButton->setIcon(style()->standardIcon(QStyle::SP_MediaSeekBackward));
    connect(backwardToolButton, SIGNAL(clicked()), this, SLOT(seekBackward()));
    thumbnailToolBar->addButton(backwardToolButton);
    thumbnailToolBar->addButton(playToolButton);
    thumbnailToolBar->addButton(forwardToolButton);

    connect(&mediaPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(updateThumbnailToolBar()));
    connect(&mediaPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(updateThumbnailToolBar()));
    connect(&mediaPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(updateThumbnailToolBar()));
}