Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright (c) [2015] Qualcomm Technologies International, Ltd.
All Rights Reserved.
Qualcomm Technologies Inc. Confidential and Proprietary.
Not a Contribution. Notifications and licenses are retained for attribution
purposes only . Your use of this code is governed by the terms of your license
agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
Except as may be granted by separate express written agreement, this file
provides no rights under or license to any QTIL or its affiliates patents,
trademarks, copyrights,or other intellectual property.
514 changes: 0 additions & 514 deletions LICENSE.LGPL

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# player
Demo player based on Qt and GStreamer
41 changes: 18 additions & 23 deletions clickslider.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
/**********************
** clickslider.cpp
**********************/
/****************************************************************************
**
** Copyright (c) [2015] Qualcomm Technologies International, Ltd.
** All Rights Reserved.
** Qualcomm Technologies Inc. Confidential and Proprietary.
** Not a Contribution. Notifications and licenses are retained for attribution
** purposes only . Your use of this code is governed by the terms of your
** license agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
** Except as may be granted by separate express written agreement, this file
** provides no rights under or license to any QTIL or its affiliates patents,
** trademarks, copyrights,or other intellectual property.
**
****************************************************************************/

#include <QtGui>
#include <QStyleOptionSlider>
#include <QDebug>
Expand All @@ -11,31 +22,15 @@ ClickSlider::ClickSlider( QWidget * parent) :QSlider(parent)

}

/*
void ClickSlider::mousePressEvent ( QMouseEvent * mouseEvent )
{
if(mouseEvent->button()==Qt::LeftButton && isEnabled())
{
int duration = maximum() - minimum();
int pos = minimum() + duration * ((double)mouseEvent->x() / width());
qDebug() << Q_FUNC_INFO << " pos" << pos;
if(pos != sliderPosition())
{
setValue(pos);
}
// else ok.
emit(sliderMoved(pos));
}
}
*/

void ClickSlider::mousePressEvent ( QMouseEvent * event )
{
QStyleOptionSlider opt;
initStyleOption(&opt);
int pos;
int pos = 0;
QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);

pos = value();

if (event->button() == Qt::LeftButton &&
sr.contains(event->pos()) == false)
{
Expand All @@ -47,7 +42,7 @@ void ClickSlider::mousePressEvent ( QMouseEvent * event )

if (invertedAppearance() == true)
{
setValue( maximum() - newVal );
setValue(maximum() - newVal);
pos = maximum() - newVal;
}
else
Expand Down
16 changes: 13 additions & 3 deletions clickslider.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/**********************
** clickslider.h
**********************/
/****************************************************************************
**
** Copyright (c) [2015] Qualcomm Technologies International, Ltd.
** All Rights Reserved.
** Qualcomm Technologies Inc. Confidential and Proprietary.
** Not a Contribution. Notifications and licenses are retained for attribution
** purposes only . Your use of this code is governed by the terms of your
** license agreement with Qualcomm Technologies International, Ltd.(“QTIL”).
** Except as may be granted by separate express written agreement, this file
** provides no rights under or license to any QTIL or its affiliates patents,
** trademarks, copyrights,or other intellectual property.
**
****************************************************************************/

#ifndef CLICKSLIDER_H
#define CLICKSLIDER_H
Expand Down
161 changes: 138 additions & 23 deletions csrplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ csrplayer::csrplayer(QWidget *parent)
player = new QMediaPlayer(this);
// owned by PlaylistModel
playlist = new QMediaPlaylist();
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
player->setPlaylist(playlist);
//! [create-objs]

Expand Down Expand Up @@ -69,12 +70,16 @@ csrplayer::csrplayer(QWidget *parent)

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

ui->openButton->setIcon(style()->standardIcon(QStyle::SP_ComputerIcon));
ui->openButton->setIcon(QIcon(":/icons/resources/ic_open.png"));
ui->openButton->setIconSize(QSize(40, 40));
ui->openButton->setEnabled(true);
connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
this, SLOT(setOpenEnabled(QMediaPlayer::State)));
ui->closeButton->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton));
ui->minimizeButton->setIcon(QIcon(":/icons/resources/ic_minimize.png"));
ui->minimizeButton->setIconSize(QSize(40, 40));
ui->minimizeButton->setEnabled(true);
connect(ui->minimizeButton, SIGNAL(clicked()), this, SLOT(playerMinimize()));
ui->closeButton->setIcon(QIcon(":/icons/resources/ic_close.png"));
ui->closeButton->setIconSize(QSize(40, 40));
connect(ui->openButton, SIGNAL(clicked()), this, SLOT(open()));

