-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoTask.h
56 lines (53 loc) · 1.43 KB
/
VideoTask.h
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
#ifndef VIDEOTASK_H
#define VIDEOTASK_H
#include "Task.h"
#include <QtAV/AVPlayer.h>
#include <QSlider>
#include <QFileInfo>
#include <QTextStream>
using namespace QtAV;
class VideoTask : public Task
{
public:
VideoTask(QString a, QString b, QFileInfo c, AVPlayer* d) : Task(a, b, c), video(d)
{
taskType = a;
taskName = b;
taskInfo = c;
timeSlider = 0;
volumeSlider = 0;
taskProgress = 0;
isFinished = false;
}
~VideoTask()
{
record();
}
AVPlayer::State getState(){ return video ? video->state() : AVPlayer::StoppedState; }
qint64 size(){ return taskInfo.size(); }
void start(){ if (getState() != AVPlayer::PlayingState) video->play(); }
void pause(){ if (getState() == AVPlayer::PlayingState) video->pause(); }
void stop(){ if (getState() != AVPlayer::StoppedState) video->pause(); }
void record()
{
QFile file("task.log");
if (!file.open(QIODevice::ReadWrite | QIODevice::Append)) return;
QTextStream in(&file);
QString str = QString::fromLocal8Bit("任务创建时间: ") + taskTime.toString()
+ QString::fromLocal8Bit("\n文件绝对路径: ") + taskInfo.absoluteFilePath()
+ QString::fromLocal8Bit("\n文件大小:") + QString::number(taskInfo.size())
+ QString::fromLocal8Bit("\n信号:") + taskName;
in << str << "\n";
file.close();
}
void setState()
{
if (getState() == AVPlayer::PlayingState)video->pause();
else video->play();
}
public:
AVPlayer* video;
QSlider* timeSlider;
QSlider* volumeSlider;
};
#endif