1.添加positioning
2.添加控件,修改名称,修改最大值提升精度
3.
在类xplay2中添加
void Xplay2::timerEvent(QTimerEvent* e)
{
long long total = dt.totalMs;
qDebug() << "total: " << total << endl;
if (total > 0)
{
double pos = (double)dt.pts / (double)total;
qDebug()<< "pos: " << pos << endl;
int v = ui.playPos->maximum() * pos;
ui.playPos->setValue(v);
}
}
当前解码到的pts除以总pts,是个比例,用该比例乘上进度条总长度获得一个值,用该值传回进度条获得当前的播放位置,并不能实现拖拽功能
在xplay的构造函数中添加定时器
Xplay2::Xplay2(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
dt.start();
startTimer(40);
}
让控件刷新与视频同步(fps=25)
双击全屏
void Xplay2::mouseDoubleClickEvent(QMouseEvent* e)
{
if (isFullScreen())
this->showNormal();
else
this->showFullScreen();
}
窗口尺寸变化
void Xplay2::resizeEvent(QResizeEvent* e)
{
ui.playPos->move(50, this->height() - 100);
ui.playPos->resize(this->width() - 100, ui.playPos->height());
ui.openfile->move(100, this->height() - 150);
ui.openGLWidget->resize(this->size());
}
数值单位为像素,从左上角开始