Expand All @@ -89,13 +94,23 @@ csrplayer::csrplayer(QWidget *parent)
connect(ui->controls, SIGNAL(previous()), this, SLOT(previousClicked()));
connect(ui->controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
connect(ui->controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool)));
connect(ui->controls, SIGNAL(changeMode(int)), this, SLOT(setMode(int)));

connect(ui->controls, SIGNAL(stop()), ui->videoWidget, SLOT(update()));

connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
ui->controls, SLOT(setState(QMediaPlayer::State)));
connect(player, SIGNAL(volumeChanged(int)), ui->controls, SLOT(setVolume(int)));
connect(player, SIGNAL(mutedChanged(bool)), ui->controls, SLOT(setMuted(bool)));
connect(this, SIGNAL(playModeChanged(int)), ui->controls, SLOT(setMode(int)));

m_pMsgThread = new MsgThread(this, id1, id2);
if (id1 != -1 && id2 != -1)
{
connect(m_pMsgThread, SIGNAL(appResume()), this, SLOT(playerShow()));
connect(this, SIGNAL(appPaused()), m_pMsgThread, SLOT(onAppPaused()));
m_pMsgThread->start();
}

if (!player->isAvailable()) {
QMessageBox::warning(this, tr("Service not available"),
Expand Down Expand Up @@ -124,7 +139,11 @@ csrplayer::~csrplayer()
delete player;
delete playlist;
delete coverLabel;
delete playlistModel;
delete playlistModel;
#ifdef ENABLE_PLAYLISTVIEW
delete playlistView;
#endif
delete m_pMsgThread;
}

void csrplayer::open()
Expand All @@ -134,19 +153,63 @@ void csrplayer::open()
qDebug() << ui->videoWidget->geometry();
#endif

#if 0
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"));
#if 1
//QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Files"));
//addToPlaylist(fileNames);

QFileDialog *fileDialog = new QFileDialog(this);
fileDialog->setOption(QFileDialog::DontUseNativeDialog,true);

QLabel *fileTypeLabel = fileDialog->findChild<QLabel*>("fileTypeLabel");
fileTypeLabel->hide();

QLabel *fileNameLabel = fileDialog->findChild<QLabel*>("fileNameLabel");
fileNameLabel->hide();

QLabel *lookInLabel = fileDialog->findChild<QLabel*>("lookInLabel");
lookInLabel->hide();

QToolButton *backButton = fileDialog->findChild<QToolButton*>("backButton");
backButton->hide();

QToolButton *detailModeButton = fileDialog->findChild<QToolButton*>("detailModeButton");
detailModeButton->hide();

QToolButton *forwardButton = fileDialog->findChild<QToolButton*>("forwardButton");
forwardButton->hide();

QToolButton *listModeButton = fileDialog->findChild<QToolButton*>("listModeButton");
listModeButton->hide();

QToolButton *newFolderButton = fileDialog->findChild<QToolButton*>("newFolderButton");
newFolderButton->hide();

QToolButton *toParentButton = fileDialog->findChild<QToolButton*>("toParentButton");
toParentButton->hide();

QDialogButtonBox *buttonBox = fileDialog->findChild<QDialogButtonBox*>("buttonBox");
//buttonBox->hide();
buttonBox->setOrientation(Qt::Horizontal);

QComboBox *fileTypeCombo = fileDialog->findChild<QComboBox*>("fileTypeCombo");
fileTypeCombo->hide();

fileDialog->setWindowTitle(tr("Open File"));
fileDialog->setDirectory("/media/mmcblk0p6/");
fileDialog->setStyleSheet ("font: 32pt \"Courier\";");
fileDialog->setWindowFlags(Qt::Window);
fileDialog->showFullScreen();
fileDialog->setViewMode(QFileDialog::List);
if(fileDialog->exec() == QDialog::Accepted) {
QStringList fileNames = fileDialog->selectedFiles();
addToPlaylist(fileNames);
}
#else
Dialog *fileDialog = new Dialog(this, "/media/mmcblk1p1/", QFileDialog::List);
fileDialog->setWindowTitle(tr("Open File"));
fileDialog->setStyleSheet ("font: 20pt \"Courier\";");
fileDialog->resize(1024, 600);
/*if(fileDialog->exec() == QDialog::Accepted) {
QString fileNames = fileDialog->GetFile();
qDebug()<<fileNames;
addToPlaylist(QStringList(fileNames));
}*/
//fileDialog->resize(1024, 600);
fileDialog->showMaximized();
fileDialog->exec();
#ifdef DEBUG_OPEN
qDebug()<<fileDialog->GetFile();
Expand All @@ -158,8 +221,7 @@ void csrplayer::open()
#ifdef USE_V4L2sink
#ifdef ENABLE_PLAYLISTVIEW
player->setOverlay(ui->videoWidget->geometry().y(), ui->videoWidget->geometry().x(), ui->videoWidget->geometry().width(), ui->videoWidget->geometry().height());
#else
int x, y, w, h;
#els

if (ui->videoWidget->geometry().width() * DEFAULT_H > ui->videoWidget->geometry().height() * DEFAULE_W)
{
Expand Down Expand Up @@ -229,18 +291,31 @@ void csrplayer::addToPlaylist(const QStringList& fileNames)
}
}

void csrplayer::playerMinimize()
{
player->setOverlay(0, 0, 1, 1);
hide();
emit appPaused();
}

void csrplayer::playerShow()
{
show();
player->setOverlay(y, x, w, h);
}

void csrplayer::durationChanged(qint64 duration)
{
this->duration = duration/1000;
ui->slider->setMaximum(duration / 1000);
this->duration = int(duration/1000.0 + 0.5);
ui->slider->setMaximum(int(duration/1000.0 + 0.5));
}

void csrplayer::positionChanged(qint64 progress)
{
if (!ui->slider->isSliderDown()) {
ui->slider->setValue(progress / 1000);
ui->slider->setValue(progress/1000);
}
updateDurationInfo(progress / 1000);
updateDurationInfo(progress/1000);
}

void csrplayer::metaDataChanged()
Expand Down Expand Up @@ -273,6 +348,41 @@ void csrplayer::previousClicked()
player->setPosition(0);
}

void csrplayer::setMode(int mode)
{
#ifdef DEBUG_OPEN
qDebug() << "Set mode" << mode;
qDebug() << "Current play mode is " << playlist->playbackMode();
#endif

switch (mode) {
case 0:
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
emit playModeChanged(0);
break;
case 1:
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemInLoop);
emit playModeChanged(1);
break;
case 2:
playlist->setPlaybackMode(QMediaPlaylist::Sequential);
emit playModeChanged(2);
break;
case 3:
playlist->setPlaybackMode(QMediaPlaylist::Loop);
emit playModeChanged(3);
break;
case 4:
playlist->setPlaybackMode(QMediaPlaylist::Random);
emit playModeChanged(4);
break;
default:
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
emit playModeChanged(0);
break;
}
}

void csrplayer::jump(const QModelIndex &index)
{
if (index.isValid()) {
Expand All @@ -283,20 +393,25 @@ void csrplayer::jump(const QModelIndex &index)

void csrplayer::playlistPositionChanged(int currentItem)
{
QUrl fileUrl = playlistModel->playlist()->currentMedia().canonicalUrl();
#if 0
#ifdef ENABLE_PLAYLISTVIEW
playlistView->setCurrentIndex(playlistModel->index(currentItem, 0));
#endif
QUrl fileUrl = playlistModel->playlist()->currentMedia().canonicalUrl();
#ifdef DEBUG_OPEN
qDebug() << fileUrl.fileName();
qDebug() << fileUrl.fileName().length();
#endif
ui->label->setText(fileUrl.fileName());
#else
QString dispName = fileUrl.fileName();
if (dispName.length() <= 32) dispName += QString(2*(36-dispName.length()), ' ');
else
dispName += " ";

ui->label->setText(dispName);
#endif
#endif

#ifdef DEBUG_OPEN
qDebug() << fileUrl.fileName();
qDebug() << fileUrl.fileName().length();
#endif
}

void csrplayer::seek(int seconds)
Expand Down
Loading