⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 mplayer開發驅動
💻 CPP
字号:
#include <QApplication>
#include <QProcess>
#include <QVBoxLayout>
#include <QLayoutItem>
#include <QWidget>
#include <QPaintEvent>
#include <QPainter>
#include <QColor>
#include <QRect>
#include <QLinearGradient>
#include <QSizePolicy>
#include <QPushButton>
#include <QTextEdit>
#include <QSlider>
#include <QCloseEvent>
#include <QTimer>

#ifdef Q_OS_WIN32
const QString mplayerPath("path/to/mplayer.exe");
#else
const QString mplayerPath("mplayer");
#endif
const QString movieFile("video.mpg");

class PlayerWidget: public QWidget
{
	Q_OBJECT

public:
	PlayerWidget(QWidget *parent =0)
		:QWidget(parent), isPlaying(false)
	{
		controller = new QPushButton("Play");		
		renderTarget = new QWidget(this);
		renderTarget->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
		renderTarget->setAttribute(Qt::WA_PaintOnScreen);		renderTarget->setMinimumSize(176, 144);		
		timeLine = new QSlider(Qt::Horizontal);

		log = new QTextEdit;
		log->setReadOnly(true);

		QVBoxLayout *layout = new QVBoxLayout;
		layout->addWidget(controller);
		layout->addWidget(renderTarget);
		layout->addWidget(timeLine);
		layout->addWidget(log);
		setLayout(layout);

		mplayerProcess = new QProcess(this);

		poller = new QTimer(this);

		connect(controller, SIGNAL(clicked()), this, SLOT(switchPlayState()));
		connect(mplayerProcess, SIGNAL(readyReadStandardOutput()),
			this, SLOT(catchOutput()));
		connect(mplayerProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
			this, SLOT(mplayerEnded(int, QProcess::ExitStatus)));
		connect(poller, SIGNAL(timeout()), this, SLOT(pollCurrentTime()));
		connect(timeLine, SIGNAL(sliderMoved(int)), this, SLOT(timeLineChanged(int)));
	}

protected:
	virtual void closeEvent(QCloseEvent *e)
	{
		stopMPlayer();
		e->accept();
	}

private:
	bool startMPlayer()
	{
		if(isPlaying)
			return true;

		QStringList args;		
		// On demande 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -