예제 #1
0
void VideoThread::play()
{
	if(!m_inited)
	{
		//qDebug() << "VideoThread::play(): not inited";
		return;
	}
		
	m_status = Running;
	
	if(m_readTimer && m_readTimer->isActive())
	{
		//qDebug() << "VideoThread::play(): timer active";
 		m_total_runtime += m_run_time.restart();
 	}
	else
	{
		if(m_readTimer)
			m_readTimer->start();
		m_run_time.start();
		//qDebug() << "VideoThread::play(): starting timer";
	}
	//m_readTimer->start();
	//m_video_decoder->decode(); // start decoding again
	emit movieStateChanged(QMovie::Running);
}
예제 #2
0
파일: QVideo.cpp 프로젝트: dtbinh/dviz
void QVideo::pause()
{
	m_status = Paused;
	m_total_runtime += m_run_time.elapsed();
	//qDebug() << "QVideo::pause(): m_total_runtime:"<<m_total_runtime;
	
	//emit startDecode();
	killTimer(m_play_timer);
	m_play_timer = 0;
	emit movieStateChanged(QMovie::Paused);
}
예제 #3
0
void VideoThread::pause()
{
	//qDebug() << "VideoThread::pause()";
	m_status = Paused;
	m_total_runtime += m_run_time.elapsed();
	//qDebug() << "QVideo::pause(): m_total_runtime:"<<m_total_runtime;
	
	//emit startDecode();
	if(m_inited)
		m_readTimer->stop();
	emit movieStateChanged(QMovie::Paused);
}
예제 #4
0
void VideoThread::stop()
{
	//qDebug() << "VideoThread::stop()";
	seek(0, AVSEEK_FLAG_BACKWARD);
	
	m_status = NotRunning;
	m_readTimer->stop();
	
	// Since there is no stop() or pause(), we dont need to touch m_run_time right now - it will be reset in play()
	m_total_runtime = 0;

	emit movieStateChanged(QMovie::NotRunning);
	
}
예제 #5
0
ImagePlayer::ImagePlayer(QWidget *parent, QString name )
    : QWidget(parent)
    , surface(0)
    , playButton(0)
    , positionSlider(0)
{
    connect(&movie, SIGNAL(stateChanged(QMovie::MovieState)),
            this, SLOT(movieStateChanged(QMovie::MovieState)));
    connect(&movie, SIGNAL(frameChanged(int)),
            this, SLOT(frameChanged(int)));

    ImageWidget *imageWidget = new ImageWidget( parent );
    surface = imageWidget->videoSurface();

    playButton = new QPushButton;
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));

    connect(playButton, SIGNAL(clicked()),
            this, SLOT(play()));

    positionSlider = new QSlider(Qt::Horizontal);
    positionSlider->setRange(0, 0);

    connect(positionSlider, SIGNAL(sliderMoved(int)),
            this, SLOT(setPosition(int)));

    connect(&movie, SIGNAL(frameChanged(int)),
            positionSlider, SLOT(setValue(int)));

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    //controlLayout->addWidget(openButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(positionSlider);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget( imageWidget );
    layout->addLayout( controlLayout );

    setLayout(layout);
	//
	_name = name;
	openFile();
}
예제 #6
0
파일: QVideo.cpp 프로젝트: dtbinh/dviz
void QVideo::play()
{
	m_status = Running;
	
	if(m_play_timer)
 	{
 		m_total_runtime += m_run_time.restart();
		killTimer(m_play_timer);
	}
	else
	{
		m_run_time.start();
	}
	
	m_play_timer = startTimer(1);
	//m_video_decoder->decode(); // start decoding again
	emit movieStateChanged(QMovie::Running);
}
예제 #7
0
int VideoPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: openFile(); break;
        case 1: play(); break;
        case 2: movieStateChanged((*reinterpret_cast< QMovie::MovieState(*)>(_a[1]))); break;
        case 3: frameChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: setPosition((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
예제 #8
0
파일: QVideo.cpp 프로젝트: dtbinh/dviz
void QVideo::stop()
{
	if(m_video_decoder && m_video_loaded)
	{
		//m_video_decoder->restart();
		m_video_decoder->flushBuffers();
		seek(0, AVSEEK_FLAG_BACKWARD);
	}
	
	m_status = NotRunning;
	killTimer(m_play_timer);
	m_play_timer = 0;
	
	// Since there is no stop() or pause(), we dont need to touch m_run_time right now - it will be reset in play()
	m_total_runtime = 0;

	emit movieStateChanged(QMovie::NotRunning);
	
}
예제 #9
0
VideoPlayer::VideoPlayer(QWidget *parent, Qt::WindowFlags flags)
    : QWidget(parent, flags)
    , videoItem(0)
    , playButton(0)
    , positionSlider(0)
{
    connect(&movie, SIGNAL(stateChanged(QMovie::MovieState)),
            this, SLOT(movieStateChanged(QMovie::MovieState)));
    connect(&movie, SIGNAL(frameChanged(int)),
            this, SLOT(frameChanged(int)));

    videoItem = new VideoItem;

    QGraphicsScene *scene = new QGraphicsScene(this);
    QGraphicsView *graphicsView = new QGraphicsView(scene);

#ifndef QT_NO_OPENGL
    graphicsView->setViewport(new QGLWidget);
#endif

    scene->addItem(videoItem);

    QSlider *rotateSlider = new QSlider(Qt::Horizontal);
    rotateSlider->setRange(-180,  180);
    rotateSlider->setValue(0);

    connect(rotateSlider, SIGNAL(valueChanged(int)),
            this, SLOT(rotateVideo(int)));

    QAbstractButton *openButton = new QPushButton(tr("Open..."));
    connect(openButton, SIGNAL(clicked()), this, SLOT(openFile()));

    playButton = new QPushButton;
    playButton->setEnabled(false);
    playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));

    connect(playButton, SIGNAL(clicked()),
            this, SLOT(play()));

    positionSlider = new QSlider(Qt::Horizontal);
    positionSlider->setRange(0, 0);

    connect(positionSlider, SIGNAL(sliderMoved(int)),
            this, SLOT(setPosition(int)));

    connect(&movie, SIGNAL(frameChanged(int)),
            positionSlider, SLOT(setValue(int)));

    QBoxLayout *controlLayout = new QHBoxLayout;
    controlLayout->setMargin(0);
    controlLayout->addWidget(openButton);
    controlLayout->addWidget(playButton);
    controlLayout->addWidget(positionSlider);

    QBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(graphicsView);
    layout->addWidget(rotateSlider);
    layout->addLayout(controlLayout);

    setLayout(layout);
}