-
Notifications
You must be signed in to change notification settings - Fork 0
/
videoplayer_controls.cpp
126 lines (117 loc) · 3.91 KB
/
videoplayer_controls.cpp
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/***********************************************************************************
** This file is part of Senior Project Launcher.
**
** Senior Project Launcher is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 2.1 of the License, or
** (at your option) any later version.
**
** Senior Project Launcher is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with Senior Project Launcher. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************************/
void SeniorProject::on_playButton_clicked()
{
switch(mediaPlayer->state())
{
case QMediaPlayer::PlayingState:
mediaPlayer->pause();
ui->playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
break;
default:
mediaPlayer->play();
ui->playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
break;
}
}
void SeniorProject::on_Information_currentChanged(int index)
{
switch(index)
{
case 0:
ui->Information->resize(ui->Information->width(), 311);
ui->controlLayout->hide();
if (mediaPlayer->state() == QMediaPlayer::PlayingState)
{
on_playButton_clicked();
}
break;
case 1:
ui->Information->resize(ui->Information->width(), 291);
if (prev_prog == prog)
changevid = false;
if (prog == 1 && changevid)
mediaPlayer->setMedia(QUrl("http://db.tt/Av4ohw4e"));
if (prog == 2 && changevid)
mediaPlayer->setMedia(QUrl("https://db.tt/nAhsdOvQ"));
if (prog == 3 && changevid)
mediaPlayer->setMedia(QUrl("https://db.tt/h7e1bTLS"));
if (prog == 4 && changevid)
mediaPlayer->setMedia(QUrl("http://db.tt/K1kwfdnZ"));
ui->controlLayout->show();
on_playButton_clicked();
break;
}
}
void SeniorProject::durationChanged(qint64 duration)
{
ui->positionSlider->setRange(0, duration);
qDebug() << "Duration changed to " + QString::number(duration);
}
void SeniorProject::positionChanged(qint64 position)
{
ui->positionSlider->setValue(position);
}
void SeniorProject::setPosition(int position)
{
mediaPlayer->setPosition(position);
}
void SeniorProject::on_volumeButton_clicked()
{
switch(mediaPlayer->isMuted())
{
case false:
mediaPlayer->setMuted(true);
ui->volumeButton->setIcon
(style()->standardIcon(QStyle::SP_MediaVolumeMuted));
break;
default:
mediaPlayer->setMuted(false);
ui->volumeButton->setIcon
(style()->standardIcon(QStyle::SP_MediaVolume));
break;
}
}
void SeniorProject::on_volumeSlider_valueChanged(int position)
{
mediaPlayer->setVolume(position);
ui->volume_label->setText(QString::number(position));
}
void SeniorProject::mediaStatusChanged(QMediaPlayer::MediaStatus status)
{
switch(status)
{
case QMediaPlayer::LoadingMedia:
changevid= false;
ui->Back->setEnabled(false);
ui->Information->setTabText(1, tr("Video (Loading...)"));
break;
case QMediaPlayer::InvalidMedia:
qDebug() << "true!";
changevid= false;
ui->Back->setEnabled(true);
ui->Information->setTabText
(1, tr("Error. Could not load video: No Internet Connection?"));
break;
default:
changevid= false;
ui->Back->setEnabled(true);
ui->Information->setTabText(1, tr("Video"));
break;
}
qDebug() << status;
}