-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayerwidget.cpp
More file actions
74 lines (62 loc) · 1.71 KB
/
playerwidget.cpp
File metadata and controls
74 lines (62 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "playerwidget.h"
#include "ui_playerwidget.h"
playerWidget::playerWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::playerWidget)
{
ui->setupUi(this);
mObject = new Phonon::MediaObject(this);
aOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
path = Phonon::createPath(mObject, aOutput);
ui->volumeSlider->setAudioOutput(aOutput);
ui->seekSlider->setMediaObject(mObject);
connect(mObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinishSlot()));
}
playerWidget::~playerWidget()
{
delete ui;
}
void playerWidget::play(PlaylistItem *item){
ui->songLbl->setText(tr("%1 - %2").arg(item->artist)
.arg(item->song));
ui->timeLbl->setText(item->time);
mObject->setCurrentSource(item->url);
mObject->play();
}
void playerWidget::fillFields(PlaylistItem *item){
ui->songLbl->setText(tr("%1 - %2").arg(item->artist)
.arg(item->song));
ui->timeLbl->setText(item->time);
}
QString playerWidget::time(int time){
QString timeString;
int sec = time;
int min = sec / 60;
int hour = min / 60;
int msec = time;
QTime playTime(hour%60, min%60, sec%60, msec%1000);
QString timeFormat = "m:ss";
if (hour > 0)
timeFormat = "h:mm:ss";
timeString = playTime.toString(timeFormat);
return timeString;
}
void playerWidget::aboutToFinishSlot(){
emit aboutToFinish();
}
void playerWidget::saveSelected(PlaylistItem *item){
selectedItem = item;
}
void playerWidget::on_toolButton_clicked()
{
if (selectedItem)
play(selectedItem);
}
void playerWidget::on_nextBtn_clicked()
{
emit playNext();
}
void playerWidget::on_prevBtn_clicked()
{
emit playPrev();
}