first commit
This commit is contained in:
132
project/fm_viewer/ui/rm_play_slider.cpp
Normal file
132
project/fm_viewer/ui/rm_play_slider.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#include "rm_play_slider.h"
|
||||
#include "rm_slider.h"
|
||||
#include "../fm_dimensions.h"
|
||||
#include "../fm_app_colors.h"
|
||||
#include "fm_layer.h"
|
||||
#include "../core/rm_player.h"
|
||||
#include "../data/rm_video_item_2ch.h"
|
||||
#include <QStyleOption>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
#include "fm_colors.h"
|
||||
|
||||
RMPlaySlider::RMPlaySlider(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
|
||||
|
||||
FMWidgetBackground(this,"slider_frame",0x3a3a3a);
|
||||
|
||||
layout = new QHBoxLayout(this);
|
||||
layout->setAlignment(Qt::AlignCenter);
|
||||
ZERO_LAYOUT(layout);
|
||||
|
||||
LAYOUT_SPACE(layout,10,0);
|
||||
|
||||
currentTimeLabel = new QLabel(this);
|
||||
currentTimeLabel->setAlignment(Qt::AlignCenter);
|
||||
FMLabel(currentTimeLabel,"current_time","Arial",FM_SELECTED_TEXT_COLOR,14,false);
|
||||
currentTimeLabel->setText(ZERO_TIME_STRING);
|
||||
layout->addWidget(currentTimeLabel);
|
||||
currentTimeLabel->setFixedWidth(60);
|
||||
|
||||
//LAYOUT_SPACE(layout,10,0);
|
||||
|
||||
slider = new RMSlider(this);
|
||||
slider->setValue(0);
|
||||
//slider->setObjectName("play");
|
||||
FMSlider(slider,"play_slider",FM_SILDER_COLOR,0x666666);
|
||||
#if (RM_MODEL != RM_MODEL_TYPE_EMT_KR)
|
||||
layout->addWidget(slider);
|
||||
#endif
|
||||
|
||||
durationLabel = new QLabel(this);
|
||||
durationLabel->setAlignment(Qt::AlignCenter);
|
||||
FMLabel(durationLabel,"duration_time","Arial",FM_COLOR_SLIDER_TEXT,14,false);
|
||||
durationLabel->setText(ZERO_TIME_STRING);
|
||||
durationLabel->setFixedWidth(60);
|
||||
layout->addWidget(durationLabel);
|
||||
|
||||
#if (RM_MODEL == RM_MODEL_TYPE_EMT_KR)
|
||||
layout->addWidget(slider);
|
||||
#endif
|
||||
|
||||
//LAYOUT_SPACE(layout,10,0);
|
||||
|
||||
LAYOUT_SPACE(layout,10,0);
|
||||
|
||||
RMPlayer* player = RMPlayer::instance();
|
||||
|
||||
player->setSlider(slider);
|
||||
|
||||
connect(player,SIGNAL(positionChanged(qint64,qint64)),SLOT(onPositionChanged(qint64,qint64)));
|
||||
connect(player,SIGNAL(playEvent(PLAY_EVENT,RMVideoItem*)),SLOT(onPlayEvent(PLAY_EVENT,RMVideoItem*)));
|
||||
}
|
||||
void RMPlaySlider::setEnabled(bool bEnabled)
|
||||
{
|
||||
//qInfo() << __FUNCTION__ << __LINE__;
|
||||
// QT 5.12 문제로 보임 disabled 된 경우 QLabel Text 가 번지는 현상 발생
|
||||
slider->setEnabled(bEnabled);
|
||||
}
|
||||
/*
|
||||
void RMPlaySlider::paintEvent(QPaintEvent *pe)
|
||||
{
|
||||
Q_UNUSED(pe);
|
||||
QStyleOption o;
|
||||
o.initFrom(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
|
||||
}
|
||||
*/
|
||||
void RMPlaySlider::onPositionChanged(qint64 position,qint64 duration)
|
||||
{
|
||||
// qInfo() << "onPositionChanged:" << position << " duration:" << duration;
|
||||
// 마지막 초를 표시하기 위해 사용
|
||||
//qint64 posCeil = ((qint64)(ceil(((double)duration) / 1000.0) * 1000.0));
|
||||
|
||||
// 60260 video duration: 59281
|
||||
qint64 pos = MIN(position,duration);
|
||||
|
||||
qint64 pos2 = (qint64)(((double)pos) * _itemDurationMSec / ((double)(duration)));
|
||||
|
||||
// 캡쳐 등에서 시간 동기화를 위해 사용
|
||||
RMPlayer::instance()->titleSeconds = pos2;
|
||||
//qInfo() << __FUNCTION__ << " video duration:" << _itemDurationMSec << duration << "POS:" << pos << " POS2:" << pos2;
|
||||
|
||||
currentTimeLabel->setText(RMVideoItem::durationString(pos2,true));
|
||||
}
|
||||
void RMPlaySlider::onPlayEvent(PLAY_EVENT event,RMVideoItem* item)
|
||||
{
|
||||
if(event == PLAY_DID_LOADED)
|
||||
{
|
||||
if(item == NULL) {
|
||||
return;
|
||||
}
|
||||
//Q_ASSERT(item != NULL);
|
||||
|
||||
// 로딩이 완료되지 않은 상태에서 slider click 하면 thread lock 이 발생함..
|
||||
// 50 으로 처리할 경우 다시 발생함.
|
||||
QTimer::singleShot(200,this,SLOT(onEnableSliderDelay()));
|
||||
|
||||
//playSlider->setEnabled(true);
|
||||
|
||||
|
||||
//playSlider->slider->setEnabled(true);
|
||||
//qInfo() << __FUNCTION__ << playSlider->isEnabled();
|
||||
currentTimeLabel->setText(ZERO_TIME_STRING);
|
||||
durationLabel->setText(item->titleDuration());
|
||||
|
||||
_itemDurationMSec = (double)item->durationInMSecs();
|
||||
|
||||
}
|
||||
else if (event == PLAY_DID_CLEARED)
|
||||
{
|
||||
setEnabled(false);
|
||||
currentTimeLabel->setText(ZERO_TIME_STRING);
|
||||
durationLabel->setText(ZERO_TIME_STRING);
|
||||
slider->setValue(0);
|
||||
}
|
||||
}
|
||||
void RMPlaySlider::onEnableSliderDelay()
|
||||
{
|
||||
setEnabled(true);
|
||||
}
|
||||
Reference in New Issue
Block a user